diff --git a/src/azure-cli/azure/cli/command_modules/rdbms/_helptext_pg.py b/src/azure-cli/azure/cli/command_modules/rdbms/_helptext_pg.py index 043d9e11419..94770f77b4a 100644 --- a/src/azure-cli/azure/cli/command_modules/rdbms/_helptext_pg.py +++ b/src/azure-cli/azure/cli/command_modules/rdbms/_helptext_pg.py @@ -327,6 +327,8 @@ text: az postgres flexible-server migration update --subscription xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --resource-group testGroup --name testserver --migration-name xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --db-names db1 db2 - name: Allow the migration workflow to overwrite the DB on the target. text: az postgres flexible-server migration update --subscription xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --resource-group testGroup --name testserver --migration-name xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --overwrite-dbs + - name: Cutover the data migration. After this is complete, subsequent updates to the source DB will not be migrated to the target. + text: az postgres flexible-server migration update --subscription xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --resource-group testGroup --name testserver --migration-name xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --cutover - name: This command helps in starting the data migration immediately between the source and target. Any migration scheduled for a future date and time will be cancelled. text: az postgres flexible-server migration update --subscription xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --resource-group testGroup --name testserver --migration-name xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --start-data-migration """ diff --git a/src/azure-cli/azure/cli/command_modules/rdbms/_params.py b/src/azure-cli/azure/cli/command_modules/rdbms/_params.py index 598e3442867..0dabaf54ab0 100644 --- a/src/azure-cli/azure/cli/command_modules/rdbms/_params.py +++ b/src/azure-cli/azure/cli/command_modules/rdbms/_params.py @@ -735,6 +735,8 @@ def handle_migration_parameters(command_group, server_name_arg_type, migration_i help='Space-separated list of DBs to migrate. A minimum of 1 and a maximum of 8 DBs can be specified. You can migrate more DBs concurrently using additional migrations. Note that each additional DB affects the performance of the source server.') c.argument('overwrite_dbs', options_list=['--overwrite-dbs'], action='store_true', required=False, help='Allow the migration workflow to overwrite the DB on the target.') + c.argument('cutover', options_list=['--cutover'], action='store_true', required=False, + help='Cut-over the data migration. After this is complete, subsequent updates to the source DB will not be migrated to the target.') c.argument('start_data_migration', options_list=['--start-data-migration'], action='store_true', required=False, help='Reschedule the data migration to start right now.') elif scope == "delete": diff --git a/src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_common.py b/src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_common.py index 1cb25d46dca..2a98cf46a60 100644 --- a/src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_common.py +++ b/src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_common.py @@ -63,12 +63,11 @@ def migration_create_func(cmd, client, resource_group_name, server_name, propert raise FileOperationError("Properties file does not exist in the given location") with open(properties_filepath, "r") as f: try: - request_payload = json.load(f) - request_payload.get("properties")['TriggerCutover'] = 'true' - json_data = json.dumps(request_payload) + json_data = json.dumps(json.load(f)) except ValueError as err: logger.error(err) raise BadRequestError("Invalid json file. Make sure that the json file content is properly formatted.") + if migration_name is None: # Convert a UUID to a string of hex digits in standard form migration_name = str(uuid.uuid4()) @@ -95,7 +94,7 @@ def migration_list_func(cmd, client, resource_group_name, server_name, migration return r.json() -def migration_update_func(cmd, client, resource_group_name, server_name, migration_name, setup_logical_replication=None, db_names=None, overwrite_dbs=None, start_data_migration=None): +def migration_update_func(cmd, client, resource_group_name, server_name, migration_name, setup_logical_replication=None, db_names=None, overwrite_dbs=None, cutover=None, start_data_migration=None): subscription_id = get_subscription_id(cmd.cli_ctx) @@ -119,6 +118,12 @@ def migration_update_func(cmd, client, resource_group_name, server_name, migrati operationSpecified = True properties = "{\"properties\": {\"overwriteDBsInTarget\": \"true\"} }" + if cutover is True: + if operationSpecified is True: + raise MutuallyExclusiveArgumentError("Incorrect Usage: Can only specify one update operation.") + operationSpecified = True + properties = "{\"properties\": {\"triggerCutover\": \"true\"} }" + if start_data_migration is True: if operationSpecified is True: raise MutuallyExclusiveArgumentError("Incorrect Usage: Can only specify one update operation.")