Skip to content

[SQL] Fix az sql server update --assign_identity failing with unrelated RetentionDays error#33317

Draft
Copilot wants to merge 2 commits intodevfrom
copilot/fix-az-sql-server-update-identity-error
Draft

[SQL] Fix az sql server update --assign_identity failing with unrelated RetentionDays error#33317
Copilot wants to merge 2 commits intodevfrom
copilot/fix-az-sql-server-update-identity-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 5, 2026

az sql server update --assign_identity (and any server update not specifying --soft-delete-retention-days) failed with ERROR: (InvalidParameterValue) Invalid value given for parameter RetentionDays — an error completely unrelated to identity assignment.

Root cause: server_update explicitly set instance.retention_days = None in the else branch when soft_delete_retention_days was not provided. The SDK serializer drops None values from the PUT body, so the Azure SQL API received a request with no retentionDays field and rejected it.

Fix: Remove the else: instance.retention_days = None branch. When --soft-delete-retention-days is not specified, the existing value from the GET response is preserved in the PUT body.

# Before (broken)
if soft_delete_retention_days is not None:
    instance.retention_days = soft_delete_retention_days
else:
    instance.retention_days = None  # strips field from PUT body → API error

# After (fixed)
if soft_delete_retention_days is not None:
    instance.retention_days = soft_delete_retention_days
# else: preserve existing value from GET response

Testing Guide

New SqlServerUpdateRetentionDaysUnitTest unit test class (no live credentials required) covers:

  • retention_days is preserved when --soft-delete-retention-days is not specified (values: 0, 7, None)
  • retention_days is correctly updated when --soft-delete-retention-days is specified
  • --assign_identity without --soft-delete-retention-days does not affect retention_days (direct regression test)
# Previously failed; should now succeed
az sql server update --name <server> --resource-group <rg> --assign_identity

History Notes

[SQL] az sql server update: Fix --assign_identity failing with unrelated InvalidParameterValue error for RetentionDays


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

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • azcliprod.blob.core.windows.net
    • Triggering command: /usr/bin/python3 python3 -m unittest azure.cli.command_modules.sql.tests.latest.test_sql_commands.SqlServerUpdateRetentionDaysUnitTest -v (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

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

azure-client-tools-bot-prd Bot commented May 5, 2026

️✔️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
️✔️postgresql
️✔️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

azure-client-tools-bot-prd Bot commented May 5, 2026

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

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented May 5, 2026

sql

…serving existing retention_days

Agent-Logs-Url: https://github.com/Azure/azure-cli/sessions/10c5a645-1796-4cf0-9712-045bfe649233

Co-authored-by: a0x1ab <59631311+a0x1ab@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix az sql server update identity assignment error [SQL] Fix az sql server update --assign_identity failing with unrelated RetentionDays error May 5, 2026
Copilot finished work on behalf of a0x1ab May 5, 2026 04:23
Copilot AI requested a review from a0x1ab May 5, 2026 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

az sql server update --assign_identity fails with unrelated "Invalid value given for parameter RetentionDays" error

5 participants