Skip to content

[SQL] az sql db update: Prevent overwrite of SLO when updating from serverless to provisioned#32292

Merged
evelyn-ys merged 1 commit intoAzure:devfrom
achyuth-ms:sloupdatefix
Oct 21, 2025
Merged

[SQL] az sql db update: Prevent overwrite of SLO when updating from serverless to provisioned#32292
evelyn-ys merged 1 commit intoAzure:devfrom
achyuth-ms:sloupdatefix

Conversation

@achyuth-ms
Copy link
Copy Markdown
Member

@achyuth-ms achyuth-ms commented Oct 20, 2025

Related command
az sql db update

Description
Fixes a bug where updating a database from serverless to provisioned compute tier would incorrectly overwrite the service objective name to 'S0' instead of using the user-specified service objective.

Previously, when converting from serverless (e.g., GP_S_Gen5_1) to a provisioned tier (e.g., Standard S1), the code would default to 'S0' regardless of the --service-objective parameter value.

This fix ensures that when a user explicitly specifies --service-objective during a serverless-to-provisioned update, that value is preserved and used instead of being overwritten.

Testing Guide
Test case added: test_sql_db_serverless_to_provisioned_slo_update

Steps to reproduce the original bug:

  1. Create a serverless database: az sql db create --service-objective GP_S_Gen5 --compute-model Serverless
  2. Update to Standard S1: az sql db update --service-objective S1 --edition Standard
  3. Previously: Database would be updated to S0 (bug)
  4. After fix: Database correctly updates to S1

The test validates:

  • Creates serverless database (GP_S_Gen5 with 1 vCore)
  • Updates to Standard S1 with explicit --service-objective S1
  • Verifies currentServiceObjectiveName is 'S1' (not 'S0')
  • Converts back to serverless successfully

History Notes
[SQL] az sql db update: Prevent overwrite of SLO when updating from serverless to provisioned


This checklist is used to make sure that common guidelines for a pull request are followed.

@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Oct 20, 2025

️✔️AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.13
️✔️acs
️✔️latest
️✔️3.12
️✔️3.13
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.13
️✔️ams
️✔️latest
️✔️3.12
️✔️3.13
️✔️apim
️✔️latest
️✔️3.12
️✔️3.13
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.13
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️aro
️✔️latest
️✔️3.12
️✔️3.13
️✔️backup
️✔️latest
️✔️3.12
️✔️3.13
️✔️batch
️✔️latest
️✔️3.12
️✔️3.13
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.13
️✔️billing
️✔️latest
️✔️3.12
️✔️3.13
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.13
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.13
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.13
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.13
️✔️config
️✔️latest
️✔️3.12
️✔️3.13
️✔️configure
️✔️latest
️✔️3.12
️✔️3.13
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.13
️✔️container
️✔️latest
️✔️3.12
️✔️3.13
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.13
️✔️core
️✔️latest
️✔️3.12
️✔️3.13
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.13
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.13
️✔️dls
️✔️latest
️✔️3.12
️✔️3.13
️✔️dms
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.13
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.13
️✔️find
️✔️latest
️✔️3.12
️✔️3.13
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.13
️✔️identity
️✔️latest
️✔️3.12
️✔️3.13
️✔️iot
️✔️latest
️✔️3.12
️✔️3.13
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.13
️✔️lab
️✔️latest
️✔️3.12
️✔️3.13
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️maps
️✔️latest
️✔️3.12
️✔️3.13
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.13
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.13
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.13
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.13
️✔️network
️✔️latest
️✔️3.12
️✔️3.13
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.13
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.13
️✔️profile
️✔️latest
️✔️3.12
️✔️3.13
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.13
️✔️redis
️✔️latest
️✔️3.12
️✔️3.13
️✔️relay
️✔️latest
️✔️3.12
️✔️3.13
️✔️resource
️✔️latest
️✔️3.12
️✔️3.13
️✔️role
️✔️latest
️✔️3.12
️✔️3.13
️✔️search
️✔️latest
️✔️3.12
️✔️3.13
️✔️security
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.13
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.13
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.13
️✔️sql
️✔️latest
️✔️3.12
️✔️3.13
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.13
️✔️storage
️✔️latest
️✔️3.12
️✔️3.13
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.13
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.13
️✔️util
️✔️latest
️✔️3.12
️✔️3.13
️✔️vm
️✔️latest
️✔️3.12
️✔️3.13

@azure-client-tools-bot-prd
Copy link
Copy Markdown

Hi @achyuth-ms,
Since the current milestone time is less than 7 days, this pr will be reviewed in the next milestone.

@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Oct 20, 2025

️✔️AzureCLI-BreakingChangeTest
️✔️Non Breaking Changes

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Oct 20, 2025

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link
Copy Markdown

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).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

@achyuth-ms achyuth-ms changed the title Fix to prevent overwrite of slo when updating db serverless to provisioned [SQL] Fix: az sql db update: Prevent overwrite of SLO when updating from serverless to provisioned Oct 20, 2025
@achyuth-ms achyuth-ms marked this pull request as ready for review October 20, 2025 23:50
Copilot AI review requested due to automatic review settings October 20, 2025 23:50
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 fixes a bug in az sql db update where updating a database from serverless to provisioned compute tier would incorrectly default to service objective 'S0' instead of preserving the user-specified value.

Key Changes:

  • Modified compute model detection logic to use the requested service_objective parameter instead of only checking the current database SKU
  • Added null safety check to _is_serverless_slo function
  • Added comprehensive test case validating serverless-to-provisioned updates with explicit service objective

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/azure-cli/azure/cli/command_modules/sql/custom.py Fixed compute model detection to respect user-specified service objective and added null safety check
src/azure-cli/azure/cli/command_modules/sql/tests/latest/test_sql_commands.py Added test case validating the fix for serverless-to-provisioned updates

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +1209 to +1211



Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

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

Remove excessive blank lines at the end of the test method. Two blank lines are sufficient between top-level definitions.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

@ericshape ericshape left a comment

Choose a reason for hiding this comment

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

approved from SQL RP

@evelyn-ys
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@evelyn-ys evelyn-ys changed the title [SQL] Fix: az sql db update: Prevent overwrite of SLO when updating from serverless to provisioned [SQL] az sql db update: Prevent overwrite of SLO when updating from serverless to provisioned Oct 21, 2025
@evelyn-ys evelyn-ys merged commit c0a728a into Azure:dev Oct 21, 2025
50 checks passed
SakoPak pushed a commit to SakoPak/azure-cli that referenced this pull request Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants