-
Notifications
You must be signed in to change notification settings - Fork 292
feat(provision): prompt to cancel Azure deployment on Ctrl+C (Bicep) #7795
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
Open
vhvb1989
wants to merge
10
commits into
main
Choose a base branch
from
vivazqu/provision-cancel-ctrlc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
db0c2be
feat(provision): prompt to cancel Azure deployment on Ctrl+C (Bicep)
vhvb1989 f0501f6
fix: address Copilot review feedback (iteration 1)
vhvb1989 e95b773
fix: address Copilot review feedback (iteration 2)
vhvb1989 b2d0c19
fix: close interrupt-vs-natural-completion race (iteration 3)
vhvb1989 5fc8a71
fix: re-entrant Ctrl+C suppression hardening (iteration 4)
vhvb1989 fea0473
fix: address Copilot review feedback (iteration 5)
vhvb1989 7b67773
fix: address Copilot review feedback (iteration 6)
vhvb1989 f511812
fix: address Copilot review feedback (iteration 7)
vhvb1989 bea4593
fix: address Copilot review feedback (iteration 8)
vhvb1989 199a887
fix: address review findings from wbreza and jongio on PR #7795
vhvb1989 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # Provision cancellation (Ctrl+C) | ||
|
|
||
| When `azd provision` (or `azd up`) submits a Bicep deployment to Azure, the | ||
| deployment runs asynchronously on the Azure side. If the user presses | ||
| <kbd>Ctrl</kbd>+<kbd>C</kbd> while azd is waiting for that deployment to | ||
| finish, azd will pause and ask what to do instead of exiting immediately. | ||
|
|
||
| ## Behavior | ||
|
|
||
| 1. azd stops the live progress reporter and presents an interactive prompt | ||
| that includes the Azure portal URL of the running deployment. | ||
| 2. The user picks one of: | ||
| - **Leave the Azure deployment running and stop azd** (default). azd | ||
| exits with a non-zero status; the Azure deployment continues to | ||
| completion. The user can monitor or cancel it from the portal link. | ||
| - **Cancel the Azure deployment**. azd submits an ARM cancel request | ||
| against the deployment and waits up to 2 minutes for Azure to confirm a | ||
| terminal state (`Canceled`, `Failed`, or `Succeeded`). | ||
| 3. Additional <kbd>Ctrl</kbd>+<kbd>C</kbd> presses while the prompt is | ||
| showing (or while a cancel request is in flight) are ignored so the user | ||
| can finish reading and choose deliberately. | ||
|
|
||
| ## Outcomes when "Cancel" is selected | ||
|
|
||
| | Outcome | When | | ||
| |---------|------| | ||
| | Cancellation confirmed | Azure transitions the deployment to `Canceled` within the wait budget. azd exits non-zero with a clear message. | | ||
| | Cancel arrived too late | Azure reports the deployment finished (`Succeeded` / `Failed`) before the cancel request took effect. azd surfaces the final state plus the portal URL. | | ||
| | Cancel still pending | Azure does not reach a terminal state within the wait budget. azd warns that cancellation is still in progress and prints the portal URL. | | ||
| | Cancel request failed | The ARM `Cancel` API itself returned an error. azd prints the error and the portal URL. | | ||
|
|
||
| When the deployment URL is available, azd prints it so the user can follow | ||
| up manually from the browser. The URL is omitted if azd was unable to | ||
| resolve it (for example, when the ARM service is unreachable). | ||
|
|
||
| ## Provider scope | ||
|
|
||
| | Provider | Behavior on Ctrl+C during provision | | ||
| |---------|--------------------------------------| | ||
| | Bicep (subscription scope) | Interactive prompt (described above). | | ||
| | Bicep (resource group scope) | Interactive prompt (described above). | | ||
| | Deployment Stacks | Currently treated as "leave running" — the stacks ARM API does not expose a per-deployment cancel surface today. | | ||
| | Terraform | Unchanged: the Terraform CLI does not expose a safe per-apply cancel; pressing Ctrl+C exits azd and Terraform handles its own teardown. | | ||
|
|
||
| ## Telemetry | ||
|
|
||
| A `provision.cancellation` attribute is recorded on the provisioning span | ||
| with one of: | ||
|
|
||
| - `none` — provisioning completed normally without an interrupt. | ||
| - `leave_running` — user chose to let the Azure deployment continue. | ||
| - `canceled` — cancel request succeeded and Azure reached `Canceled`. | ||
| - `cancel_too_late` — Azure reached `Succeeded` / `Failed` before cancel | ||
| took effect. | ||
| - `cancel_timed_out` — Azure did not reach a terminal state within the | ||
| wait budget. | ||
| - `cancel_failed` — the ARM `Cancel` API call itself returned an error. | ||
|
|
||
| ## Non-interactive mode | ||
|
|
||
| If azd is running without a TTY (e.g. CI), the prompt cannot be displayed. | ||
| In that case azd defaults to **leave running** behavior so that an | ||
| unattended deployment is never silently cancelled by an environment | ||
| signal. | ||
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.