使用 Private Link 匯入或匯出 Azure SQL 資料庫

適用於:Azure SQL 資料庫

透過 Azure PowerShell 或 Azure 入口網站執行匯入或匯出時,您必須將 [允許存取 Azure 服務] 設定為 [開啟],否則匯入或匯出作業會失敗,並發生錯誤。 通常,使用者會想要使用私人端點執行匯入或匯出,而不需要存取所有 Azure 服務。 本文說明如何使用 Private Link 匯入或匯出 Azure SQL 資料庫,並在 Azure SQL 邏輯伺服器上將 [允許存取 Azure 服務] 設為 [關閉]。

注意

針對 Azure SQL 資料庫使用 Private Link 的匯入/匯出目前為預覽狀態。

資料庫匯入/匯出私人連結是由 Microsoft 所建立的服務受控私人端點,專用於資料庫匯入/匯出流程、Azure SQL 資料庫和相關 Azure 儲存體服務的所有通訊。 服務管理的私人端點,是特定虛擬網路和子網路內的私人 IP 位址。 使用者必須在伺服器和儲存體的 Azure 入口網站中手動核准私人端點。

Diagram of Import Export Private link architecture.

匯入/匯出 Private Link 可以透過 Azure 入口網站、PowerShell 或使用 REST API 來設定。

  1. 移至您要匯入資料庫的 Azure SQL 邏輯伺服器的 [概觀] 頁面。 從工具列選取 [匯入資料庫]。
  2. 在 [匯入資料庫] 頁面中,選取 [使用 Private Link] 選項核取方塊。 Screenshot from the Azure portal that shows how to enable Import Private link.
  3. 輸入儲存體帳戶、驗證認證、資料庫詳細資料,然後選取 [確定]。
  1. 移至您要匯入的 Azure SQL 資料庫的 [概觀] 頁面。 從工具列選取 [匯出]。
  2. 在 [匯出資料庫] 頁面中,選取 [使用 Private Link] 選項核取方塊。 Screenshot from the Azure portal that shows how to enable Export Private Link.
  3. 輸入儲存體帳戶、驗證認證、資料庫詳細資料,然後選取 [確定]。

2. 核准私人端點

  1. 前往 Azure 入口網站中的 Private Link 中心。 在 Azure 搜尋方塊中,搜尋「Private Link」。
  2. 瀏覽至 Private Link 中心的 [私人端點] 頁面。
  3. 核准您使用匯入/匯出服務建立的私人端點。

核准 Azure SQL 資料庫上的私人端點連線

  1. 移至裝載資料庫的 Azure SQL 邏輯伺服器。
  2. 瀏覽至 [安全性] 底下的 [網路] 頁面
  3. 選取 [私人存取] 索引標籤。
  4. 選取您想要核准的私人端點。
  5. 選取 [核准] 以核准連線。

Screenshot from the Azure portal that shows how to approve Azure SQL Database Private Link.

核准 Azure 儲存體上的私人端點連線

  1. 移至裝載 .bacpac 檔案所在 Blob 容器的儲存體帳戶。
  2. 在 [安全性] 功能表中開啟 [私人端點連線] 頁面。
  3. 選取匯入/匯出服務的私人端點。
  4. 選取 [核准] 以核准連線。

Screenshot from the Azure portal that shows how to approve Azure Storage Private Link in Azure Storage.

3. 檢查匯入/匯出狀態

  1. 在核准私人端點之後,會在 Azure SQL 伺服器和 Azure 儲存體帳戶中啟動資料庫匯入或匯出作業。 在那之前將會保留作業。
  2. 您可以在 [Azure SQL Server] 頁面的 [資料管理] 區段下,檢查 [匯入/匯出記錄] 頁面的資料庫匯入或匯出作業狀態。 Screenshot from the Azure portal that shows how to check Import Export Jobs Status.

使用 New-AzSqlDatabaseImport Cmdlet,將匯入資料庫要求提交至 Azure。 匯入可能需要一些時間才能完成,視資料庫大小而定。 以 DTU 為基礎的佈建模型支援每一層的選取資料庫大小上限值。 匯入資料庫時 使用其中一個支援的值

$importRequest = New-AzSqlDatabaseImport -ResourceGroupName "<resourceGroupName>" `
        -ServerName "<serverName>" -DatabaseName "<databaseName>" `
        -DatabaseMaxSizeBytes "<databaseSizeInBytes>" -StorageKeyType "StorageAccessKey" `
        -StorageKey $(Get-AzStorageAccountKey -ResourceGroupName $resourceGroupName `
                        -StorageAccountName "<storageAccountName>").Value[0]
        -StorageUri "https://myStorageAccount.blob.core.windows.net/importsample/sample.bacpac" `
        -Edition "Standard" -ServiceObjectiveName "P6" ` -UseNetworkIsolation $true `
        -StorageAccountResourceIdForPrivateLink "/subscriptions/<subscriptionId>/resourcegroups/<resource_group_name>/providers/Microsoft.Storage/storageAccounts/<storage_account_name>" `
         -SqlServerResourceIdForPrivateLink "/subscriptions/<subscriptionId>/resourceGroups/<resource_group_name>/providers/Microsoft.Sql/servers/<server_name>" `
        -AdministratorLogin "<userID>" `
        -AdministratorLoginPassword $(ConvertTo-SecureString -String "<password>" -AsPlainText -Force)

使用 New-AzSqlDatabaseExport Cmdlet 將匯出資料庫要求提交至 Azure SQL 資料庫服務。 視資料庫大小而定,匯出作業可能需要一些時間才能完成。

$importRequest = New-AzSqlDatabaseExport -ResourceGroupName "<resourceGroupName>" `
        -ServerName "<serverName>" -DatabaseName "<databaseName>" `
        -DatabaseMaxSizeBytes "<databaseSizeInBytes>" -StorageKeyType "StorageAccessKey" `
        -StorageKey $(Get-AzStorageAccountKey -ResourceGroupName $resourceGroupName `
                        -StorageAccountName "<storageAccountName>").Value[0]
        -StorageUri "https://myStorageAccount.blob.core.windows.net/importsample/sample.bacpac" `
        -Edition "Standard" -ServiceObjectiveName "P6" ` -UseNetworkIsolation $true `
        -StorageAccountResourceIdForPrivateLink "/subscriptions/<subscriptionId>/resourcegroups/<resource_group_name>/providers/Microsoft.Storage/storageAccounts/<storage_account_name>" `
         -SqlServerResourceIdForPrivateLink "/subscriptions/<subscriptionId>/resourceGroups/<resource_group_name>/providers/Microsoft.Sql/servers/<server_name>" `
        -AdministratorLogin "<userID>" `
        -AdministratorLoginPassword $(ConvertTo-SecureString -String "<password>" -AsPlainText -Force)

已強化用於執行匯入和匯出作業的現有 API,可支援 Private Link。 請參閱匯入資料庫 API

限制

目前,匯入/匯出的 Private Link 有下列限制:

  • 若要搭配匯入/匯出使用 Private Link,使用者資料庫和 Azure 儲存體 Blob 容器必須裝載在相同類型的 Azure 雲端上。 例如,不是同時位於 Azure Commercial 中,就是同時位於 Azure Gov 中。 不支援跨雲端類型裝載。

  • 目前不支援使用 PowerShell 從 Azure SQL 受控執行個體匯入或匯出資料庫的作業。

  • 當使用者資料庫或 Azure 儲存體帳戶受到資源鎖定保護時,不應使用匯入/匯出 Private Link。

  • 需要手動核准新的私人端點連線,才能完成匯出作業。 啟動匯出之後,請移至 Private Link 中心的「擱置連線」並核准連線,這可能需要幾分鐘的時間才會出現。

  • 在建立新資料庫時,使用 Private Link 的匯入不支援指定備份儲存體備援,而會使用預設的異地備援備份儲存體備援來建立資料庫。 因應措施是,先使用 Azure 入口網站或 PowerShell 建立具有所需備份儲存體備援的空資料庫,然後將.bacpac 檔案匯入這個空的資料庫中。

  • 使用 REST API 搭配 Private Link 的匯入只能對現有資料庫進行,因為 API 使用資料庫延伸模組。 因應措施是建立具有所需名稱的空白資料庫,然後使用 Private Link 呼叫匯入 REST API。

下一步