-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[SQL] az sql midb log-replay: Support for log replay service on managed database #15168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
00b9235
ab16df0
03436bc
7d98b1f
06f6ec5
adab2d2
c7b9f98
18e8b8d
1eb5074
cc3a159
af8f98e
0f904b9
9968e6d
c8abe60
9c48068
a4192ea
702eeaa
d17a993
73a9256
9791b52
3be9b07
ff39850
a78f79a
5294f88
0c67b16
494ce40
caa3e0c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,8 +58,7 @@ | |
| ElasticPoolCapabilitiesAdditionalDetails, | ||
| FailoverPolicyType, | ||
| SqlServerMinimalTlsVersionType, | ||
| SqlManagedInstanceMinimalTlsVersionType, | ||
| AuthenticationType | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AuthenticationType is removed from SDK. This shouldn't be part of my change but I was getting build errors. I think I didn't broke anything 🤞 |
||
| SqlManagedInstanceMinimalTlsVersionType | ||
| ) | ||
|
|
||
| from ._validators import ( | ||
|
|
@@ -654,8 +653,7 @@ def load_arguments(self, _): | |
| options_list=['--admin-password', '-p']) | ||
|
|
||
| c.argument('authentication_type', | ||
| options_list=['--auth-type', '-a'], | ||
| arg_type=get_enum_type(AuthenticationType)) | ||
| options_list=['--auth-type', '-a']) | ||
|
|
||
| c.argument('storage_key_type', | ||
| arg_type=get_enum_type(StorageKeyType)) | ||
|
|
@@ -678,8 +676,7 @@ def load_arguments(self, _): | |
| options_list=['--admin-password', '-p']) | ||
|
|
||
| c.argument('authentication_type', | ||
| options_list=['--auth-type', '-a'], | ||
| arg_type=get_enum_type(AuthenticationType)) | ||
| options_list=['--auth-type', '-a']) | ||
|
|
||
| c.argument('storage_key_type', | ||
| arg_type=get_enum_type(StorageKeyType)) | ||
|
|
@@ -1839,6 +1836,47 @@ def _configure_security_policy_storage_params(arg_ctx): | |
| help='The resource id of the long term retention backup to be restored. ' | ||
| 'Use \'az sql midb ltr-backup show\' or \'az sql midb ltr-backup list\' for backup id.') | ||
|
|
||
| with self.argument_context('sql midb log-replay start') as c: | ||
| create_args_for_complex_type( | ||
| c, 'parameters', ManagedDatabase, [ | ||
| 'auto_complete', | ||
| 'last_backup_name', | ||
| 'storage_container_uri', | ||
| 'storage_container_sas_token' | ||
| ]) | ||
|
|
||
| c.argument('auto_complete', | ||
| required=False, | ||
| options_list=['--auto-complete', '-a'], | ||
| action='store_true', | ||
| help='The flag that in usage with last_backup_name automatically completes log replay servise.') | ||
|
|
||
| c.argument('last_backup_name', | ||
| required=False, | ||
| options_list=['--last-backup-name', '--last-bn'], | ||
| help='The name of the last backup to restore.') | ||
|
|
||
| c.argument('storage_container_uri', | ||
| required=True, | ||
| options_list=['--storage-uri', '--su'], | ||
| help='The URI of the storage container where backups are.') | ||
|
|
||
| c.argument('storage_container_sas_token', | ||
| required=True, | ||
| options_list=['--storage-sas', '--ss'], | ||
| help='The authorization Sas token to access storage container where backups are.') | ||
|
|
||
| with self.argument_context('sql midb log-replay complete') as c: | ||
| create_args_for_complex_type( | ||
| c, 'parameters', ManagedDatabase, [ | ||
| 'last_backup_name' | ||
| ]) | ||
|
|
||
| c.argument('last_backup_name', | ||
| required=False, | ||
| options_list=['--last-backup-name', '--last-bn'], | ||
| help='The name of the last backup to restore.') | ||
|
|
||
| ############################################### | ||
| # sql virtual cluster # | ||
| ############################################### | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,7 @@ | |
| get_sql_firewall_rules_operations, | ||
| get_sql_instance_pools_operations, | ||
| get_sql_managed_databases_operations, | ||
| get_sql_managed_database_restore_details_operations, | ||
| get_sql_managed_backup_short_term_retention_policies_operations, | ||
| get_sql_managed_database_long_term_retention_policies_operations, | ||
| get_sql_managed_database_long_term_retention_backups_operations, | ||
|
|
@@ -703,6 +704,23 @@ def load_command_table(self, _): | |
| is_preview=True) | ||
| g.wait_command('wait') | ||
|
|
||
| with self.command_group('sql midb log-replay', | ||
| managed_databases_operations, | ||
| client_factory=get_sql_managed_databases_operations) as g: | ||
| g.custom_command('start', 'managed_db_log_replay_start', supports_no_wait=True) | ||
| g.command('stop', 'delete', confirmation=True, supports_no_wait=True) | ||
| g.command('complete', 'complete_restore') | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add wait command here
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added, but can you tell what is the use case for wait command? Why am I adding it (there must be some rule that I am not aware of ) ?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because you support no wait for some commands, e.g. start, stop, if users use --no-wait in your command, the command will not wait any more. But if i want to query command status, i have to use wait command
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh okay I get it now. Thanks |
||
|
|
||
| managed_database_restore_details_operations = CliCommandType( | ||
| operations_tmpl='azure.mgmt.sql.operations#ManagedDatabaseRestoreDetailsOperations.{}', | ||
| client_factory=get_sql_managed_database_restore_details_operations) | ||
|
|
||
| with self.command_group('sql midb log-replay', | ||
| managed_database_restore_details_operations, | ||
| client_factory=get_sql_managed_database_restore_details_operations) as g: | ||
|
|
||
| g.show_command('show', 'get') | ||
|
|
||
| ############################################### | ||
| # sql virtual cluster # | ||
| ############################################### | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1276,7 +1276,7 @@ def db_update( | |
| Applies requested parameters to a db resource instance for a DB update. | ||
| ''' | ||
| # Verify edition | ||
| if instance.sku.tier.lower() == DatabaseEdition.data_warehouse.value.lower(): # pylint: disable=no-member | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DatabaseEdition was removed from SDK also. Same thing as above |
||
| if instance.sku.tier.lower() == "datawarehouse": # pylint: disable=no-member | ||
| raise CLIError('Azure SQL Data Warehouse can be updated with the command' | ||
| ' `az sql dw update`.') | ||
|
|
||
|
|
@@ -1953,7 +1953,7 @@ def dw_create( | |
| ''' | ||
|
|
||
| # Set edition | ||
| kwargs['sku'].tier = DatabaseEdition.data_warehouse.value | ||
| kwargs['sku'].tier = "DataWarehouse" | ||
|
|
||
| # Create | ||
| return _db_dw_create( | ||
|
|
@@ -1978,7 +1978,7 @@ def dw_list( | |
| server_name=server_name) | ||
|
|
||
| # Include only DW's | ||
| return [db for db in dbs if db.sku.tier == DatabaseEdition.data_warehouse.value] | ||
| return [db for db in dbs if db.sku.tier == "DataWarehouse"] | ||
|
|
||
|
|
||
| def dw_update( | ||
|
|
@@ -3359,6 +3359,43 @@ def restore_long_term_retention_mi_backup( | |
| resource_group_name=target_resource_group_name, | ||
| parameters=kwargs) | ||
|
|
||
|
|
||
| def managed_db_log_replay_start( | ||
| cmd, | ||
| client, | ||
| database_name, | ||
| managed_instance_name, | ||
| resource_group_name, | ||
| auto_complete, | ||
| last_backup_name, | ||
| storage_container_uri, | ||
| storage_container_sas_token, | ||
| **kwargs): | ||
|
|
||
| # Determine managed instance location | ||
| kwargs['location'] = _get_managed_instance_location( | ||
| cmd.cli_ctx, | ||
| managed_instance_name=managed_instance_name, | ||
| resource_group_name=resource_group_name) | ||
|
|
||
| kwargs['create_mode'] = CreateMode.restore_external_backup.value | ||
|
|
||
| if auto_complete and not last_backup_name: | ||
| raise CLIError('Please specify a last backup name when using auto complete flag.') | ||
|
|
||
| kwargs['auto_complete'] = auto_complete | ||
| kwargs['last_backup_name'] = last_backup_name | ||
|
|
||
| kwargs['storageContainerUri'] = storage_container_uri | ||
| kwargs['storageContainerSasToken'] = storage_container_sas_token | ||
|
|
||
| # Create | ||
| return client.create_or_update( | ||
| database_name=database_name, | ||
| managed_instance_name=managed_instance_name, | ||
| resource_group_name=resource_group_name, | ||
| parameters=kwargs) | ||
|
|
||
| ############################################### | ||
| # sql failover-group # | ||
| ############################################### | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.