[SQL] Fix az sql server update failing with "Invalid value given for parameter RetentionDays"#33593
Draft
Copilot wants to merge 2 commits into
Draft
[SQL] Fix az sql server update failing with "Invalid value given for parameter RetentionDays"#33593Copilot wants to merge 2 commits into
az sql server update failing with "Invalid value given for parameter RetentionDays"#33593Copilot wants to merge 2 commits into
Conversation
️✔️AzureCLI-FullTest
|
️✔️AzureCLI-BreakingChangeTest
|
Closed
…er RetentionDays When the Azure SQL API returns retention_days=-1 for legacy servers (where soft delete was never configured), the server_update command was failing with "Invalid value given for parameter RetentionDays" because: 1. The previous fix set instance.retention_days=None (omitting the field from PUT) 2. The Azure SQL API then internally used the existing -1 value and rejected it Fix: normalize -1 to 0 (disabled) when user does not specify --soft-delete-retention-days. Closes #32741
Copilot
AI
changed the title
[WIP] Fix invalid value error for RetentionDays in az sql server update
[SQL] Fix Jun 21, 2026
az sql server update failing with "Invalid value given for parameter RetentionDays"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related command
az sql server updateDescription
az sql server updatefails withInvalid value given for parameter RetentionDayseven when--soft-delete-retention-daysis not specified by the user. This affects any update operation on legacy servers (e.g.,--enable-public-network true).Root cause: The Azure SQL API returns
retentionDays = -1for servers where soft delete was never configured. On every PUT, the API now validates the server's internalretentionDaysregardless of whether the field was included in the request body. A prior fix omitted the field (None) from the PUT body, but the API still reads the existing-1from its internal state and rejects it.Fix:
server_update: when--soft-delete-retention-daysis not provided and the existinginstance.retention_days < 0, normalize to0(disabled) so the PUT body explicitly carries a valid value, migrating the legacy-1state to0retention_daysofNone,0, or1–7Testing Guide
Unit tests added in
ServerUpdateRetentionDaysUnitTest(no live resources required):# Run the new unit tests python -m unittest azure.cli.command_modules.sql.tests.latest.test_sql_commands.ServerUpdateRetentionDaysUnitTest -vTo reproduce the fix manually on a legacy server:
History Notes
[SQL]
az sql server update: Fix "Invalid value given for parameter RetentionDays" error on servers where soft delete retention was never configuredThis 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.