Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
00b9235
{Docs} Remove stale reference in README to closed issue about extensi…
dkmiller Apr 27, 2020
ab16df0
Merge remote-tracking branch 'upstream/release'
azclibot Apr 28, 2020
03436bc
Merge remote-tracking branch 'upstream/release'
azclibot Apr 30, 2020
7d98b1f
Merge remote-tracking branch 'upstream/release'
azclibot May 19, 2020
06f6ec5
Merge remote-tracking branch 'upstream/release'
azclibot Jun 2, 2020
adab2d2
Merge remote-tracking branch 'upstream/release'
azclibot Jun 23, 2020
c7b9f98
Merge remote-tracking branch 'upstream/release'
azclibot Jul 14, 2020
18e8b8d
Merge remote-tracking branch 'upstream/release'
azclibot Jul 16, 2020
1eb5074
Merge remote-tracking branch 'upstream/release'
azclibot Aug 4, 2020
cc3a159
Merge remote-tracking branch 'upstream/release' into master
azclibot Aug 6, 2020
af8f98e
Merge remote-tracking branch 'upstream/release' into master
azclibot Aug 26, 2020
0f904b9
Merge remote-tracking branch 'upstream/release' into master
azclibot Aug 28, 2020
9968e6d
midb log-replay commands
MDCS-sql Sep 15, 2020
c8abe60
fixed tests and styles
MDCS-sql Sep 15, 2020
9c48068
Fixing alias for some params
MDCS-sql Sep 15, 2020
a4192ea
Merge branch 'dev' of https://github.com/Azure/azure-cli into logReplay
MDCS-sql Sep 15, 2020
702eeaa
making things right
MDCS-sql Sep 18, 2020
d17a993
Merge remote-tracking branch 'upstream/release' into master
azclibot Sep 22, 2020
73a9256
Typos and wait command
MDCS-sql Sep 22, 2020
9791b52
add wait command in help file
MDCS-sql Sep 22, 2020
3be9b07
Merge branch 'master' of https://github.com/Azure/azure-cli into logR…
MDCS-sql Sep 22, 2020
ff39850
reverting changes that are not part of my change
MDCS-sql Sep 24, 2020
a78f79a
setup file changed by mistake
MDCS-sql Sep 24, 2020
5294f88
removed group create
MDCS-sql Sep 25, 2020
0c67b16
fix key vault issues
MDCS-sql Sep 28, 2020
494ce40
Merge branch 'dev' of https://github.com/Azure/azure-cli into logReplay
MDCS-sql Sep 28, 2020
caa3e0c
Added examples for log-replay wait command and fixed typos
MDCS-sql Sep 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions src/azure-cli/azure/cli/command_modules/sql/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,45 @@
short-summary: Place the CLI in a waiting state until a condition of the managed database is met.
"""

helps['sql midb log-replay'] = """
type: group
short-summary: SQL Managed Instance database Log Replay service commands.
"""

helps['sql midb log-replay start'] = """
type: command
short-summary: Starts Log Replay service on specified database.
examples:
- name: Log Replay with auto complete option.
text: az sql midb log-replay start -g mygroup --mi myinstance -n mymanageddb -a --last-bn "backup.bak" --storage-uri "https://test.blob.core.windows.net/testing" --storage-sas "sv=2019-02-02&ss=b&srt=sco&sp=rl&se=2023-12-02T00:09:14Z&st=2019-11-25T16:09:14Z&spr=https&sig=92kAe4QYmXaht%2Fgjocqwerqwer41s%3D"
- name: Log Replay without auto complete option.
text: az sql midb log-replay start -g mygroup --mi myinstance -n mymanageddb --storage-uri "https://test.blob.core.windows.net/testing" --storage-sas "sv=2019-02-02&ss=b&srt=sco&sp=rl&se=2023-12-02T00:09:14Z&st=2019-11-25T16:09:14Z&spr=https&sig=92kAe4QYmXaht%2Fgjocqwerqwer41s%3D"
"""

helps['sql midb log-replay complete'] = """
type: command
short-summary: Completes Log Replay service on specified database.
examples:
- name: Completes log replay service.
text: az sql midb log-replay complete -g mygroup --mi myinstance -n mymanageddb --last-backup-name "backup.bak"
"""

helps['sql midb log-replay show'] = """
type: command
short-summary: Gets status of Log Replay service.
examples:
- name: Gets status of the ongoing log replay service.
text: az sql midb log-replay show -g mygroup --mi myinstance -n mymanageddb
"""

helps['sql midb log-replay stop'] = """
type: command
short-summary: Stops Log Replay service.
examples:
- name: Stops ongoing log replay service by deleting database.
text: az sql midb log-replay stop -g mygroup --mi myinstance -n mymanageddb
"""

helps['sql server'] = """
type: group
short-summary: Manage SQL servers.
Expand Down
50 changes: 44 additions & 6 deletions src/azure-cli/azure/cli/command_modules/sql/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@
ElasticPoolCapabilitiesAdditionalDetails,
FailoverPolicyType,
SqlServerMinimalTlsVersionType,
SqlManagedInstanceMinimalTlsVersionType,
AuthenticationType
Copy link
Member Author

Choose a reason for hiding this comment

The 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 (
Expand Down Expand Up @@ -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))
Expand All @@ -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))
Expand Down Expand Up @@ -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 #
###############################################
Expand Down
4 changes: 4 additions & 0 deletions src/azure-cli/azure/cli/command_modules/sql/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,7 @@ def get_sql_database_long_term_retention_policies_operations(cli_ctx, _):

def get_sql_database_long_term_retention_backups_operations(cli_ctx, _):
return get_sql_management_client(cli_ctx).long_term_retention_backups


def get_sql_managed_database_restore_details_operations(cli_ctx, _):
return get_sql_management_client(cli_ctx).managed_database_restore_details
18 changes: 18 additions & 0 deletions src/azure-cli/azure/cli/command_modules/sql/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add wait command here

Copy link
Member Author

Choose a reason for hiding this comment

The 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 ) ?

Copy link
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Member Author

Choose a reason for hiding this comment

The 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 #
###############################################
Expand Down
43 changes: 40 additions & 3 deletions src/azure-cli/azure/cli/command_modules/sql/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member Author

Choose a reason for hiding this comment

The 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`.')

Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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 #
###############################################
Expand Down
Loading