Microsoft Azure Blob Storage 連線¶
Microsoft Azure Blob Storage 連線型別支援 Azure Blob Storage 整合。
Azure Blob Storage 身份驗證¶
有六種方法可以使用 Airflow 連線到 Azure Blob Storage。
使用 令牌憑證,即在 Airflow 連線中新增特定的憑證(client_id、secret、tenant)和訂閱 ID。
使用 Azure 共享金鑰憑證,即在 Airflow 連線的
shared_access_key中新增共享金鑰憑證。使用 SAS Token,即在 Airflow 連線的
sas_token中新增金鑰配置。使用 連線字串,即在 Airflow 連線的
connection_string中新增連線字串。透過設定
managed_identity_client_id、workload_identity_tenant_id使用託管身份(底層使用帶有這些引數的 DefaultAzureCredential)回退到 DefaultAzureCredential。這包含一種嘗試不同身份驗證選項的機制:託管系統身份、環境變數、透過 Azure CLI 身份驗證等。
一次只能使用一種授權方法。如果需要管理多個憑證或金鑰,則應配置多個連線。
預設連線 ID¶
所有與 Microsoft Azure Blob Storage 相關的 hook 和 operator 預設使用 wasb_default。
配置連線¶
- 登入(可選)
指定用於 Azure Blob Storage 的登入資訊。作為服務主體憑證進行 Active Directory(令牌)身份驗證時嚴格需要。如果指定了主機(帳戶 URL),則其餘情況可選。可以省略,以回退到 DefaultAzureCredential。
- 密碼(可選)
指定用於 Azure Blob Storage 的密碼。用於 Active Directory(令牌憑證)和共享金鑰身份驗證。可以省略,以回退到 DefaultAzureCredential。
- 主機(可選)
指定 Azure Blob Storage 的帳戶 URL。作為服務主體憑證進行 Active Directory(令牌)和 DefaultAzureCredential 身份驗證時嚴格需要。如果指定了登入資訊(帳戶名),則其餘情況可選。
- Blob Storage 連線字串(可選)
用於連線字串身份驗證的連線字串。可以省略,以回退到 DefaultAzureCredential。
- Blob Storage 共享訪問金鑰(可選)
指定共享訪問金鑰。僅在共享訪問金鑰身份驗證時需要。可以省略,以回退到 DefaultAzureCredential。
- SAS Token(可選)
用於 SAS Token 身份驗證的 SAS Token。可以省略,以回退到 DefaultAzureCredential。
- 租戶 ID(Active Directory 身份驗證)(可選)
指定要使用的租戶。僅在 Active Directory(令牌)身份驗證時需要。可以省略,以回退到 DefaultAzureCredential。
- 額外引數(可選)
指定可在 Azure 連線中使用的額外引數(以 JSON 字典形式)。以下引數均為可選:
client_secret_auth_config: 使用 ClientSecretCredential 作為服務主體進行身份驗證時要傳遞的額外配置。可以省略,以回退到 DefaultAzureCredential。managed_identity_client_id: 使用者分配的託管身份的客戶端 ID。如果與 workload_identity_tenant_id 一起提供,它們將傳遞給DefaultAzureCredential。workload_identity_tenant_id: 應用程式的 Microsoft Entra 租戶 ID。也稱為其“目錄”ID。如果與 managed_identity_client_id 一起提供,它們將傳遞給DefaultAzureCredential。
在環境變數中指定連線時,應使用 URI 語法。
請注意,URI 的所有組成部分都應該進行 URL 編碼。
例如,使用令牌憑證連線
export AIRFLOW_CONN_WASB_DEFAULT='wasb://blob%20username:blob%20password@myblob.com?tenant_id=tenant+id'