移除 Azure Synapse Analytics 中的透明資料加密保護器

Tip

Microsoft Fabric Data Warehouse 是一個企業規模的關聯式倉庫,建立在資料湖基礎上,具備未來準備架構、內建 AI 及新功能。 如果你是資料倉儲新手,建議先從Fabric Data Warehouse開始。 現有的 專用 SQL 工作負載可升級至 Fabric,以取得資料科學、即時分析與報告等多項新功能。

僅適用於:Azure Synapse Analytics 專用 SQL 集區 (原為 SQL DW)

當客戶管理的 TDE 保護器可能已遭危害時,請使用此程序。 在刪除或停用舊金鑰前,先切換到新的保護器,這樣專用的 SQL 池才能繼續被存取。

Caution

刪除或停用一個使用中的 TDE 保護器會讓所有依賴它的專用 SQL 池無法存取。 在移除金鑰前,請先檢視事件應變計畫及備份保留要求。

註

本文介紹獨立專用 SQL 池(前稱 SQL DW)。 關於 Synapse 工作空間中的專用 SQL 池,請參見 Azure Synapse Analytics 工作空間的加密。

刪除金鑰不會使先前備份或還原到另一個金鑰庫的該金鑰副本失效。 在事件應變中保護並清點每一份副本。

Prerequisites

檢查 TDE 保護器的憑證指紋

以下步驟說明如何檢查特定資料庫中虛擬日誌檔案(VLF)仍在使用的 TDE 保護器指紋。

執行以下查詢以找到目前資料庫 TDE 保護器的指紋及資料庫 ID:

SELECT [database_id],
       [encryption_state],
       [encryptor_type], /*asymmetric key means Azure Key Vault, certificate means service-managed keys*/
       [encryptor_thumbprint]
 FROM [sys].[dm_database_encryption_keys]

執行以下查詢以回傳正在使用的 VLF 和 TDE 保護器指紋。 每個不同的拇指印指的是 Azure Key Vault 中不同的金鑰:

SELECT * FROM sys.dm_db_log_info (database_id)

或者,你也可以使用 PowerShell 或 Azure CLI:

  • PowerShell 指令Get-AzSqlServerKeyVaultKey提供查詢中使用的 TDE 保護器的指紋,讓你能在 Azure Key Vault 中看到哪些金鑰要保留、哪些要刪除。 只有資料庫不再使用的金鑰才能安全地從 Azure Key Vault 刪除。

  • Azure CLI 指令az sql server key show提供查詢中使用的 TDE 保護器的拇指紋,讓你能在 Azure Key Vault 中看到哪些金鑰要保留、哪些要刪除。 只有資料庫不再使用的金鑰才能安全地從 Azure Key Vault 刪除。

保持加密資源可存取

PowerShell

  1. 在 Azure Key Vault 中建立新的金鑰。 確保你在與可能被入侵的 TDE 保護器分開的金鑰庫建立新金鑰,因為存取控制是在金庫層級配置的。

  2. 透過使用 Add-AzSqlServerKeyVaultKey 和 Set-AzSqlServerTransparentDataEncryptionProtector Cmdlet 將新金鑰新增至伺服器,並將其更新為伺服器的新 TDE 保護器。

    # add the key from Azure Key Vault to the server  
    Add-AzSqlServerKeyVaultKey -ResourceGroupName <SQLDatabaseResourceGroupName> -ServerName <LogicalServerName> -KeyId <KeyVaultKeyId>
    
    # set the key as the TDE protector for all resources under the server
    Set-AzSqlServerTransparentDataEncryptionProtector -ResourceGroupName <SQLDatabaseResourceGroupName> `
        -ServerName <LogicalServerName> -Type AzureKeyVault -KeyId <KeyVaultKeyId>
    
  3. 請使用 Get-AzSqlServerTransparentDataEncryptionProtector Cmdlet,確保伺服器及所有副本更新到新的 TDE 保護器。

    註

    新的 TDE 保護裝置可能需要幾分鐘的時間,才能傳播到伺服器下的所有資料庫和次要資料庫。

    Get-AzSqlServerTransparentDataEncryptionProtector -ServerName <LogicalServerName> -ResourceGroupName <SQLDatabaseResourceGroupName>
    
  4. 在 Azure Key Vault 中 備份新的金鑰 。

    # -OutputFile parameter is optional; if removed, a file name is automatically generated.
    Backup-AzKeyVaultKey -VaultName <KeyVaultName> -Name <KeyVaultKeyName> -OutputFile <DesiredBackupFilePath>
    
  5. 使用 Remove-AzKeyVaultKey cmdlet 從 Azure Key Vault 刪除被入侵的密鑰。

    Remove-AzKeyVaultKey -VaultName <KeyVaultName> -Name <KeyVaultKeyName>
    
  6. 若要在未來將密鑰還原至 Azure Key Vault,請使用 Restore-AzKeyVaultKey Cmdlet。

    Restore-AzKeyVaultKey -VaultName <KeyVaultName> -InputFile <BackupFilePath>
    

Azure CLI

關於指令參考,請參見 Azure CLI keyvault。

  1. 在 Azure Key Vault 中建立新的金鑰。 確保你在與可能被入侵的 TDE 保護器分開的金鑰庫建立新金鑰,因為存取控制是在金庫層級配置的。

  2. 將新的金鑰新增至伺服器,並將其更新為伺服器的新 TDE 保護裝置。

    # add the key from Azure Key Vault to the server  
    az sql server key create --kid <KeyVaultKeyId> --resource-group <SQLDatabaseResourceGroupName> --server <LogicalServerName>
    
    # set the key as the TDE protector for all resources under the server
    az sql server tde-key set --server-key-type AzureKeyVault --kid <KeyVaultKeyId> --resource-group <SQLDatabaseResourceGroupName> --server <LogicalServerName>
    
  3. 確保伺服器和所有副本更新到新的 TDE 保護器。

    註

    新的 TDE 保護裝置可能需要幾分鐘的時間,才能傳播到伺服器下的所有資料庫和次要資料庫。

    az sql server tde-key show --resource-group <SQLDatabaseResourceGroupName> --server <LogicalServerName>
    
  4. 在 Azure Key Vault 中備份新的金鑰。

    # --file parameter is optional; if removed, a file name is automatically generated.
    az keyvault key backup --file <DesiredBackupFilePath> --name <KeyVaultKeyName> --vault-name <KeyVaultName>
    
  5. 從 Azure Key Vault 刪除遭入侵的金鑰。

    az keyvault key delete --name <KeyVaultKeyName> --vault-name <KeyVaultName>
    
  6. 日後將金鑰還原至 Azure Key Vault。

    az keyvault key restore --file <BackupFilePath> --vault-name <KeyVaultName>
    

保持加密資源無法存取

  1. 刪除使用可能已外洩的金鑰進行加密的資料庫。

    系統會自動備份資料庫和日誌檔案,因此只要提供金鑰,你就能在任何時候進行資料庫的時間點還原。 在刪除作用中的 TDE 保護器之前,請先卸除資料庫,以避免最近 10 分鐘內交易資料可能遺失。

  2. 備份 Azure Key Vault 中 TDE 保護裝置的密鑰數據。

  3. 從 Azure Key Vault 移除可能遭入侵的密鑰。

註

任何權限變更對金鑰保險庫生效,可能要等大約 10 分鐘。 這次包括撤銷 AKV 中對 TDE 保護器的存取權限,且使用者可能仍具有存取權限。