---
title: 使用 Azure Key Vault 設定 CMEK
url: https://platform.claude.com/docs/zh-TW/manage-claude/cmek-azure-key-vault
description: 建立 Azure Key Vault 金鑰、授予 Anthropic 對您金鑰的存取權，並在 Claude Platform 或 Claude Enterprise 中使用該金鑰。
---

讓 Claude Code 為您設定此功能

```text
/claude-api 協助我使用 Azure Key Vault 設定客戶管理的加密金鑰
```

## 開始之前

在 Claude 中：

* 客戶管理的加密金鑰（CMEK）已[為您的組織開啟](https://platform.claude.com/docs/zh-TW/manage-claude/cmek#availability)。
* 您已取得您的 Anthropic 組織 ID，即不含 `org_` 前綴的 UUID。請從 Claude Console 中的 [Organization](https://platform.claude.com/settings/organization) 複製，或從 claude.ai 上的 **Organization settings > Organization and access** 複製。建立金鑰的人需要此 ID。
* 您是 Claude Platform 上的 Organization Admin，或是 Claude Enterprise 上的 Owner 或 Primary Owner。
* 在 Claude Platform 上，您擁有一個[保留資料](https://platform.claude.com/docs/zh-TW/manage-claude/cmek-data-retention#data-retention)的工作區，最好是新的工作區，因為[現有資料仍以 Anthropic 的金鑰加密](https://platform.claude.com/docs/zh-TW/manage-claude/cmek-how-it-works#when-your-key-takes-effect)。
* 在 Claude Enterprise 上，您了解[哪些功能會關閉或變更](https://platform.claude.com/docs/zh-TW/manage-claude/cmek-coverage-claude-enterprise#turned-off-or-changed)。

在 Azure 中：

* 您可以在您的金鑰保存庫中建立金鑰，並在其上指派 RBAC 角色。
* 您可以在您的 Entra 租用戶中建立服務主體（Application Administrator、Cloud Application Administrator 或同等的自訂角色）。
* 保存庫具有針對 `AuditEvent` 日誌類別的診斷設定。若沒有此設定，Anthropic 對您金鑰執行的操作將不會留下任何稽核軌跡。

## 在 Azure 中：建立金鑰

如果 **Verify** 或 **Add** 失敗，請參閱 [Azure Key Vault 的修正方式](https://platform.claude.com/docs/zh-TW/manage-claude/cmek-troubleshooting#azure-key-vault)。

以下步驟會授予 Anthropic 的多租用戶應用程式對您金鑰的存取權：

* **Name:** `anthropic-cmek-client-us`
* **Client ID:** `8635ae1a-3e5d-44e8-a4ed-e0f614466f87`

請僅使用此用戶端 ID 和名稱，切勿使用透過電子郵件或聊天傳送的 ID 和名稱。此應用程式不會要求任何 Microsoft Graph 權限。

### 檢查保存庫

若要獲得最低的延遲，請使用位於 `northcentralus` 或 `eastus2` 的保存庫。請先在 Azure CLI 或 Cloud Shell 中執行以下命令：

```bash
az keyvault show --name <your-vault-name> \
  --query "{rbac:properties.enableRbacAuthorization, purge:properties.enablePurgeProtection, pub:properties.publicNetworkAccess, net:properties.networkAcls.defaultAction, ipRules:properties.networkAcls.ipRules, uri:properties.vaultUri, tenantId:properties.tenantId}"
```

| 欄位      | 必須為                                                                                                                                        |
| ------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `rbac`  | `true`                                                                                                                                     |
| `purge` | `true`。如果為 `false` 或 `null`，請先開啟清除保護。開啟後即無法再關閉。                                                                                            |
| `pub`   | `"Enabled"`。不支援私人端點。                                                                                                                       |
| `net`   | `"Allow"`，或 `"Deny"` 並在 `ipRules` 中包含 [Anthropic 的輸出 IP 位址](https://platform.claude.com/docs/zh-TW/api/ip-addresses#outbound-ip-addresses) |

複製 `uri`（保存庫 URI）和 `tenantId`。

### 建立金鑰並授予存取權

在本頁中，`<ORGANIZATION_UUID>` 是您的 [Anthropic 組織 ID](https://platform.claude.com/docs/zh-TW/manage-claude/cmek-azure-key-vault#prerequisites)，以小寫表示。若要使用您現有的金鑰，請先[新增組織標籤](https://platform.claude.com/docs/zh-TW/manage-claude/cmek-azure-key-vault#organization-tag)。

<Tabs>
  <Tab title="Azure 入口網站">
    <Steps>
      <Step title="建立 Anthropic 的服務主體">
        從入口網站的頂端導覽列開啟 Cloud Shell。執行以下命令：

        ```bash
        az ad sp create --id 8635ae1a-3e5d-44e8-a4ed-e0f614466f87
        ```

        如果服務主體已存在，請繼續下一個步驟。
      </Step>

      <Step title="確認服務主體已存在">
        前往 **Microsoft Entra ID > Enterprise applications**，並清除預設的應用程式類型篩選條件。搜尋 `anthropic-cmek-client-us`。

        <Frame caption="Entra 企業應用程式中的 anthropic-cmek-client-us 服務主體。">
          ![anthropic-cmek-client-us 的 Microsoft Entra 企業應用程式概觀，顯示其 Application ID 和 Object ID。](https://platform.claude.com/docs/images/cmek/azure-service-principal.png)
        </Frame>
      </Step>

      <Step title="開啟 Create a key 頁面">
        開啟您的金鑰保存庫並選取 **Keys**。按一下 **Generate/Import**。
      </Step>

      <Step title="在您的保存庫中建立 RSA 金鑰">
        設定以下值：

        * **Name:** 金鑰的名稱
        * **Key type:** RSA
        * **RSA key size:** 3072 或更大

        按一下 **Tags** 旁的連結。
      </Step>

      <Step title="新增組織標籤">
        輸入以下值：

        * **Tag Name:** `anthropic-org-<ORGANIZATION_UUID>`
        * **Tag Value:** `true`

        按一下 **OK**，然後按一下 **Create**。

        <Frame caption="建立大小為 3072 或更大的 RSA 金鑰，並將標籤 anthropic-org-<ORGANIZATION_UUID> 設為 true。">
          ![Azure Key Vault 的 Create a key 頁面，包含 RSA、3072 金鑰大小，以及設為 true 的 anthropic-org 標籤。](https://platform.claude.com/docs/images/cmek/azure-create-key-tag.png)
        </Frame>
      </Step>

      <Step title="限制允許的操作">
        開啟新金鑰，然後開啟其目前版本。在 **Permitted operations** 下，清除 **Wrap Key** 和 **Unwrap Key** 以外的所有核取方塊。按一下 **Save**。

        <Frame caption="將允許的操作限制為 Wrap Key 和 Unwrap Key。金鑰版本會顯示組織標籤。">
          ![Azure Key Vault 金鑰版本，具有 1 個標籤，且 Permitted operations 限制為 Wrap Key 和 Unwrap Key。](https://platform.claude.com/docs/images/cmek/azure-permitted-operations-tag.png)
        </Frame>
      </Step>

      <Step title="開啟金鑰的存取控制">
        開啟金鑰本身，而非保存庫。選取其 **Access control (IAM)** 索引標籤，然後按一下 **Add > Add role assignment**。
      </Step>

      <Step title="選取角色">
        在 **Role** 索引標籤上，選取 **Key Vault Crypto User**。按一下 **Next**。
      </Step>

      <Step title="新增 Anthropic 的服務主體">
        在 **Members** 索引標籤上，按一下 **Select members**。搜尋 `anthropic-cmek-client-us` 並選取它。按一下 **Select**，然後按一下 **Next**。
      </Step>

      <Step title="檢閱並指派">
        在 **Review + assign** 索引標籤上，按一下 **Review + assign**。
      </Step>
    </Steps>
  </Tab>

  <Tab title="Azure CLI">
    <Steps>
      <Step title="建立 Anthropic 的服務主體">
        ```bash
        az ad sp create --id 8635ae1a-3e5d-44e8-a4ed-e0f614466f87
        ```

        從輸出中複製 `id` 欄位。

        如果命令以「already exists」錯誤結束，請改用以下命令取得 `id`：

        ```bash
        az ad sp show --id 8635ae1a-3e5d-44e8-a4ed-e0f614466f87 --query id -o tsv
        ```
      </Step>

      <Step title="在您的保存庫中建立 RSA 金鑰">
        ```bash
        az keyvault key create \
          --vault-name <your-vault-name> \
          --name <your-key-name> \
          --kty RSA --size 3072 \
          --ops wrapKey unwrapKey \
          --tags anthropic-org-<ORGANIZATION_UUID>=true
        ```

        取代預留位置：

        * **`<your-vault-name>`:** 您的金鑰保存庫名稱
        * **`<your-key-name>`:** 金鑰的名稱
        * **`<ORGANIZATION_UUID>`:** 您的 Anthropic 組織 ID，以小寫表示

        若要使用 HSM 支援的金鑰，請使用 `--kty RSA-HSM`。
      </Step>

      <Step title="授予 Anthropic 服務主體對您金鑰的存取權">
        ```bash
        VAULT_ID=$(az keyvault show --name <your-vault-name> --query id -o tsv)

        az role assignment create \
          --role "Key Vault Crypto User" \
          --assignee-object-id <sp-object-id> \
          --assignee-principal-type ServicePrincipal \
          --scope "${VAULT_ID}/keys/<your-key-name>"
        ```

        取代預留位置：

        * **`<your-vault-name>`:** 您的金鑰保存庫名稱
        * **`<sp-object-id>`:** 第一個步驟中的 `id` 值
        * **`<your-key-name>`:** 金鑰的名稱
      </Step>
    </Steps>
  </Tab>
</Tabs>

在 Claude 中新增金鑰的人員需要保存庫 URI、金鑰名稱和租用戶 ID。

### 為您現有的金鑰新增組織標籤

若沒有組織標籤，驗證將會失敗。金鑰必須是 RSA，且為 3072 位元或更大。

請在 Azure CLI 或 Cloud Shell 中執行以下命令，而不是建立金鑰。此命令會將金鑰限制為 `wrapKey` 和 `unwrapKey`。它也會取代目前版本的標籤，因此請在 `--tags` 中以 `name=value` 的格式列出您想保留的任何標籤。

```bash
az keyvault key set-attributes \
  --vault-name <your-vault-name> \
  --name <your-key-name> \
  --ops wrapKey unwrapKey \
  --tags anthropic-org-<ORGANIZATION_UUID>=true
```

您仍需要完成服務主體和角色指派的步驟。

## 在 Claude 中：新增並附加金鑰

若要在 Claude Platform 上以指令碼執行此部分，請改為[使用 Admin API](https://platform.claude.com/docs/zh-TW/manage-claude/cmek-admin-api)。

<Tabs>
  <Tab title="Claude Platform">
    <Steps>
      <Step title="開啟加密金鑰設定">
        在 Claude Console 中，開啟 Data retention 頁面上的 [Encryption keys](https://platform.claude.com/settings/privacy#encryption-keys)。如果該區段不存在，請從頂端的下拉選單中選取 **Organization**。
      </Step>

      <Step title="新增金鑰">
        在 **Encryption keys** 下，按一下 **Add key**。輸入 **Display name**，選取 **Azure Key Vault**，然後按一下 **Continue**。
      </Step>

      <Step title="輸入金鑰詳細資料">
        確認您的金鑰具有對話方塊中顯示的 **Organization tag**。輸入 **Vault URI**、**Key name** 和 **Tenant ID**，將 **Client ID** 留空，然後按一下 **Add**。
      </Step>

      <Step title="驗證金鑰">
        在 **Encryption keys** 清單中，按一下金鑰旁的 **Verify**。檢查通過時會顯示 **Connected**。如果改為顯示 **Connection failed**，請參閱[疑難排解 CMEK](https://platform.claude.com/docs/zh-TW/manage-claude/cmek-troubleshooting)。
      </Step>

      <Step title="將金鑰附加至工作區">
        <Warning>
          附加金鑰[無法復原](https://platform.claude.com/docs/zh-TW/manage-claude/cmek-key-lifecycle#what-each-action-does)。您無法將其從工作區中移除，也無法替換它。如果該金鑰被刪除，Anthropic 將無法救回受其保護的資料。
        </Warning>

        1. 在 Data retention 頁面頂端，從下拉式選單中選取工作區。
        2. 在 **Encryption key** 下，選取金鑰並按一下 **Save**。
        3. 勾選核取方塊，確認您已閱讀 CMEK 文件，然後按一下 **Confirm**。

        您會看到 **Workspace settings updated.** 您的金鑰[生效](https://platform.claude.com/docs/zh-TW/manage-claude/cmek-how-it-works#when-your-key-takes-effect)後，您的雲端供應商的稽核日誌會顯示 Anthropic 對您的金鑰的呼叫。

        在 [ZDR 組織](https://platform.claude.com/docs/zh-TW/manage-claude/cmek-data-retention#zdr-organizations)中，選取工作區後，請選取 **Standard data retention**，**Encryption key** 才會出現。按一下 **Save** 後，請在資料保留條款上按一下 **Accept**。
      </Step>
    </Steps>
  </Tab>

  <Tab title="Claude Enterprise">
    在 Claude Enterprise 上，CMEK 適用於整個組織，且您只能新增單一金鑰。

    <Warning>
      新增金鑰[無法復原](https://platform.claude.com/docs/zh-TW/manage-claude/cmek-key-lifecycle#what-each-action-does)。您無法將該金鑰從組織中移除，也無法替換它。如果該金鑰遭到刪除，Anthropic 將無法救回該金鑰所保護的資料。
    </Warning>

    新增金鑰會為每位使用者[關閉或變更部分功能](https://platform.claude.com/docs/zh-TW/manage-claude/cmek-coverage-claude-enterprise#turned-off-or-changed)。若要先試用 CMEK，請使用另一個獨立的組織。

    <Steps>
      <Step title="開啟加密金鑰設定">
        前往 [claude.ai > Organization settings > Data and privacy](https://claude.ai/admin-settings/data-privacy-controls) 並找到 **Encryption keys**。
      </Step>

      <Step title="新增金鑰">
        按一下 **Add key**。輸入 **Display name** 並選取 **Azure Key Vault**。選取核取方塊以確認您已閱讀 CMEK 文件，然後按一下 **Continue**。
      </Step>

      <Step title="輸入金鑰詳細資料">
        確認您的金鑰具有對話方塊中顯示的 **Organization tag**。輸入 **Vault URI**、**Key name** 和 **Tenant ID**，將 **Client ID** 留空，然後按一下 **Add**。
      </Step>

      <Step title="確認金鑰已新增">
        檢查最多可能需要 30 秒。當出現 **Encryption key configured.** 時，請按一下 **Done**。如果改為出現 **The encryption key couldn’t be added.**，請[找出原因並重試](https://platform.claude.com/docs/zh-TW/manage-claude/cmek-troubleshooting#claude-ai-add-fails)。

        從那時起寫入的資料都會受到您的金鑰保護。請告知您的使用者[哪些功能已變更](https://platform.claude.com/docs/zh-TW/manage-claude/cmek-coverage-claude-enterprise#turned-off-or-changed)。
      </Step>
    </Steps>
  </Tab>
</Tabs>
