Share via


使用受控識別來存取 Azure Key Vault 憑證

Microsoft Entra ID 所產生受控識別可讓您的 Azure Front Door 執行個體輕鬆安全存取其他受 Microsoft Entra 保護的資源,例如 Azure Key Vault。 Azure 會管理身分識別資源,因此您無須建立或輪替任何祕密。 如需受控識別的詳細資訊,請參閱什麼是適用於 Azure 資源的受控識別?

在 Azure Front Door 中啟用受控識別,並授與存取 Azure Key Vault 的適當權限後,Azure Front Door 只會使用受控識別來存取憑證。 如果您未新增受控識別權限至 Key Vault,則會因為沒有 Key Vault 的權限,導致自訂憑證自動輪替和新增憑證失敗。 如果停用受控識別,則 Azure Front Door 會提供後援以使用原始設定的 Microsoft Entra 應用程式。 不建議使用此解決方案,未來將會淘汰。

您可以將兩種類型的身分識別授與 Azure Front Door 設定檔:

  • 系統指派的身分識別會繫結至您的服務,若刪除服務則會一併刪除。 服務僅能有一個系統指派的身分識別。

  • 使用者指派的身分識別是一項獨立 Azure 資源,可指派給您的服務。 服務可有多個使用者指派的身分識別。

受控識別專屬於裝載 Azure 訂用帳戶的 Microsoft Entra 租用戶。 如果訂閱移至其他目錄,這些身分識別不會隨之更新。 如果您移動訂閱,即必須重新建立並重新設定身分識別。

您也可以選擇使用角色型存取控制 (RBAC)存取原則來設定 Azure Key Vault 存取權。

必要條件

您必須已建立 Azure Front Door 標準或進階設定檔,才能設定 Azure Front Door 的受控識別。 若要建立新的 Front Door 設定檔,請參閱建立 Azure Front Door

啟用受控識別

  1. 移至現有的 Azure Front Door 設定檔。 從左側功能表窗格的 [安全性] 底下選取 [身分識別]

    Screenshot of the identity button under settings for a Front Door profile.

  2. 選取系統指派使用者指派受控識別。

    • 系統指派 - 針對 Azure Front Door 設定檔生命週期建立的受控識別,可用以存取 Azure Key Vault。

    • 使用者指派 - 用來向 Azure Key Vault 進行驗證的獨立受控識別資源,且有自己的生命週期。

    系統指派

    1. 將 [狀態] 切換到 [開啟],然後選取 [儲存]

      Screenshot of the system assigned managed identity configuration page.

    2. 您會收到訊息提示,確認要為 Front Door 設定檔建立系統受控識別。 選取以確認。

      Screenshot of the system assigned managed identity confirmation message.

    3. 建立好系統指派的受控識別,並向 Microsoft Entra ID 註冊之後,您就可以使用 [物件 (主體) 識別碼] 將 Azure Key Vault 存取權授與 Azure Front Door。

      Screenshot of the system assigned managed identity registered with Microsoft Entra ID.

    使用者指派

    您必須已建立使用者受控識別。 若要建立新的身分識別,請參閱建立使用者指派的受控識別

    1. 在 [使用者指派] 索引標籤中,選取 [+ 新增] 以新增使用者指派的受控識別。

      Screenshot of the user assigned managed identity configuration page.

    2. 搜尋並選取使用者指派的受控識別。 然後選取 [新增] 將使用者受控識別新增至 Azure Front Door 設定檔。

      Screenshot of the add user assigned managed identity page.

    3. 您會在 Azure Front Door 設定檔中看到所選取的使用者指派受控識別名稱。

      Screenshot of the add user assigned managed identity added to Front Door profile.


設定 Key Vault 存取

  • 角色型存取控制 - 將 Azure Key Vault 的存取權授與 Azure Front Door,具有 Azure Resource Manager 的精細存取控制。
  • 存取原則 - 原生 Azure Key Vault 存取控制,以將 Azure Key Vault 的存取權授與 Azure Front Door。

如需詳細資訊,請參閱 Azure 角色型存取控制 (Azure RBAC) 與存取原則

角色型存取控制 (RBAC)

  1. 巡覽至您的 Azure Key Vault。 選取 [設定] 底下的 [存取控制 (IAM)],然後選取 [+ 新增]。 從下拉式功能表中選取 [新增角色指派]

    Screenshot of the access control (IAM) page for a Key Vault.

  2. 在 [新增角色指派] 頁面上,在搜尋方塊中搜尋 Key Vault 祕密使用者。 然後從搜尋結果中選取 [Key Vault 祕密使用者]

    Screenshot of the add role assignment page for a Key Vault.

  3. 選取 [成員] 索引標籤,然後選取 [受控識別]。 選取 [+ 選取成員],將受控識別新增至角色指派。

    Screenshot of the members tab for the add role assignment page for a Key Vault.

  4. 選取與您的 Azure Front Door 相關聯的 [系統指派] 或 [使用者指派] 受控識別,然後選取 [選取] 將受控識別新增至角色指派。

    Screenshot of the select members page for the add role assignment page for a Key Vault.

  5. 選取 [檢閱 + 指派],以設定角色指派。

    Screenshot of the review and assign page for the add role assignment page for a Key Vault.

存取原則

  1. 巡覽至您的 Azure Key Vault。 選取 [設定] 下的 [存取原則],然後選取 [+ 建立]

    Screenshot of the access policies page for a Key Vault.

  2. 在 [建立存取原則] 頁面的 [權限] 索引標籤上,選取 [祕密權限] 下的 [列出] 和 [取得]。 然後選取 [下一步] 設定主體索引標籤。

    Screenshot of the permissions tab for the Key Vault access policy.

  3. 在 [主體] 索引標籤上:如果使用系統受控識別,請貼上物件 (主體) 識別碼;如果您正在使用使用者指派的受控識別,請輸入名稱。 然後選取 [檢閱 + 建立] 索引標籤。已略過 [應用程式] 索引標籤,因為已為您選取 Azure Front Door。

    Screenshot of the principal tab for the Key Vault access policy.

  4. 檢閱存取原則設定,然後選取 [建立] 設定存取原則。

    Screenshot of the review and create tab for the Key Vault access policy.

驗證存取權

  1. 移至您已啟用受控識別的 Azure Front Door 設定檔,然後選取 [安全性] 下的 [祕密]

    Screenshot of accessing secrets from under settings of a Front Door profile.

  2. 確認受控識別出現在 Front Door 所用憑證的 [存取角色] 資料行下。 如果您是第一次設定受控識別,您必須將憑證新增至 Front Door,才能看到此資料行。

    Screenshot of Azure Front Door using managed identity to access certificate in Key Vault.

下一步