共用方式為


New-AzDataMigrationToSqlDb

建立新的資料庫移轉至指定的 SQL Db。 此命令可以將數據從選取的源資料庫數據表遷移至目標資料庫數據表。 如果目標資料庫沒有現有的數據表,請使用 New-AzDataMigrationSqlServerSchema 命令,將架構物件從源資料庫移轉至目標 databse。

語法

New-AzDataMigrationToSqlDb
   -ResourceGroupName <String>
   -SqlDbInstanceName <String>
   -TargetDbName <String>
   [-SubscriptionId <String>]
   [-Kind <ResourceType>]
   [-MigrationService <String>]
   [-Scope <String>]
   [-SourceDatabaseName <String>]
   [-SourceSqlConnectionAuthentication <String>]
   [-SourceSqlConnectionDataSource <String>]
   [-SourceSqlConnectionEncryptConnection]
   [-SourceSqlConnectionPassword <SecureString>]
   [-SourceSqlConnectionTrustServerCertificate]
   [-SourceSqlConnectionUserName <String>]
   [-TableList <String[]>]
   [-TargetDatabaseCollation <String>]
   [-TargetSqlConnectionAuthentication <String>]
   [-TargetSqlConnectionDataSource <String>]
   [-TargetSqlConnectionEncryptConnection]
   [-TargetSqlConnectionPassword <SecureString>]
   [-TargetSqlConnectionTrustServerCertificate]
   [-TargetSqlConnectionUserName <String>]
   [-DefaultProfile <PSObject>]
   [-AsJob]
   [-NoWait]
   [-PassThru]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

建立新的資料庫移轉至指定的 SQL Db。 此命令可以將數據從選取的源資料庫數據表遷移至目標資料庫數據表。 如果目標資料庫沒有現有的數據表,請使用 New-AzDataMigrationSqlServerSchema 命令,將架構物件從源資料庫移轉至目標 databse。

範例

範例 1:啟動從內部部署來源 Sql Server 移轉至目標 Sql Db 的資料庫

$sourcePassword = ConvertTo-SecureString -String "****" -AsPlainText -Force
$targetPassword = ConvertTo-SecureString -String "****" -AsPlainText -Force
New-AzDataMigrationToSqlDb -ResourceGroupName myRG -SqlDbInstanceName "mysqldb" -MigrationService  "/subscriptions/1111-2222-3333-4444/resourceGroups/myRG/providers/Microsoft.DataMigration/SqlMigrationServices/myDMS" -TargetSqlConnectionAuthentication "SqlAuthentication" -TargetSqlConnectionDataSource "mydb.windows.net" -TargetSqlConnectionPassword $targetPassword -TargetSqlConnectionUserName "user" -SourceSqlConnectionAuthentication "SqlAuthentication" -SourceSqlConnectionDataSource "xyz.MICROSOFT.COM" -SourceSqlConnectionUserName "user1" -SourceSqlConnectionPassword $sourcePassword -SourceDatabaseName "sourcedb" -TargetDbName "mydb1" -Scope  "/subscriptions/1111-2222-3333-4444/resourceGroups/myRG/providers/Microsoft.Sql/servers/mysqldb"

Name       Kind  ProvisioningState MigrationStatus
-----       ----  ----------------- ---------------
mydb1       SqlDb   Succeeded         InProgress

啟動從內部部署來源 Sql Server 移轉至目標 Sql Db 的資料庫

範例 2:使用一些從內部部署來源 Sql Server 選取的數據表來啟動資料庫移轉,以以 Sql Db 為目標

$sourcePassword = ConvertTo-SecureString -String "****" -AsPlainText -Force
$targetPassword = ConvertTo-SecureString -String "****" -AsPlainText -Force
New-AzDataMigrationToSqlDb -ResourceGroupName myRG -SqlDbInstanceName "mysqldb" -MigrationService  "/subscriptions/1111-2222-3333-4444/resourceGroups/myRG/providers/Microsoft.DataMigration/SqlMigrationServices/myDMS" -TargetSqlConnectionAuthentication "SqlAuthentication" -TargetSqlConnectionDataSource "mydb.windows.net" -TargetSqlConnectionPassword $targetPassword -TargetSqlConnectionUserName "user" -SourceSqlConnectionAuthentication "SqlAuthentication" -SourceSqlConnectionDataSource "xyz.MICROSOFT.COM" -SourceSqlConnectionUserName "user1" -SourceSqlConnectionPassword $sourcePassword -SourceDatabaseName "sourcedb" -TargetDbName "mydb1" -Scope  "/subscriptions/1111-2222-3333-4444/resourceGroups/myRG/providers/Microsoft.Sql/servers/mysqldb"  -TableList "table_1"

Name       Kind  ProvisioningState MigrationStatus
-----       ----  ----------------- ---------------
mydb1       SqlDb   Succeeded         InProgress

使用一些從內部部署來源 Sql Server 選取的數據表來啟動資料庫移轉,以以 Sql Db 為目標

參數

-AsJob

以作業身分執行命令

類型:SwitchParameter
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Confirm

在執行 Cmdlet 之前,提示您進行確認。

類型:SwitchParameter
別名:cf
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-DefaultProfile

DefaultProfile 參數無法運作。 如果針對不同的訂用帳戶執行 Cmdlet,請使用 SubscriptionId 參數。

類型:PSObject
別名:AzureRMContext, AzureCredential
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Kind

.

類型:ResourceType
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-MigrationService

移轉服務的資源標識碼。

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-NoWait

以異步方式執行命令

類型:SwitchParameter
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-PassThru

當命令成功時傳回 true

類型:SwitchParameter
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-ResourceGroupName

包含資源的資源群組名稱。 您可以從 Azure Resource Manager API 或入口網站取得此值。

類型:String
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-Scope

目標資源的資源識別碼(SQL VM 或 SQL 受控實例)

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-SourceDatabaseName

源資料庫的名稱。

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-SourceSqlConnectionAuthentication

驗證類型。

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-SourceSqlConnectionDataSource

數據源。

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-SourceSqlConnectionEncryptConnection

是否要加密連線。

類型:SwitchParameter
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-SourceSqlConnectionPassword

線上到來源 SQL 的密碼。

類型:SecureString
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-SourceSqlConnectionTrustServerCertificate

是否信任伺服器證書。

類型:SwitchParameter
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-SourceSqlConnectionUserName

線上至來源 SQL 的用戶名稱。

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-SqlDbInstanceName

.

類型:String
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-SubscriptionId

識別 Azure 訂用帳戶的訂用帳戶標識碼。

類型:String
Position:Named
預設值:(Get-AzContext).Subscription.Id
必要:False
接受管線輸入:False
接受萬用字元:False

-TableList

要複製的數據表清單。

類型:String[]
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-TargetDatabaseCollation

要用於目標資料庫的資料庫定序。

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-TargetDbName

目標資料庫的名稱。

類型:String
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-TargetSqlConnectionAuthentication

驗證類型。

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-TargetSqlConnectionDataSource

數據源。

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-TargetSqlConnectionEncryptConnection

是否要加密連線。

類型:SwitchParameter
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-TargetSqlConnectionPassword

線上到來源 SQL 的密碼。

類型:SecureString
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-TargetSqlConnectionTrustServerCertificate

是否信任伺服器證書。

類型:SwitchParameter
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-TargetSqlConnectionUserName

線上至來源 SQL 的用戶名稱。

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-WhatIf

顯示 Cmdlet 執行時會發生什麼事。 Cmdlet 未執行。

類型:SwitchParameter
別名:wi
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

輸出