Skip to content
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

[SQL] Add IOPS parameter to MI create and update #29873

Merged
merged 9 commits into from
Sep 13, 2024
4 changes: 4 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 @@ -908,6 +908,8 @@
text: az sql mi create -g mygroup -n myinstance -l mylocation -i -u myusername -p mypassword --subnet /subscriptions/{SubID}/resourceGroups/{ResourceGroup}/providers/Microsoft.Network/virtualNetworks/{VNETName}/subnets/{SubnetName} --dns-zone-partner dns
- name: Create managed instance which uses Windows authentication metadata mode
text: az sql mi create -g mygroup -n myinstance -l mylocation -i -u myusername -p mypassword --subnet /subscriptions/{SubID}/resourceGroups/{ResourceGroup}/providers/Microsoft.Network/virtualNetworks/{VNETName}/subnets/{SubnetName} --am Windows
- name: Create GPv2 managed instance with specified IOPS limit
text: az sql mi create -g mygroup -n myinstance -l mylocation -i -u myusername -p mypassword --subnet /subscriptions/{SubID}/resourceGroups/{ResourceGroup}/providers/Microsoft.Network/virtualNetworks/{VNETName}/subnets/{SubnetName} -e GeneralPurpose --gpv2 true -f Gen8IH -c 4 --storage 256GB --iops 3000
"""

helps['sql mi delete'] = """
Expand Down Expand Up @@ -1045,6 +1047,8 @@
text: az sql mi update -g mygroup -n myinstance --database-format AlwaysUpToDate --pricing-model Regular
- name: Update managed instance to use Windows authentication metadata mode
text: az sql mi update -g mygroup -n myinstance --am Windows
- name: Update managed instance to GPv2 with specified IOPS limit
text: az sql mi update -g mygroup -n myinstance -e GeneralPurpose --gpv2 true --iops 3000
"""

helps['sql midb'] = """
Expand Down
18 changes: 18 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 @@ -299,6 +299,11 @@ def get_location_type_with_default_from_resource_group(cli_ctx):
help='The storage size. If no unit is specified, defaults to gigabytes (GB).',
validator=validate_managed_instance_storage_size)

iops_param_type = CLIArgumentType(
options_list=['--iops'],
type=int,
help='The storage iops.')

backup_storage_redundancy_param_type = CLIArgumentType(
options_list=['--backup-storage-redundancy', '--bsr'],
type=get_internal_backup_storage_redundancy,
Expand Down Expand Up @@ -2276,12 +2281,23 @@ def _configure_security_policy_storage_params(arg_ctx):
help='The compute generation component of the sku. '
'Allowed values include: Gen4, Gen5.')

c.argument('is_general_purpose_v2',
options_list=['--gpv2'],
arg_type=get_three_state_flag(),
help='Whether or not this is a GPv2 variant of General Purpose edition.')

c.argument('storage_size_in_gb',
options_list=['--storage'],
arg_type=storage_param_type,
help='The storage size of the managed instance. '
'Storage size must be specified in increments of 32 GB')

c.argument('storage_iops',
options_list=['--iops'],
arg_type=iops_param_type,
help='The storage iops of the managed instance. '
'Storage iops can be specified in increments of 1.')

c.argument('license_type',
arg_type=get_enum_type(DatabaseLicenseType),
help='The license type to apply for this managed instance.')
Expand Down Expand Up @@ -2352,13 +2368,15 @@ def _configure_security_policy_storage_params(arg_ctx):
# Create args that will be used to build up the ManagedInstance object
create_args_for_complex_type(
c, 'parameters', ManagedInstance, [
'is_general_purpose_v2',
'administrator_login',
'administrator_login_password',
'license_type',
'minimal_tls_version',
'virtual_network_subnet_id',
'vcores',
'storage_size_in_gb',
'storage_iops',
'collation',
'proxy_override',
'public_data_endpoint_enabled',
Expand Down
16 changes: 16 additions & 0 deletions src/azure-cli/azure/cli/command_modules/sql/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -5070,10 +5070,12 @@ def managed_instance_update( # pylint: disable=too-many-locals
cmd,
instance,
resource_group_name,
is_general_purpose_v2=None,
administrator_login_password=None,
license_type=None,
vcores=None,
storage_size_in_gb=None,
storage_iops=None,
assign_identity=False,
proxy_override=None,
public_data_endpoint_enabled=None,
Expand Down Expand Up @@ -5110,6 +5112,18 @@ def managed_instance_update( # pylint: disable=too-many-locals
instance.service_principal = _get_service_principal_object_from_type(service_principal_type)

# Apply params to instance
# Note on is_general_purpose_v2
# If this parameter was not set by the user, we do not want to pick up its current value.
# This is due to the fact that this update might have a target edition that does not use this parameter.
# Note on storage_iops
# If this parameter was not set by the user, we do not want to pick up its current value.
# This is due to the fact that this update might have a target edition that does not use this parameter.
# If the target edition uses the parameter, the current value will get picked up later in the update process.
# Note on storage_throughput_mbps
# If this parameter was not set by the user, we do not want to pick up its current value.
# This is due to the fact that this update might have a target edition that does not use this parameter.
# If the target edition uses the parameter, the current value will get picked up later in the update process.
instance.is_general_purpose_v2 = is_general_purpose_v2
instance.administrator_login_password = (
administrator_login_password or instance.administrator_login_password)
instance.license_type = (
Expand All @@ -5118,6 +5132,8 @@ def managed_instance_update( # pylint: disable=too-many-locals
vcores or instance.v_cores)
instance.storage_size_in_gb = (
storage_size_in_gb or instance.storage_size_in_gb)
instance.storage_iops = storage_iops
instance.storage_throughput_mbps = None
instance.proxy_override = (
proxy_override or instance.proxy_override)
instance.minimal_tls_version = (
Expand Down
Loading
Loading