Skip to content

Latest commit

 

History

History
82 lines (69 loc) · 4.58 KB

File metadata and controls

82 lines (69 loc) · 4.58 KB

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 Ctrl+C 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 5 minutes (a single global budget) for Azure to confirm a terminal state (Canceled, Failed, or Succeeded). Once the top-level deployment reaches Canceled, azd best-effort cancels and waits for any descendant (nested) deployments within the same 5-minute budget so leftover children do not keep running on Azure.
  3. Additional Ctrl+C 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 raced succeeded Azure reached Succeeded before cancel took effect. azd surfaces this as a success-toned message — resources are deployed.
Cancel raced failed Azure reached Failed before cancel took effect. azd surfaces the failure plus the portal URL.
Cancel raced deleted The deployment record was deleted before cancel took effect (unusual; suggests an external actor).
Cancel still pending Azure does not reach a terminal state within the wait budget. azd warns that cancellation may still complete and prints the portal URL.
Cancel request failed The ARM Cancel API itself returned an error. azd surfaces that the deployment is still running and prints 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_raced_succeeded — Azure reached Succeeded before cancel took effect (resources are deployed; we surface this as a success-toned message rather than a failure).
  • cancel_raced_failed — Azure reached Failed before cancel took effect.
  • cancel_raced_deleted — the deployment record was deleted before cancel could take effect (unusual; suggests an external actor).
  • cancel_too_late — fallback for unexpected terminal states (kept for backwards-compat; the three cancel_raced_* values cover the documented terminal states).
  • cancel_timed_out — top-level deployment did not reach a terminal state within the wait budget (5 minutes).
  • cancel_timed_out_nested — top-level reached Canceled, but one or more descendant (nested) deployments did not reach a terminal state within the same 5-minute global budget. The user-facing output lists the stuck deployment(s) with portal links so they can be investigated manually.
  • 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.