Skip to content
Merged
Prev Previous commit
Next Next commit
[SQL] az sql mi update: Add --subnet and --vnet-name parameters to su…
…pport the cross subnet update SLO (#18886)

* Update sql track2

* Update commands.py

update begin_delete

* update setter_name to pass sdk validation

* replace_all_delete

* pass az self-check

* update recording tests

* fix all begin_xyz issue

* run test to unblock some issues

* pass SqlServerMSSupportScenarioTest

* change region to pass tests

* pass LTR test

* add recorded tests for MI

* update db_rename parameters

* pass db management tests

* address aad tests

* pass sql server aad

* revert azure-mgmt-netapp version change

* record test after rebase

* add three passed tests

* modify short term policy

* complete another three tests

* pass tde test

* pass two more tests

* Update custom.py

* pass two more tests

* pass classification test

* pass long and short backup

* update test file to match new config

* pass server and db security tests

* record test_sql_db_sensitivity_classifications again

* update MI tests

* pass MI tests

* pass tests

* modify instance_pool_test

* Iteration 1:
- Adding support for cross subnet update SLO

* Iteration 2:
- Removing the change from History.rst file

* Iteration 3:
- Fixing merge errors

* Iteration 4:
- Removing merge errors

* Iteration 5:
- Removing merge errors

* Iteration 6:
- Fixed merge errors

* Iteration 7:
- Fix merge errors

* Iteration 7:
- Fixed CLI style issue - removed two trailing spaces
- Fixed CLI linter issue - fixed the cross-subnet update slo command in _help.py

Co-authored-by: Ji Wang <[email protected]>
Co-authored-by: Nemanja <[email protected]>
  • Loading branch information
3 people authored Aug 3, 2021
commit 0d6b718a6aa4b7f3bb7cbc38ee0e3e54adeddaae
5 changes: 4 additions & 1 deletion src/azure-cli/azure/cli/command_modules/sql/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,10 +892,13 @@
text: az sql mi update -g myResourceGroup -n myServer -i \\
--user-assigned-identity-id /subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testumi \\
--identity-type SystemAssigned,UserAssigned --pid /subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testumi
- name: Update a managed instance with User Managed Identies and Identity Type is UserAssigned.
- name: Update a managed instance with User Managed Identies and Identity Type is UserAssigned
text: az sql mi update -g myResourceGroup -n myServer -i \\
--user-assigned-identity-id /subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testumi \\
--identity-type UserAssigned --pid /subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testumi
- name: Move managed instance to another subnet
text: az sql mi update -g myResourceGroup -n myServer -i \\
--subnet /subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testumi \\
"""

helps['sql midb'] = """
Expand Down
11 changes: 11 additions & 0 deletions src/azure-cli/azure/cli/command_modules/sql/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -1979,6 +1979,17 @@ def _configure_security_policy_storage_params(arg_ctx):

c.ignore('name') # Hide sku name

c.extra('vnet_name',
options_list=['--vnet-name'],
help='The virtual network name',
validator=validate_subnet)

c.argument('virtual_network_subnet_id',
options_list=['--subnet'],
required=False,
help='Name or ID of the subnet that allows access to an Azure Sql Managed Instance. '
'If subnet name is provided, --vnet-name must be provided.')

with self.argument_context('sql mi show') as c:
c.argument('expand_ad_admin',
options_list=['--expand-ad-admin'],
Expand Down
6 changes: 5 additions & 1 deletion src/azure-cli/azure/cli/command_modules/sql/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -4313,7 +4313,8 @@ def managed_instance_update(
primary_user_assigned_identity_id=None,
key_id=None,
identity_type=None,
user_assigned_identity_id=None):
user_assigned_identity_id=None,
virtual_network_subnet_id=None):
'''
Updates a managed instance. Custom update function to apply parameters to instance.
'''
Expand Down Expand Up @@ -4362,6 +4363,9 @@ def managed_instance_update(

instance.key_id = (key_id or instance.key_id)

if virtual_network_subnet_id is not None:
instance.subnet_id = virtual_network_subnet_id

return instance


Expand Down
Loading