將 Key Vault VM 延伸模組套用至 Azure 雲端服務 (延伸支援)

本文提供適用於 Windows 的 Azure Key Vault VM 延伸模組的基本資訊,並說明如何在 Azure 雲端服務中啟用。

什麼是 Key Vault VM 延伸模組?

金鑰保存庫 VM 擴充功能可自動重新整理儲存在 Azure 金鑰保存庫中的憑證。 具體而言,此擴充功能會監視儲存於金鑰保存庫的觀察憑證清單。 在延伸模組偵測到變更時,其會擷取並安裝對應的憑證。 如需詳細資訊,請參閱適用於 Windows 的 Key Vault VM 延伸模組

Key Vault VM 延伸模組中的新功能?

Azure 雲端服務 (延伸支援) 平台上現在支援 Key Vault VM 延伸模組,以啟用端對端的憑證管理。 延伸模組現在可以以預先定義的輪詢間隔從已設定的金鑰保存庫提取憑證,並加以安裝供服務使用。

如何使用 Key Vault VM 延伸模組?

下列程序將顯示如何在 Azure 雲端服務上安裝 Key Vault VM 延伸模組,方法是先在保存庫中建立啟動程序憑證,以從 Microsoft Entra ID 取得權杖。 該權杖將有助於向保存庫驗證延伸模組。 設定驗證程序並安裝延伸模組之後,將會以定期輪詢間隔自動提取所有最新的憑證。

注意

Key Vault VM 延伸模組會將 Windows 憑證存放區中的所有憑證,下載至 VM 延伸模組設定中 certificateStoreLocation 屬性提供的位置。 目前,Key Vault VM 延伸模組只會將憑證私密金鑰的存取權授與本機系統管理員帳戶。

必要條件

若要使用 Azure Key Vault VM 延伸模組,您需要有 Microsoft Entra 租用戶。 如需詳細資訊,請參閱快速入門:設定租用戶

啟用 Azure Key Vault VM 延伸模組

  1. 在您的保存庫中產生憑證,並下載該憑證的 .cer 檔案。

  2. Azure 入口網站中,移至 [應用程式註冊]

    Screenshot of resources available in the Azure portal, including app registrations.

  3. 應用程式註冊頁面上,選取新增註冊

    Screenshot that shows the page for app registrations in the Azure portal.

  4. 在下一個頁面上,填寫表單並完成應用程式建立。

  5. 將憑證的 .cer 檔案上傳至 Microsoft Entra 應用程式入口網站。

    您可以選擇性地使用 Key Vault 的 Azure 事件方格通知功能來上傳憑證。

  6. 在 Key Vault 中授與 Microsoft Entra 應用程式祕密權限:

    • 如果您要使用角色型存取控制 (RBAC) 預覽,則請搜尋您所建立 Microsoft Entra 應用程式的名稱,並將其指派給「金鑰保存庫祕密使用者 (預覽)」角色。
    • 如果您要使用保存庫存取原則,則請將 Secret-Get 權限指派給您建立的 Microsoft Entra 應用程式。 如需詳細資訊,請參閱指派存取原則
  7. 使用 cloudService 資源的 Azure Resource Manager 範本程式碼片段來安裝 Key Vault VM 延伸模組:

    {
        "osProfile":
        {
            "secrets":
            [
                {
                    "sourceVault":
                    {
                        "id": "[parameters('sourceVaultValue')]"
                    },
                    "vaultCertificates":
                    [
                        {
                            "certificateUrl": "[parameters('bootstrpCertificateUrlValue')]"
                        }
                    ]
                }
            ]
        },
        "extensionProfile":
        {
            "extensions":
            [
                {
                    "name": "KVVMExtensionForPaaS",
                    "properties":
                    {
                        "type": "KeyVaultForPaaS",
                        "autoUpgradeMinorVersion": true,
                        "typeHandlerVersion": "1.0",
                        "publisher": "Microsoft.Azure.KeyVault",
                        "settings":
                        {
                            "secretsManagementSettings":
                            {
                                "pollingIntervalInS": "3600",
                                "certificateStoreName": "My",
                                "certificateStoreLocation": "LocalMachine",
                                "linkOnRenewal": false,
                                "requireInitialSync": false,
                                "observedCertificates": "[parameters('keyVaultObservedCertificates']"
                            },
                            "authenticationSettings":
                            {
                                "clientId": "Your AAD app ID",
                                "clientCertificateSubjectName": "Your boot strap certificate subject name [Do not include the 'CN=' in the subject name]"
                            }
                        }
                    }
                }
            ]
        }
    }
    

    您可能需要在 ServiceDefinition.csdef 中指定啟動程序憑證的憑證存放區:

        <Certificates>
                 <Certificate name="bootstrapcert" storeLocation="LocalMachine" storeName="My" />
        </Certificates> 
    

下一步

藉由在 Azure 雲端服務 (延伸支援) 中啟用監視,進一步改善您的部署。