airflow.providers.microsoft.azure.secrets.key_vault
¶
此模組包含 Azure Key Vault 後端。
模組內容¶
類別¶
從 Azure Key Vault 密鑰中檢索 Airflow 連線或變數。 |
- class airflow.providers.microsoft.azure.secrets.key_vault.AzureKeyVaultBackend(connections_prefix='airflow-connections', variables_prefix='airflow-variables', config_prefix='airflow-config', vault_url='', sep='-', *, tenant_id='', client_id='', client_secret='', managed_identity_client_id='', workload_identity_tenant_id='', **kwargs)[原始碼]¶
基底:
airflow.secrets.BaseSecretsBackend
、airflow.utils.log.logging_mixin.LoggingMixin
從 Azure Key Vault 密鑰中檢索 Airflow 連線或變數。
Azure Key Vault 可以設定為
airflow.cfg
中的密鑰後端[secrets] backend = airflow.providers.microsoft.azure.secrets.key_vault.AzureKeyVaultBackend backend_kwargs = {"connections_prefix": "airflow-connections", "vault_url": "<azure_key_vault_uri>"}
例如,如果密鑰前綴為
airflow-connections-smtp-default
,如果您提供{"connections_prefix": "airflow-connections"}
並請求 conn_idsmtp-default
,則可以存取此密鑰。如果變數前綴為airflow-variables-hello
,如果您提供{"variables_prefix": "airflow-variables"}
並請求變數金鑰hello
,則可以存取此變數。對於用戶端驗證,Azure Python SDK 中的
DefaultAzureCredential
用作憑證提供者,它支援服務主體、受控身分和使用者憑證例如,若要指定具有密碼的服務主體,您可以設定環境變數
AZURE_TENANT_ID
、AZURE_CLIENT_ID
和AZURE_CLIENT_SECRET
。另請參閱
如需用戶端驗證的詳細資訊,請參閱
DefaultAzureCredential
類別參考: https://docs.microsoft.com/en-us/python/api/azure-identity/azure.identity.defaultazurecredential?view=azure-python- 參數
connections_prefix (str) – 指定要讀取以取得連線的密鑰前綴。如果設定為 None (null),則不會將連線請求傳送至 Azure Key Vault
variables_prefix (str) – 指定要讀取以取得變數的密鑰前綴。如果設定為 None (null),則不會將變數請求傳送至 Azure Key Vault
config_prefix (str) – 指定要讀取以取得變數的密鑰前綴。如果設定為 None (null),則不會將組態請求傳送至 Azure Key Vault
vault_url (str) – 要使用的 Azure Key Vault 的 URL
sep (str) – 用於串連 secret_prefix 和 secret_id 的分隔符號。預設值:「-」
tenant_id (str) – 要使用的 Azure Key Vault 的租用戶識別碼。如果未提供,則會回退到
DefaultAzureCredential
client_id (str) – 要使用的 Azure Key Vault 的用戶端識別碼。如果未提供,則會回退到
DefaultAzureCredential
managed_identity_client_id (str) – 使用者指派受控身分的用戶端識別碼。如果與 workload_identity_tenant_id 一起提供,它們將傳遞至
DefaultAzureCredential
。workload_identity_tenant_id (str) – 應用程式 Microsoft Entra 租用戶的識別碼。也稱為其「目錄」識別碼。如果與 managed_identity_client_id 一起提供,它們將傳遞至
DefaultAzureCredential
。
- get_conn_value(conn_id)[原始碼]¶
從 Azure Key Vault 密鑰取得 Airflow 連線的序列化表示。
- 參數
conn_id (str) – 要檢索的 Airflow 連線識別碼