[Sql]'az sql ltr-policy update': Add prompt when customer set locked on immutability-mode #32821
[Sql]'az sql ltr-policy update': Add prompt when customer set locked on immutability-mode #32821lixiachena wants to merge 1 commit intoAzure:devfrom
Conversation
️✔️AzureCLI-FullTest
|
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
Hi @lixiachena, |
|
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>
|
️✔️AzureCLI-BreakingChangeTest
|
There was a problem hiding this comment.
Pull request overview
Adds an extra interactive confirmation to az sql db ltr-policy set when the user sets time-based immutability mode to Locked, to ensure customers acknowledge the irreversible impact.
Changes:
- Prompt for confirmation when
--tb-immutability-mode lockedis specified (unless--yesis provided).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if time_based_immutability_mode.lower() == 'locked': | ||
| if not yes: | ||
| confirmation = prompt_y_n("""Once locked, immutable backups cannot be modified or deleted for the full retention period. There is no extra cost to enable immutability, but standard backup storage charges apply. Note: The logical Azure SQL Server cannot be deleted during the retention period. | ||
| Do you want to proceed?""") |
There was a problem hiding this comment.
For an irreversible action like setting immutability mode to locked, it’s safer to explicitly set the prompt default to “no” (and avoid relying on prompt_y_n’s library default). This reduces the risk of an accidental lock by hitting Enter, while still allowing automation via --yes.
| Do you want to proceed?""") | |
| Do you want to proceed?""", default='n') |
| confirmation = prompt_y_n("""Once locked, immutable backups cannot be modified or deleted for the full retention period. There is no extra cost to enable immutability, but standard backup storage charges apply. Note: The logical Azure SQL Server cannot be deleted during the retention period. | ||
| Do you want to proceed?""") |
There was a problem hiding this comment.
The confirmation message is embedded as a single very long line with a newline + indentation in the middle, which will include leading spaces in the rendered prompt and is hard to maintain. Consider formatting it as multiple shorter lines (or dedenting) so the CLI output is clean and future edits don’t require touching an overlong literal.
| if time_based_immutability_mode.lower() == 'locked': | ||
| if not yes: | ||
| confirmation = prompt_y_n("""Once locked, immutable backups cannot be modified or deleted for the full retention period. There is no extra cost to enable immutability, but standard backup storage charges apply. Note: The logical Azure SQL Server cannot be deleted during the retention period. | ||
| Do you want to proceed?""") | ||
| if not confirmation: | ||
| return |
There was a problem hiding this comment.
When users pass both --tb-immutability Enabled and --tb-immutability-mode Locked in the same call, they will be prompted twice (once for enabling immutability above, and again here for locking). Consider consolidating into a single confirmation when mode is locked (e.g., skip the earlier prompt or make the earlier prompt conditional on mode != locked) to avoid redundant interactive prompts.
Related command
Description
Add a prompt for customer to be aware of impact of locked immutability-mode
Testing Guide
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.