Microsoft Azure Cosmos

Microsoft Azure Cosmos 連線型別啟用 Azure Cosmos 整合。

Azure 認證

使用 Airflow 連線到 Azure Cosmos 有三種方法。

  1. 使用主金鑰(Primary Keys),即向 Airflow 連線新增特定憑據 (client_id, secret, tenant) 和帳戶名。

  2. 透過設定 managed_identity_client_idworkload_identity_tenant_id 來使用託管標識(managed identity)(底層使用帶有這些引數的 DefaultAzureCredential)。

  3. 回退到DefaultAzureCredential。這包含一個嘗試不同選項進行身份驗證的機制:託管系統標識(Managed System Identity)、環境變數、透過 Azure CLI 進行身份驗證等。

預設連線 ID

所有與 Microsoft Azure Cosmos 相關的鉤子(hooks)和運算子(operators)預設使用 azure_cosmos_default

配置連線

登入

指定用於初始連線的 Cosmos 終結點 URI。

密碼(可選)

指定用於初始連線的 Cosmos 主金鑰令牌(Cosmos Master Key Token)。可以省略此項,以回退到 DefaultAzureCredential

額外(可選)

指定可在 Azure Cosmos 連線中使用的額外引數(以 JSON 字典形式)。以下引數均為可選:

  • database_name: 指定要使用的 Azure Cosmos 資料庫。

  • collection_name: 指定要使用的 Azure Cosmos 集合。

  • partition_key: 指定集合的分割槽鍵。

  • subscription_id: 指定用於初始連線的訂閱 ID。回退到 DefaultAzureCredential 所必需。

  • resource_group_name: 指定所需 Azure Cosmos 所在的 Azure 資源組名稱。回退到 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_AZURE_COSMOS_DEFAULT='azure-cosmos://https%3A%2F%2Fairflow.azure.com:master%20key@?database_name=mydatabase&collection_name=mycollection'

此條目是否有幫助?