-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[SQL] az sql mi create/update: Add memory size in gb parameter
#32466
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
base: dev
Are you sure you want to change the base?
[SQL] az sql mi create/update: Add memory size in gb parameter
#32466
Conversation
|
Validation for Azure CLI Full Test Starting...
Thanks for your contribution! |
|
Validation for Breaking Change Starting...
Thanks for your contribution! |
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR. Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a memorySizeInGb parameter to the az sql mi create and az sql mi update commands, leveraging the 2024-08-01-preview API. This enables users to specify the memory size in gigabytes for SQL Managed Instances.
- Added
--memoryparameter to create and update commands for SQL Managed Instances - Implemented parameter handling in custom logic and parameter definitions
- Added comprehensive test coverage and documentation examples
Reviewed changes
Copilot reviewed 4 out of 6 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| test_sql_commands.py | Adds two new test classes to verify memory size parameter functionality in create and update scenarios |
| custom.py | Updates managed_instance_update function to handle memory_size_in_gb parameter and adds logic to set requested_logical_availability_zone to None |
| _params.py | Defines the memory_size_in_gb parameter type and registers it for both create and update commands |
| _help.py | Adds usage examples demonstrating the --memory parameter for create and update commands |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| self.cmd('sql mi delete --ids {} --yes' | ||
| .format(managed_instance['id']), checks=NoneCheck()) | ||
|
|
||
| class SqlManagedInstanceHermesUpdateScenarioTest(ScenarioTest): |
Copilot
AI
Nov 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Class name 'SqlManagedInstanceHermesUpdateScenarioTest' conflicts with an existing class at line 8682. The new test class should be renamed to reflect its purpose of testing memory size in GB updates, such as 'SqlManagedInstanceMemorySizeInGBUpdateScenarioTest'.
| class SqlManagedInstanceMemorySizeInGBCreateScenarioTest(ScenarioTest): | ||
| @AllowLargeResponse() | ||
| def test_sql_mi_memorysizeingb_create(self): | ||
|
|
||
| subscription_id = '62e48210-5e43-423e-889b-c277f3e08c39' | ||
| group = 'uroskrstic' |
Copilot
AI
Nov 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test contains hardcoded subscription IDs and resource group names but is missing the @live_only() decorator. Similar tests in the codebase (e.g., lines 8628, 8684) that use hardcoded resources include this decorator. Add @live_only() before the @AllowLargeResponse() decorator to prevent playback test failures.
| class SqlManagedInstanceHermesUpdateScenarioTest(ScenarioTest): | ||
| @AllowLargeResponse() | ||
| def test_sql_mi_memorysizeingb_update(self): | ||
|
|
||
| subscription_id = '62e48210-5e43-423e-889b-c277f3e08c39' | ||
| group = 'uroskrstic' |
Copilot
AI
Nov 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test contains hardcoded subscription IDs and resource group names but is missing the @live_only() decorator. Similar tests in the codebase (e.g., lines 8628, 8684) that use hardcoded resources include this decorator. Add @live_only() before the @AllowLargeResponse() decorator to prevent playback test failures.
| self.check('sku.family', '{family}'), | ||
| self.check('sku.capacity', '{v_cores}')]) | ||
|
|
||
| # Get the managed instance and check GPv2 flag |
Copilot
AI
Nov 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment incorrectly refers to 'GPv2 flag' but the code is actually checking memory size in GB. Update to: '# Get the managed instance and check memory size in gb'.
| # Get the managed instance and check GPv2 flag | |
| # Get the managed instance and check memory size in gb |
| self.cmd('sql mi update -g {rg} -n {managed_instance_name} --gpv2 {is_general_purpose_v2} --memory {memory_size_in_gb}', | ||
| checks=[self.check('memorySizeInGb', '{memory_size_in_gb}')]) | ||
|
|
||
| # Get the managed instance and check memory size in gb |
Copilot
AI
Nov 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Corrected capitalization of 'gb' to 'GB' to match the parameter name 'memorySizeInGb' and maintain consistency with other comments in the codebase.
| # Get the managed instance and check memory size in gb | |
| # Get the managed instance and check memory size in GB |
| options_list=['--memory'], | ||
| arg_type=memory_size_type, | ||
| help='The memory size of the managed instance.' | ||
| 'Memory size must be specified in GB') |
Copilot
AI
Nov 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space between the two help text strings. The help text will display as 'The memory size of the managed instance.Memory size must be specified in GB'. Add a space before the second string: ' Memory size must be specified in GB'.
| 'Memory size must be specified in GB') | |
| ' Memory size must be specified in GB') |
| - 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 | ||
| - name: Create managed instance with specified memory size in GB | ||
| 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 Gen8IM -c 4 --storage 256GB --iops 3000 --memory 40GB |
Copilot
AI
Nov 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example uses '40GB' without a space, but CLI parameter values typically don't include units. The value should be '40' (the number only), as the help text in _params.py specifies 'Memory size must be specified in GB'. Update to: --memory 40.
| - 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 | ||
| - name: Update managed instance to use a specified memory size in GB | ||
| text: az sql mi update -g mygroup -n myinstance -e GeneralPurpose --memory 40GB |
Copilot
AI
Nov 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example uses '40GB' without a space, but CLI parameter values typically don't include units. The value should be '40' (the number only), as the help text in _params.py specifies 'Memory size must be specified in GB'. Update to: --memory 40.
| text: az sql mi update -g mygroup -n myinstance -e GeneralPurpose --memory 40GB | |
| text: az sql mi update -g mygroup -n myinstance -e GeneralPurpose --memory 40 |
Related command
az sql mi create
az sql mi update
Description
Added memorySizeInGb parameter from the 2024-08-01-preview API to the az cli client. az sql mi create and update commands are affected.
Testing Guide
Added tests that test this new feature. Example of update command:
az sql mi update -g uroskrstic -n uroskrstic-flexi-test-azpowershell --memory 80 --gpv2 True
This checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.