分享方式:


針對 FHIR 服務設定客戶自控金鑰

藉由使用客戶自控金鑰 (CMK),您可以透過您建立和管理的金鑰來保護和控制貴組織資料的存取權。 您可以使用 Azure Key Vault 來建立和管理 CMK,然後使用金鑰來加密 FHIR® 服務所儲存的資料。

客戶自控金鑰可讓您:

  • 建立您自己的加密金鑰,然後將其儲存在金鑰保存庫中,或是使用 Azure Key Vault API 來產生金鑰。

  • 維護金鑰生命週期的完全控制權和責任,包括金鑰輪替。

必要條件

  • 請確定您熟悉客戶自控金鑰的最佳做法

  • 確認您已獲指派 Azure 參與者 RBAC 角色,這可讓您建立和修改 Azure 資源。

  • 在 Azure Key Vault 中新增 FHIR 服務的金鑰。 如需步驟,請參閱在 Azure Key Vault 中新增金鑰。 客戶自控金鑰必須符合下列需求:

    • 金鑰已設定版本。

    • 金鑰類型為 RSA

    • 金鑰為 2048 位元3072 位元

    • 金鑰保存庫位於與所建立資源相同的區域,但可以位於不同的 Azure 訂用帳戶或租用戶中。

    • 金鑰保存庫名稱和金鑰名稱的合併長度不可超過 94 個字元

    • 使用具有防火牆的金鑰保存庫來停用公用存取時,必須啟用 [允許受信任的 Microsoft 服務略過此防火牆] 選項。

    • 若要防止遺失 FHIR 服務的加密金鑰,金鑰保存庫或受控 HSM 必須已啟用虛刪除清除保護。 這些功能可讓您復原已刪除一段時間的金鑰 (預設為 90 天),並封鎖永久刪除,直到該時間結束為止。

注意

FHIR 服務支援附加一種身分識別類型 (系統指派或使用者指派的身分識別)。 如果身分識別類型已經對應,變更身分識別類型可能會影響背景作業,例如匯出和匯入。

使用加密金鑰更新 FHIR 服務

新增金鑰之後,您必須使用金鑰 URL 更新 FHIR 服務。

  1. 在金鑰保存庫中,選取 [金鑰]

  2. 選取 FHIR 服務的金鑰。

Screenshot of the Keys page and the key to use with the FHIR service.

  1. 選取金鑰版本。

  2. 複製金鑰識別碼。 當您使用 ARM 範本更新金鑰時,您需要金鑰 URL。

Screenshot showing the key version details and the copy action for the Key Identifier.

您可以使用 Azure 入口網站或 ARM 範本來更新 FHIR 服務的金鑰。 在更新期間,您可以選擇使用系統指派或使用者指派的受控識別。 針對系統指派的受控識別,請務必指派 Key Vault 密碼編譯服務加密使用者角色。 如需詳細資訊,請參閱使用 Azure 入口網站指派 Azure 角色

使用 Azure 入口網站更新金鑰

  1. 在 Azure 入口網站中,移至 FHIR 服務,然後從左側窗格中選取 [加密]

  2. 針對 [加密類型] 選取 [客戶自控金鑰]

  3. 選取金鑰保存庫和金鑰,或輸入先前所建立金鑰的金鑰 URI。

  4. 選取與先前所設定受控識別類型相符的系統指派或使用者指派身分識別類型。

  5. 選取 [儲存] 以更新 FHIR 服務為使用客戶自控金鑰。

Screenshot of the Encryption view, showing the selection of the Customer-managed key option, key vault settings, identity type settings, and Save button.

藉由使用 ARM 範本來更新金鑰

使用 Azure 入口網站來部署自訂範本,並使用其中一個 ARM 範本來更新金鑰。 如需詳細資訊,請參閱使用 Azure 入口網站建立及部署 ARM 範本

系統指派的受控識別的 ARM 範本

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "workspaceName": {
            "type": "String"
        },
        "fhirServiceName": {
            "type": "String"
        },
        "keyEncryptionKeyUrl": {
            "type": "String"
        },
        "region": {
            "defaultValue": "West US 3",
            "type": "String"
        }
    },
    "resources": [
        {
            "type": "Microsoft.HealthcareApis/workspaces/fhirservices",
            "apiVersion": "2023-06-01-preview",
            "name": "[concat(parameters('workspaceName'), '/', parameters('fhirServiceName'))]",
            "location": "[parameters('region')]",
            "identity": {
                "type": "SystemAssigned"
            },
            "properties": {
                "encryption": {
                    "customerManagedKeyEncryption": {
                        "keyEncryptionKeyUrl": "[parameters('keyEncryptionKeyUrl')]"
                    }
                }
            }
        }
    ]
}

使用者指派的受控識別的 ARM 範本

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "workspaceName": {
            "type": "String"
        },
        "fhirServiceName": {
            "type": "String"
        },
        "keyVaultName": {
            "type": "String"
        },
        "keyName": {
            "type": "String"
        },
        "userAssignedIdentityName": {
            "type": "String"
        },
        "roleAssignmentName": {
            "type": "String"
        },
        "region": {
            "defaultValue": "West US 3",
            "type": "String"
        },
        "tenantId": {
            "type": "String"
        }
    },
    "resources": [
        {
            "type": "Microsoft.KeyVault/vaults",
            "apiVersion": "2022-07-01",
            "name": "[parameters('keyVaultName')]",
            "location": "[parameters('region')]",
            "properties": {
              "accessPolicies": [],
              "enablePurgeProtection": true,
              "enableRbacAuthorization": true,
              "enableSoftDelete": true,
              "sku": {
                "family": "A",
                "name": "standard"
              },
              "tenantId": "[parameters('tenantId')]"
            }
        },
        {
            "type": "Microsoft.ManagedIdentity/userAssignedIdentities",
            "apiVersion": "2023-01-31",
            "name": "[parameters('userAssignedIdentityName')]",
            "location": "[parameters('region')]"
        },
        {
            "type": "Microsoft.KeyVault/vaults/keys",
            "apiVersion": "2022-07-01",
            "name": "[concat(parameters('keyVaultName'), '/', parameters('keyName'))]",
            "properties": {
              "attributes": {
                "enabled": true
              },
              "curveName": "P-256",
              "keyOps": [ "unwrapKey","wrapKey" ],
              "keySize": 2048,
              "kty": "RSA"
            },
            "dependsOn": [
                "[resourceId('Microsoft.KeyVault/vaults/', parameters('keyVaultName'))]"
            ]
        },
        {
            "type": "Microsoft.Authorization/roleAssignments",
            "apiVersion": "2021-04-01-preview",
            "name": "[guid(parameters('roleAssignmentName'))]",
            "properties": {
              "roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', '14b46e9e-c2b7-41b4-b07b-48a6ebf60603')]",
              "principalId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('userAssignedIdentityName'))).principalId]"
            },
            "dependsOn": [
                "[resourceId('Microsoft.KeyVault/vaults/keys', parameters('keyVaultName'), parameters('keyName'))]",
                "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('userAssignedIdentityName'))]"
            ]
        },
        {
            "type": "Microsoft.HealthcareApis/workspaces",
            "name": "[parameters('workspaceName')]",
            "apiVersion": "2022-05-15",
            "location": "[parameters('region')]"
        },
        {
            "type": "Microsoft.HealthcareApis/workspaces/fhirservices",
            "apiVersion": "2023-06-01-preview",
            "name": "[concat(parameters('workspaceName'), '/', parameters('fhirServiceName'))]",
            "location": "[parameters('region')]",
            "dependsOn": [
                "[resourceId('Microsoft.HealthcareApis/workspaces', parameters('workspaceName'))]",
                "[resourceId('Microsoft.Authorization/roleAssignments', guid(parameters('roleAssignmentName')))]"
            ],
            "identity": {
                "type": "userAssigned",
                "userAssignedIdentities": {
                    "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities/', parameters('userAssignedIdentityName'))]": {}
                }
            },
            "properties": {
                "encryption": {
                    "customerManagedKeyEncryption": {
                        "keyEncryptionKeyUrl": "[reference(resourceId('Microsoft.KeyVault/vaults/keys', parameters('keyVaultName'), parameters('keyName'))).keyUriWithVersion]"
                    }
                }
            }
        }
    ]
}
  1. 出現提示時,請選取資源群組、區域、工作區和 FHIR 服務名稱的值。

    • 如果您使用系統指派的受控識別,請輸入從金鑰保存庫的 [金鑰加密金鑰 URL] 欄位中複製的金鑰識別碼
    • 如果您使用使用者指派的受控識別,請輸入金鑰保存庫名稱、金鑰名稱、使用者指派的身分識別名稱和租用戶識別碼的值。
  2. 選取 [檢閱 + 建立] 來部署金鑰的更新。

Screenshot of the deployment template with details, including Key Encryption Key URL filled in.

建立 FHIR 服務時設定金鑰

如果您搭配 FHIR 服務使用使用者指派的受控識別,您可以在建立 FHIR 服務的同時設定客戶自控金鑰。

  1. 在 [建立 FHIR 服務] 頁面上,輸入 FHIR 服務名稱

  2. 選擇 [下一步:安全性]

Screenshot of the Create FHIR service view with the FHIR service name filled in.

  1. 在 [安全性] 索引標籤的 [加密] 區段中,選取 [客戶自控金鑰]

  2. 選擇 [從金鑰保存庫選取],或 [輸入金鑰 URI],然後輸入金鑰。

  3. 選擇 [選取身分識別] 以使用使用者指派的受控識別。 在選取使用者指派的受控識別頁面上,篩選然後選取受控識別。 選擇新增

  4. 在 [安全性] 索引標籤上,選擇 [檢閱 + 建立]

Screenshot of the Security tab with the Customer-managed key option selected.

  1. 在 [檢閱 + 建立] 索引標籤上,檢閱組態選項的摘要和驗證成功訊息。 選擇 [建立],以使用客戶自控金鑰來部署 FHIR 服務。

Screenshot of the Review + create tab with the selected options and validation success message shown.

從遺失的金鑰存取中復原

若要讓 FHIR 服務正常運作,必須一律能夠存取金鑰保存庫中的金鑰。 不過在某些情況下,服務可能會失去金鑰的存取權,包括:

  • 金鑰已停用或已從金鑰保存庫刪除。

  • FHIR 服務系統指派的受控識別已停用。

  • FHIR 服務系統指派的受控識別失去金鑰保存庫的存取權。

在 FHIR 服務無法存取金鑰的任何案例中,API 要求會傳回 500 錯誤,且資料在還原金鑰之前無法存取。

如果遺失金鑰存取權,請確定您已更新金鑰和必要資源,讓 FHIR 服務能夠存取。

解決常見錯誤

導致資料庫無法存取的常見錯誤通常是因為設定問題造成。 如需詳細資訊,請參閱客戶自控金鑰的常見錯誤

注意

FHIR® 是 HL7 的註冊商標,可與 HL7 的權限搭配使用。