適用於:
Azure SQL Database
注意
資料庫層級 TDE CMK 適用於 Azure SQL 資料庫 (所有 SQL Database 版本)。 不適用於 Azure SQL 受控執行個體、SQL Server 內部部署、Azure VM 和 Azure Synapse Analytics (專用 SQL 集區 (先前稱為 SQL DW))。
在本指南中,我們將逐步解說在 Azure SQL Database上設定異地複寫和備份還原的步驟。 Azure SQL 資料庫是使用資料庫層級的透明資料加密 (TDE) 和客戶自控金鑰 (CMK) 進行設定,利用使用者指派的受控識別來存取 Azure Key Vault。 根據本指南,Azure Key Vault 和適用於 Azure SQL 的邏輯伺服器都位於相同的 Microsoft Entra 租用戶中,不過其也可以分屬不同的租用戶。
必要條件
重要
建立或還原資料庫之後,Azure 入口網站中的 [透明資料加密] 功能表會顯示與來源資料庫相同的設定的新資料庫,但也有可能遺失金鑰。 在從來源資料庫建立新資料庫的所有情況下,Azure 入口網站 [其他資料庫金鑰] 清單中針對目標資料庫顯示的金鑰數目可能小於來源資料庫所顯示的金鑰數目。 這是因為顯示的金鑰數目取決於用來建立目標資料庫的個別功能需求。 若要列出適用於新建立資料庫的所有金鑰,請使用在 Azure SQL 資料庫上檢視資料庫層級客戶自控金鑰設定中的可用 API。
建立具有資料庫層級客戶自控金鑰作為次要或複本的 Azure SQL Database
使用下列指令或命令,建立以資料庫層級客戶自控金鑰設定的 Azure SQL 資料庫的次要複本或複本目標。 需要使用者指派的自控識別,於資料庫建立階段針對透明資料加密設定客戶自控金鑰。
建立具有資料庫層級客戶自控金鑰的資料庫複本
若要在 Azure SQL 資料庫中建立資料庫作為具有資料庫層級客戶自控金鑰的複本,請遵循下列步驟:
前往 Azure 入口網站,然後瀏覽至使用資料庫層級客戶自控金鑰設定的 Azure SQL 資料庫。 存取 [資料加密] 功能表的 [透明資料加密] 索引標籤,並檢查資料庫目前使用的金鑰清單。
從資料庫的 [概觀] 功能表選取 [複製],以建立資料庫的複本。
隨即顯示 [建立 SQL 資料庫 - 複製資料庫] 功能表。 針對此資料庫使用不同的伺服器,但設定與您嘗試複製的資料庫設定相同。 在 [透明資料加密金鑰管理] 區段中,選取 [設定透明資料加密]。
當顯示 [透明資料加密] 功能表時,請檢閱此複本資料庫的 CMK 設定。 設定和金鑰應該填入來源資料庫中使用的相同身分識別和金鑰。
選取 [套用] 繼續,然後選取 [檢閱 + 建立],並選取 [建立] 以建立複製資料庫。
建立具有資料庫層級客戶自控金鑰的次要複本
前往 Azure 入口網站,然後瀏覽至使用資料庫層級客戶自控金鑰設定的 Azure SQL 資料庫。 存取 [透明資料加密] 功能表,並檢查資料庫目前使用的金鑰清單。
在資料庫的 [資料管理] 設定下,選取 [複本]。 選取 [建立複本] 以建立資料庫的次要複本。
隨即顯示 [建立 SQL Database - 異地複本] 功能表。 針對此資料庫使用次要伺服器,但設定與您嘗試複寫的資料庫設定相同。 在 [透明資料加密金鑰管理] 區段中,選取 [設定透明資料加密]。
當顯示 [透明資料加密] 功能表時,請檢閱此資料庫複本的 CMK 設定。 設定和金鑰應該填入主要資料庫中使用的相同身分識別和金鑰。
選取 [套用] 繼續,然後選取 [檢閱 + 建立],並選取 [建立] 以建立複製資料庫。
如需如何安裝目前版本的 Azure CLI,請參閱安裝 Azure CLI 一文。
使用 expand-keys
參數和 current
,將主要資料庫所使用的目前金鑰清單預先填入為 keys-filter
。
az sql db show --name $databaseName --resource-group $resourceGroup --server $serverName --expand-keys --keys-filter current
請選取使用者指派的受控識別 (如果設定跨租用戶存取,也請設定同盟用戶端識別碼)。
建立新的資料庫作為次要資料庫,提供從來源資料庫以及上述身分識別取得的金鑰預先填入清單 (如果設定跨租用戶存取,也請設定同盟用戶端識別碼)。
# Create a secondary replica with Active Geo Replication with the same name as the primary database
az sql db replica create -g $resourceGroup -s $serverName -n $databaseName --partner-server $secondaryServer --partner-database $secondaryDatabase --partner-resource-group $secondaryResourceGroup -i --encryption-protector $encryptionProtector --user-assigned-identity-id $umi --keys $keys
重要
$keys 是從來源資料庫擷取的金鑰空格分隔清單。
若要建立資料庫的複本,az sql db 複本可以搭配相同的參數使用。
# Create a copy of a database configured with database level customer-managed keys
az sql db copy -g $resourceGroup -s $serverName -n $databaseName --dest-name $secondaryDatabase -i --encryption-protector $encryptionProtector --user-assigned-identity-id $umi --keys $keys
如需 Az PowerShell 模組安裝指示,請參閱安裝 Azure PowerShell。
使用 Get-AzSqlDatabase 命令和 -ExpandKeyList
和 -KeysFilter "current"
參數,預先填入主要資料庫所使用的目前金鑰清單。 如果您想要擷取所有金鑰,請排除 -KeysFilter
。
$database = Get-AzSqlDatabase -ResourceGroupName <ResourceGroupName> -ServerName <ServerName> -DatabaseName <DatabaseName> -ExpandKeyList -KeysFilter "current"
請選取使用者指派的受控識別 (如果設定跨租用戶存取,也請設定同盟用戶端識別碼)。
使用 New-AzSqlDatabaseSecondary 命令建立新的資料庫作為次要複本,並提供從來源資料庫取得的金鑰預先填入清單,以及上述身分識別 (如果設定跨租用戶存取,也請設定同盟用戶端識別碼),在 API 呼叫使用 -KeyList
、-AssignIdentity
、-UserAssignedIdentityId
、-EncryptionProtector
(如有需要則 -FederatedClientId
) 參數。
# Create a secondary replica with Active Geo Replication with the same name as the primary database
$database = Get-AzSqlDatabase -ResourceGroupName <ResourceGroupName> -ServerName <ServerName> -DatabaseName <DatabaseName> -ExpandKeyList -KeysFilter "current"
$database | New-AzSqlDatabaseSecondary -PartnerResourceGroupName <SecondaryResourceGroupName> -PartnerServerName <SecondaryServerName> -AllowConnections "All" -AssignIdentity -UserAssignedIdentityId <UserAssignedIdentityId> -EncryptionProtector <CustomerManagedKeyId> -FederatedClientId <FederatedClientId>
-KeyList $database.Keys.Keys
若要建立資料庫的複本,New-AzSqlDatabaseCopy 複本可以搭配相同的參數使用。
# Create a copy of a database configured with database level customer-managed keys
$database = Get-AzSqlDatabase -ResourceGroupName <ResourceGroupName> -ServerName <ServerName> -DatabaseName <DatabaseName> -ExpandKeyList -KeysFilter "current"
New-AzSqlDatabaseCopy -CopyDatabaseName <CopyDatabaseName> -CopyResourceGroupName <CopyResourceGroupName> -CopyServerName <CopyServerName> -DatabaseName <DatabaseName> -ResourceGroupName <ResourceGroupName> -ServerName <ServerName> -AssignIdentity -UserAssignedIdentityId <UserAssignedIdentityId> -EncryptionProtector <CustomerManagedKeyId> -FederatedClientId <FederatedClientId>
-KeyList $database.Keys.Keys
以下是 ARM 範本的範例,其會建立次要複本和 Azure SQL Database 複本,包含資料庫層級中設定使用者指派的受控識別和客戶自控的 TDE。
如需詳細資訊和 ARM 範本,請參閱適用於 Azure SQL 資料庫和 SQL 受控執行個體的 Azure Resource Manager 範本。
使用 Azure 入口網站中的自訂部署,然後在編輯器中建置您自己的範本。 接下來,將設定貼進範例之後,加以儲存。
使用下列 REST API 要求預先填入主要資料庫所使用的目前金鑰清單:
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}?api-version=2022-08-01-preview&$expand=keys($filter=pointInTime('current'))
請選取使用者指派的受控識別 (如果設定跨租用戶存取,也請設定同盟用戶端識別碼)。
在 ARM 範本中,建立新的資料庫作為次要資料庫,提供從來源資料庫以及上述身分識別取得的金鑰預先填入清單 (如果設定跨租用戶存取,也請設定同盟用戶端識別碼) 作為 keys_to_add
參數。
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"server_name": {
"type": "String"
},
"database_name": {
"type": "String"
},
"user_assigned_identity": {
"type": "String"
},
"encryption_protector": {
"type": "String"
},
"location": {
"type": "String"
},
"source_database_id": {
"type": "String"
},
"keys_to_add": {
"type": "Object"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Sql/servers/databases",
"apiVersion": "2022-08-01-preview",
"name": "[concat(parameters('server_name'), concat('/',parameters('database_name')))]",
"location": "[parameters('location')]",
"sku": {
"name": "Basic",
"tier": "Basic",
"capacity": 5
},
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"[parameters('user_assigned_identity')]": {}
}
},
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"maxSizeBytes": 104857600,
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"zoneRedundant": false,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"maintenanceConfigurationId": "/subscriptions/e1775f9f-xxxx-xxxx-xxxx-xxxxxxxxxxxx/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_Default",
"isLedgerOn": false,
"encryptionProtector": "[parameters('encryption_protector')]",
"keys": "[parameters('keys_to_add')]",
"createMode": "Secondary",
"sourceDatabaseId": "[parameters('source_database_id')]"
}
}
]
}
encryption_protector
和 keys_to_add
參數的範例如下:
"keys_to_add": {
"value": {
"https://yourvault.vault.azure.net/keys/yourkey1/fd021f84a0d94d43b8ef33154bca0000": {},
"https://yourvault.vault.azure.net/keys/yourkey2/fd021f84a0d94d43b8ef33154bca0000": {}
}
},
"encryption_protector": {
"value": "https://yourvault.vault.azure.net/keys/yourkey2/fd021f84a0d94d43b8ef33154bca0000"
}
若要建立資料庫的複本,下列範本可以搭配相同的參數使用。
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"server_name": {
"type": "String"
},
"database_name": {
"type": "String"
},
"user_assigned_identity": {
"type": "String"
},
"encryption_protector": {
"type": "String"
},
"location": {
"type": "String"
},
"source_database_id": {
"type": "String"
},
"keys_to_add": {
"type": "Object"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Sql/servers/databases",
"apiVersion": "2022-08-01-preview",
"name": "[concat(parameters('server_name'), concat('/',parameters('database_name')))]",
"location": "[parameters('location')]",
"sku": {
"name": "Basic",
"tier": "Basic",
"capacity": 5
},
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"[parameters('user_assigned_identity')]": {}
}
},
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"maxSizeBytes": 104857600,
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"zoneRedundant": false,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"maintenanceConfigurationId": "/subscriptions/e1775f9f-xxxx-xxxx-xxxx-xxxxxxxxxxxx/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_Default",
"isLedgerOn": false,
"encryptionProtector": "[parameters('encryption_protector')]",
"keys": "[parameters('keys_to_add')]",
"createMode": "Copy",
"sourceDatabaseId": "[parameters('source_database_id')]"
}
}
]
}
使用資料庫層級客戶自控金鑰還原新的 Azure SQL Database
本節將逐步引導您還原以資料庫層級客戶自控金鑰所設定的 Azure SQL Database。 需要使用者指派的自控識別,於資料庫建立階段針對透明資料加密設定客戶自控金鑰。
還原時間點
下一節說明如何將資料庫層級客戶自控金鑰所設定的資料庫還原至指定的時間點。 若要深入了解 SQL Database 的備份復原,請參閱復原 SQL Database 中的資料庫。
前往 Azure 入口網站,然後瀏覽至使用您要還原的資料庫層級客戶自控金鑰設定的 Azure SQL 資料庫。
若要將資料庫還原至某個時間點,請從資料庫的 [概觀] 功能表中選取 [還原]。
隨即顯示 [建立 SQL 資料庫 - 還原資料庫] 功能表。 填入所需的來源和資料庫詳細資料。 在 [透明資料加密金鑰管理] 區段中,選取 [設定透明資料加密]。
當顯示 [透明資料加密] 功能表時,請檢閱資料庫的 CMK 設定。 設定和金鑰應該填入您嘗試還原的資料庫中使用的相同身分識別和金鑰。
選取 [套用] 繼續,然後選取 [檢閱 + 建立],並選取 [建立] 以建立複製資料庫。
如需如何安裝目前版本的 Azure CLI,請參閱安裝 Azure CLI 一文。
使用 expand-keys
參數,將主要資料庫所使用的金鑰清單預先填入作為 keys-filter
的還原點。
az sql db show --name $databaseName --resource-group $resourceGroup --server $serverName --expand-keys --keys-filter $timestamp
請選取使用者指派的受控識別 (如果設定跨租用戶存取,也請設定同盟用戶端識別碼)。
建立新的資料庫作為還原目標,提供從來源資料庫以及上述身分識別取得的金鑰預先填入清單 (如果設定跨租用戶存取,也請設定同盟用戶端識別碼)。
# Create a restored database
az sql db restore --dest-name $destName --name $databaseName --resource-group $resourceGroup --server $serverName --subscription $subscriptionId --time $timestamp -i --encryption-protector $encryptionProtector --user-assigned-identity-id $umi --keys $keys
重要
$keys 是從來源資料庫擷取的金鑰空格分隔清單。
如需 Az PowerShell 模組安裝指示,請參閱安裝 Azure PowerShell。
使用 Get-AzSqlDatabase 命令預先填入主要資料庫所使用的金鑰清單,而 -ExpandKeyList
和 -KeysFilter "2023-01-01"
參數 (2023-01-01
是您想要將資料庫還原至時間點的範例)。 如果您想要擷取所有金鑰,請排除 -KeysFilter
。
$database = Get-AzSqlDatabase -ResourceGroupName <ResourceGroupName> -ServerName <ServerName> -DatabaseName <DatabaseName> -ExpandKeyList -KeysFilter <Timestamp>
請選取使用者指派的受控識別 (如果設定跨租用戶存取,也請設定同盟用戶端識別碼)。
使用 Restore-AzSqlDatabase 命令搭配 -FromPointInTimeBackup
參數,從上述步驟以及上述身分識別取得的金鑰預先填入清單 (如果設定跨租用戶存取,也請設定同盟用戶端識別碼),在 API 呼叫中使用 -KeyList
、-AssignIdentity
、-UserAssignedIdentityId
、-EncryptionProtector
(如有需要則 -FederatedClientId
) 參數。
$database = Get-AzSqlDatabase -ResourceGroupName <ResourceGroupName> -ServerName <ServerName> -DatabaseName <DatabaseName> -ExpandKeyList -KeysFilter <Timestamp>
# Create a restored database
Restore-AzSqlDatabase -FromPointInTimeBackup -PointInTime <Timestamp> -ResourceId '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}' -ResourceGroupName <ResourceGroupName> -ServerName <ServerName> -TargetDatabaseName <TargetDatabaseName> -KeyList $database.Keys.Keys -EncryptionProtector <EncryptionProtector> -UserAssignedIdentityId <UserAssignedIdentityId> -AssignIdentity
已卸除的資料庫還原
下一節說明如何還原已刪除的資料庫,該資料庫已透過資料庫層級的客戶自控金鑰進行設定。 若要深入了解 SQL Database 的備份復原,請參閱復原 SQL Database 中的資料庫。
前往 Azure 入口網站,然後瀏覽至您要還原的已刪除資料庫的邏輯伺服器。 在 [資料管理] 下,選取 [已刪除的資料庫]。
選取您要還原的已刪除資料庫。
隨即顯示 [建立 SQL 資料庫 - 還原資料庫] 功能表。 填入所需的來源和資料庫詳細資料。 在 [透明資料加密金鑰管理] 區段中,選取 [設定透明資料加密]。
當顯示 [透明資料加密] 功能表時,請為您的資料庫設定 [使用者指派的受控識別]、[客戶自控金鑰] 和 [其他資料庫金鑰] 區段。
選取 [套用] 繼續,然後選取 [檢閱 + 建立],並選取 [建立] 以建立複製資料庫。
如需如何安裝目前版本的 Azure CLI,請參閱安裝 Azure CLI 一文。
使用 expand-keys
參數預先填入已卸除資料庫所使用的金鑰清單。 建議您傳遞來源資料庫使用的所有金鑰。 您也可以使用 keys-filter
參數,嘗試使用刪除時提供的金鑰進行還原。
az sql db show-deleted --name $databaseName --resource-group $resourceGroup --server $serverName --restorable-dropped-database-id "databaseName,133201549661600000" --expand-keys
重要
列出伺服器中的所有可還原卸除資料庫來擷取 restorable-dropped-database-id
,格式為 databaseName,deletedTimestamp
。
請選取使用者指派的受控識別 (如果設定跨租用戶存取,也請設定同盟用戶端識別碼)。
建立新的資料庫作為還原目標,提供從已刪除的來源資料庫以及上述身分識別取得的金鑰預先填入清單 (如果設定跨租用戶存取,也請設定同盟用戶端識別碼)。
# Create a restored database
az sql db restore --dest-name $destName --name $databaseName --resource-group $resourceGroup --server $serverName --subscription $subscriptionId --time $timestamp -i --encryption-protector $encryptionProtector --user-assigned-identity-id $umi --keys $keys --deleted-time "2023-02-06T11:02:46.160000+00:00"
重要
$keys
是從來源資料庫擷取的金鑰空格分隔清單。
如需 Az PowerShell 模組安裝指示,請參閱安裝 Azure PowerShell。
使用 Get-AzSqlDeletedDatabaseBackup 和 -ExpandKeyList
參數命令,預先填入主要資料庫所使用的金鑰清單。 建議您傳遞來源資料庫使用的所有金鑰。 您也可以使用 -KeysFilter
參數,嘗試使用刪除時提供的金鑰進行還原。
$database = Get-AzSqlDeletedDatabaseBackup -ResourceGroupName <ResourceGroupName> -ServerName <ServerName> -DatabaseId "dbName,133201549661600000" -ExpandKeyList -DeletionDate "2/6/2023" -DatabaseName <databaseName>
重要
列出伺服器中的所有可還原卸除資料庫來擷取 DatabaseId
,格式為 databaseName,deletedTimestamp
。
請選取使用者指派的受控識別 (如果設定跨租用戶存取,也請設定同盟用戶端識別碼)。
使用 Restore-AzSqlDatabase 命令搭配 -FromDeletedDatabaseBackup
參數,從上述步驟以及上述身分識別取得的金鑰預先填入清單 (如果設定跨租用戶存取,也請設定同盟用戶端識別碼),在 API 呼叫中使用 -KeyList
、-AssignIdentity
、-UserAssignedIdentityId
、-EncryptionProtector
(如有需要則 -FederatedClientId
) 參數。
$database = Get-AzSqlDeletedDatabaseBackup -ResourceGroupName <ResourceGroupName> -ServerName <ServerName> -DatabaseId "dbName,133201549661600000" -ExpandKeyList -DeletionDate <DeletionDate> -DatabaseName <databaseName>
# Create a restored database
Restore-AzSqlDatabase -FromDeletedDatabaseBackup -DeletionDate <Timestamp> -ResourceId '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/restorableDroppedDatabases/{databaseName}' -ResourceGroupName <ResourceGroupName> -ServerName <ServerName> -TargetDatabaseName <TargetDatabaseName> -KeyList $database.Keys.Keys -EncryptionProtector <EncryptionProtector> -UserAssignedIdentityId <UserAssignedIdentityId> -AssignIdentity
異地還原
下一節說明如何還原資料庫的異地複寫備份,該資料庫已透過資料庫層級的客戶自控金鑰進行設定。 若要深入了解 SQL Database 的備份復原,請參閱復原 SQL Database 中的資料庫。
前往 Azure 入口網站,然後瀏覽至您要還原資料庫的邏輯伺服器。
在 [概觀] 功能表中,選取 [建立資料庫]。
隨即顯示 [建立 SQL Database] 功能表。 填入新資料庫的 [基本] 和 [網路] 索引標籤。 在 [其他設定] 中,選取 [使用現有資料] 區段的 [備份],然後選取異地複寫備份。
前往 [安全性] 索引標籤。在 [透明資料加密金鑰管理] 區段中,選取 [設定透明資料加密]。
當顯示 [透明資料加密] 功能表時,選取 [資料庫層級客戶自控金鑰 (CMK)]。 [使用者指派的受控識別]、[客戶自控金鑰] 和 [其他資料庫金鑰] 必須符合您要還原的來源資料庫。 請確定使用者指派的受控識別可以存取金鑰保存庫,其中包含備份中使用的客戶自控金鑰。
選取 [套用] 繼續,然後選取 [檢閱 + 建立],並選取 [建立] 以建立備份資料庫。
如需如何安裝目前版本的 Azure CLI,請參閱安裝 Azure CLI 一文。
使用 expand-keys
參數,預先填入資料庫層級客戶自控金鑰設定資料庫的異地備份所使用的金鑰清單。
az sql db geo-backup --database-name $databaseName --g $resourceGroup --server $serverName --expand-keys
請選取使用者指派的受控識別 (如果設定跨租用戶存取,也請設定同盟用戶端識別碼)。
建立新的資料庫作為異地還原目標,提供從已刪除的來源資料庫以及上述身分識別取得的金鑰預先填入清單 (如果設定跨租用戶存取,也請設定同盟用戶端識別碼)。
# Create a geo restored database
az sql db geo-backup restore --geo-backup-id "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/recoverableDatabases/{databaseName}" --dest-database $destName --resource-group $resourceGroup --dest-server $destServerName -i --encryption-protector $encryptionProtector --user-assigned-identity-id $umi --keys $keys
重要
$keys
是從來源資料庫擷取的金鑰空格分隔清單。
如需 Az PowerShell 模組安裝指示,請參閱安裝 Azure PowerShell。
使用 Get-AzSqlDatabaseGeoBackup 和 -ExpandKeyList
命令,預先填入主要資料庫所使用的金鑰清單。
$database = Get-AzSqlDatabaseGeoBackup -ResourceGroupName <ResourceGroupName> -ServerName <ServerName> -DatabaseName <databaseName> -ExpandKeyList
重要
列出伺服器中的所有可還原卸除資料庫來擷取 DatabaseId
,格式為 databaseName,deletedTimestamp
。
請選取使用者指派的受控識別 (如果設定跨租用戶存取,也請設定同盟用戶端識別碼)。
使用 Restore-AzSqlDatabase 命令搭配 -FromGeoBackup
參數,從上述步驟以及上述身分識別取得的金鑰預先填入清單 (如果設定跨租用戶存取,也請設定同盟用戶端識別碼),在 API 呼叫中使用 -KeyList
、-AssignIdentity
、-UserAssignedIdentityId
、-EncryptionProtector
(如有需要則 -FederatedClientId
) 參數。
$database = Get-AzSqlDatabaseGeoBackup -ResourceGroupName <ResourceGroupName> -ServerName <ServerName> -DatabaseName <databaseName> -ExpandKeyList
# Create a restored database
Restore-AzSqlDatabase -FromGeoBackup -ResourceId "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/recoverableDatabases/{databaseName}" -ResourceGroupName <ResourceGroupName> -ServerName <ServerName> -TargetDatabaseName <TargetDatabaseName> -KeyList $database.Keys.Keys -EncryptionProtector <EncryptionProtector> -UserAssignedIdentityId <UserAssignedIdentityId> -AssignIdentity
重要
長期保留 (LTR) 備份不會提供備份所使用的金鑰清單。 若要還原 LTR 備份,來源資料庫使用的所有金鑰都必須傳遞至 LTR 還原目標。
用於複製或還原資料庫的自動金鑰輪替選項
最新複製或還原的資料庫可以設定為自動輪替用於透明資料加密的客戶自控金鑰。 如需如何在 Azure 入口網站或使用 API 中啟用自動金鑰輪替的資訊,請參閱資料庫層級的自動金鑰輪替。
下一步
請查看下列有關各種資料庫層級 CMK 作業的文件: