แชร์ผ่าน


az datamigration sql-db

Note

This reference is part of the datamigration extension for the Azure CLI (version 2.15.0 or higher). The extension will automatically install the first time you run an az datamigration sql-db command. Learn more about extensions.

Manage database migrations to SQL DB.

Commands

Name Description Type Status
az datamigration sql-db cancel

Stop in-progress database migration to SQL DB.

Extension GA
az datamigration sql-db create

Create a new database migration to a given SQL Db. This command can migrate data from the selected source database tables to the target database tables. If the target database have no table existing, please use New-AzDataMigrationSqlServerSchema command to migrate schema objects from source database to target databse. The link of New-AzDataMigrationSqlServerSchema is https://learn.microsoft.com/cli/azure/datamigration?view=azure-cli-latest#az-datamigration-sql-server-schema.

Extension GA
az datamigration sql-db delete

Delete an in-progress or completed database migration to SQL DB.

Extension GA
az datamigration sql-db show

Retrieve the specified database migration for a given SQL DB.

Extension GA
az datamigration sql-db wait

Place the CLI in a waiting state until a condition of the datamigration sql-db is met.

Extension GA

az datamigration sql-db cancel

Stop in-progress database migration to SQL DB.

az datamigration sql-db cancel --migration-operation-id
                               [--ids]
                               [--no-wait]
                               [--resource-group]
                               [--sqldb-instance-name]
                               [--subscription]
                               [--target-db-name]

Examples

Stop ongoing migration for the database.

az datamigration sql-db cancel --migration-operation-id "9a90bb84-e70f-46f7-b0ae-1aef5b3b9f07" --resource-group "testrg" --sqldb-instance-name "sqldbinstance" --target-db-name "db1"

Required Parameters

--migration-operation-id

ID tracking migration operation.

Optional Parameters

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--no-wait

Do not wait for the long-running operation to finish.

Default value: False
--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--sqldb-instance-name

Name of the target SQL Database Server.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--target-db-name

The name of the target database.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az datamigration sql-db create

Create a new database migration to a given SQL Db. This command can migrate data from the selected source database tables to the target database tables. If the target database have no table existing, please use New-AzDataMigrationSqlServerSchema command to migrate schema objects from source database to target databse. The link of New-AzDataMigrationSqlServerSchema is https://learn.microsoft.com/cli/azure/datamigration?view=azure-cli-latest#az-datamigration-sql-server-schema.

az datamigration sql-db create --resource-group
                               --sqldb-instance-name
                               --target-db-name
                               [--migration-service]
                               [--no-wait]
                               [--scope]
                               [--source-database-name]
                               [--source-sql-connection]
                               [--table-list]
                               [--target-db-collation]
                               [--target-sql-connection]

Examples

Create or Update Database Migration resource with Maximum parameters.

az datamigration sql-db create --migration-service "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.DataMigration/sqlMigrationServices/testagent" --scope "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Sql/servers/sqldbinstance" --source-database-name "aaa" --source-sql-connection authentication="WindowsAuthentication" data-source="aaa" encrypt-connection=true password="placeholder" trust-server-certificate=true user-name="bbb" --table-list "[Schema1].[TableName1]" "[Schema2].[TableName2]" --target-sql-connection authentication="SqlAuthentication" data-source="sqldbinstance" encrypt-connection=true password="placeholder" trust-server-certificate=true user-name="bbb" --resource-group "testrg" --sqldb-instance-name "sqldbinstance" --target-db-name "db1"

Create or Update Database Migration resource with Minimum parameters.

az datamigration sql-db create --migration-service "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.DataMigration/sqlMigrationServices/testagent" --scope "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Sql/servers/sqldbinstance" --source-database-name "aaa" --source-sql-connection authentication="WindowsAuthentication" data-source="aaa" encrypt-connection=true password="placeholder" trust-server-certificate=true user-name="bbb" --target-sql-connection authentication="SqlAuthentication" data-source="sqldbinstance" encrypt-connection=true password="placeholder" trust-server-certificate=true user-name="bbb" --resource-group "testrg" --sqldb-instance-name "sqldbinstance" --target-db-name "db1"

Required Parameters

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--sqldb-instance-name

Name of the target SQL Database Server.

--target-db-name

The name of the target database.

Optional Parameters

--migration-service

Resource Id of the Migration Service.

--no-wait

Do not wait for the long-running operation to finish.

Default value: False
--scope

Resource Id of the target resource (SQL VM, SQL Managed Instance or SQL DB).

--source-database-name

Name of the source database.

--source-sql-connection

Source SQL Server connection details.

Usage: --source-sql-connection data-source=XX authentication=XX user-name=XX password=XX encrypt-connection=XX trust-server-certificate=XX

data-source: Data source. authentication: Authentication type. user-name: User name to connect to source SQL. password: Password to connect to source SQL. encrypt-connection: Whether to encrypt connection or not. trust-server-certificate: Whether to trust server certificate or not.

--table-list

List of tables to copy.

--target-db-collation

Database collation to be used for the target database.

--target-sql-connection

Target SQL DB connection details.

Usage: --target-sql-connection data-source=XX authentication=XX user-name=XX password=XX encrypt-connection=XX trust-server-certificate=XX

data-source: Data source. authentication: Authentication type. user-name: User name to connect to source SQL. password: Password to connect to source SQL. encrypt-connection: Whether to encrypt connection or not. trust-server-certificate: Whether to trust server certificate or not.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az datamigration sql-db delete

Delete an in-progress or completed database migration to SQL DB.

az datamigration sql-db delete [--force {false, true}]
                               [--ids]
                               [--no-wait]
                               [--resource-group]
                               [--sqldb-instance-name]
                               [--subscription]
                               [--target-db-name]
                               [--yes]

Examples

Delete Database Migration resource.

az datamigration sql-db delete --resource-group "testrg" --sqldb-instance-name "sqldbinstance" --target-db-name "db1"

Optional Parameters

--force

Optional force delete boolean. If this is provided as true, migration will be deleted even if active.

Accepted values: false, true
--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--no-wait

Do not wait for the long-running operation to finish.

Default value: False
--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--sqldb-instance-name

Name of the target SQL Database Server.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--target-db-name

The name of the target database.

--yes -y

Do not prompt for confirmation.

Default value: False
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az datamigration sql-db show

Retrieve the specified database migration for a given SQL DB.

az datamigration sql-db show [--expand]
                             [--ids]
                             [--migration-operation-id]
                             [--resource-group]
                             [--sqldb-instance-name]
                             [--subscription]
                             [--target-db-name]

Examples

Get Sql DB database Migration with the expand parameter.

az datamigration sql-db show --expand "MigrationStatusDetails" --resource-group "testrg" --sqldb-instance-name "sqldbinstance" --target-db-name "db1"

Get Sql DB database Migration without the expand parameter.

az datamigration sql-db show --resource-group "testrg" --sqldb-instance-name "sqldbinstance" --target-db-name "db1"

Optional Parameters

--expand

Complete migration details be included in the response.

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--migration-operation-id

Optional migration operation ID. If this is provided, then details of migration operation for that ID are retrieved. If not provided (default), then details related to most recent or current operation are retrieved.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--sqldb-instance-name

Name of the target SQL Database Server.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--target-db-name

The name of the target database.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az datamigration sql-db wait

Place the CLI in a waiting state until a condition of the datamigration sql-db is met.

az datamigration sql-db wait [--created]
                             [--custom]
                             [--deleted]
                             [--exists]
                             [--expand]
                             [--ids]
                             [--interval]
                             [--migration-operation-id]
                             [--resource-group]
                             [--sqldb-instance-name]
                             [--subscription]
                             [--target-db-name]
                             [--timeout]
                             [--updated]

Examples

Pause executing next line of CLI script until the datamigration sql-db is successfully created.

az datamigration sql-db wait --resource-group "testrg" --sqldb-instance-name "sqldbinstance" --target-db-name "db1" --created

Pause executing next line of CLI script until the datamigration sql-db is successfully deleted.

az datamigration sql-db wait --resource-group "testrg" --sqldb-instance-name "sqldbinstance" --target-db-name "db1" --deleted

Optional Parameters

--created

Wait until created with 'provisioningState' at 'Succeeded'.

Default value: False
--custom

Wait until the condition satisfies a custom JMESPath query. E.g. provisioningState!='InProgress', instanceView.statuses[?code=='PowerState/running'].

--deleted

Wait until deleted.

Default value: False
--exists

Wait until the resource exists.

Default value: False
--expand

Complete migration details be included in the response.

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--interval

Polling interval in seconds.

Default value: 30
--migration-operation-id

Optional migration operation ID. If this is provided, then details of migration operation for that ID are retrieved. If not provided (default), then details related to most recent or current operation are retrieved.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--sqldb-instance-name

Name of the target SQL Database Server.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--target-db-name

The name of the target database.

--timeout

Maximum wait in seconds.

Default value: 3600
--updated

Wait until updated with provisioningState at 'Succeeded'.

Default value: False
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.