Share via


az datamigration sql-db

Note

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

Manage 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://free.blessedness.top/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 retry

Retry on going migration for the database.

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

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--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.

Property Value
Parameter group: Resource Id Arguments
--no-wait

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

Property Value
Default value: False
--resource-group -g

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

Property Value
Parameter group: Resource Id Arguments
--sqldb-instance-name

Name of the target SQL Database Server.

Property Value
Parameter group: Resource Id Arguments
--subscription

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

Property Value
Parameter group: Resource Id Arguments
--target-db-name

The name of the target database.

Property Value
Parameter group: Resource Id Arguments
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

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

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

--verbose

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

Property Value
Default value: False

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://free.blessedness.top/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

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--migration-service

Resource Id of the Migration Service.

--no-wait

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

Property Value
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.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
--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.

Property Value
Default value: False

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

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--force

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

Property Value
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.

Property Value
Parameter group: Resource Id Arguments
--no-wait

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

Property Value
Default value: False
--resource-group -g

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

Property Value
Parameter group: Resource Id Arguments
--sqldb-instance-name

Name of the target SQL Database Server.

Property Value
Parameter group: Resource Id Arguments
--subscription

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

Property Value
Parameter group: Resource Id Arguments
--target-db-name

The name of the target database.

Property Value
Parameter group: Resource Id Arguments
--yes -y

Do not prompt for confirmation.

Property Value
Default value: False
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

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

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

--verbose

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

Property Value
Default value: False

az datamigration sql-db retry

Retry on going migration for the database.

az datamigration sql-db retry [--ids]
                              [--migration-operation-id]
                              [--no-wait {0, 1, f, false, n, no, t, true, y, yes}]
                              [--resource-group]
                              [--sql-db-instance-name]
                              [--subscription]
                              [--target-db-name]

Examples

Retry Database Migration resource.

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

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--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.

Property Value
Parameter group: Resource Id Arguments
--migration-operation-id

Unique ID for tracking the migration operation.

Property Value
Parameter group: MigrationOperationInput Arguments
--no-wait

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

Property Value
Accepted values: 0, 1, f, false, n, no, t, true, y, yes
--resource-group -g

Name of the Azure resource group.

Property Value
Parameter group: Resource Id Arguments
--sql-db-instance-name

Name of the SQL database instance.

Property Value
Parameter group: Resource Id Arguments
--subscription

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

Property Value
Parameter group: Resource Id Arguments
--target-db-name

The name of the target database.

Property Value
Parameter group: Resource Id Arguments
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

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

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

--verbose

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

Property Value
Default value: False

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

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--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.

Property Value
Parameter group: 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>.

Property Value
Parameter group: Resource Id Arguments
--sqldb-instance-name

Name of the target SQL Database Server.

Property Value
Parameter group: Resource Id Arguments
--subscription

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

Property Value
Parameter group: Resource Id Arguments
--target-db-name

The name of the target database.

Property Value
Parameter group: Resource Id Arguments
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

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

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

--verbose

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

Property Value
Default value: False

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

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--created

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

Property Value
Parameter group: Wait Condition Arguments
Default value: False
--custom

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

Property Value
Parameter group: Wait Condition Arguments
--deleted

Wait until deleted.

Property Value
Parameter group: Wait Condition Arguments
Default value: False
--exists

Wait until the resource exists.

Property Value
Parameter group: Wait Condition Arguments
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.

Property Value
Parameter group: Resource Id Arguments
--interval

Polling interval in seconds.

Property Value
Parameter group: Wait Condition Arguments
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>.

Property Value
Parameter group: Resource Id Arguments
--sqldb-instance-name

Name of the target SQL Database Server.

Property Value
Parameter group: Resource Id Arguments
--subscription

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

Property Value
Parameter group: Resource Id Arguments
--target-db-name

The name of the target database.

Property Value
Parameter group: Resource Id Arguments
--timeout

Maximum wait in seconds.

Property Value
Parameter group: Wait Condition Arguments
Default value: 3600
--updated

Wait until updated with provisioningState at 'Succeeded'.

Property Value
Parameter group: Wait Condition Arguments
Default value: False
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

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

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

--verbose

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

Property Value
Default value: False