Contain a failed rollout and restore the release

Completed

When the first VM returns HTTP 503 after installing v2-bad, Contoso has two jobs: protect the three VMs still processing quotes and recover the one that changed.

Diagram that shows three VMs continuing to process quotes while Contoso restores v1 on the VM that returned HTTP 503.

Canceling the rollout stops new batches. It doesn't undo an update that's already started. To recover, Contoso must restore the approved release, v1, in the model and on the affected VM.

This worked example assumes that three worker VMs can process Contoso's quote demand within the required processing time and before the noon cutoff while the fourth VM is updating. Before relying on that assumption for a real release, establish it from measured quote completion rates, expected arrivals, and outstanding work. Allow for the delay before any additional VM can process requests; available quota isn't ready application capacity. If the remaining three VMs can't meet the target, defer the release or obtain an approved capacity plan before starting it. Contoso updates one VM at a time in place, without surge or overprovisioning. The following JSON shows the upgradePolicy portion of its Uniform model during a release, not a deployment template.

{
  "mode": "Rolling",
  "automaticOSUpgradePolicy": { "enableAutomaticOSUpgrade": false },
  "rollingUpgradePolicy": {
    "maxBatchInstancePercent": 25,
    "maxUnhealthyInstancePercent": 5,
    "maxUnhealthyUpgradedInstancePercent": 0,
    "pauseTimeBetweenBatches": "PT1M",
    "enableCrossZoneUpgrade": false,
    "rollbackFailedInstancesOnPolicyBreach": false,
    "maxSurge": false
  }
}

With four VMs, a 25% batch contains one VM. Before each batch, Azure checks the unhealthy percentage across the fleet; 5% is the minimum for maxUnhealthyInstancePercent in Compute API 2024-11-01. Contoso requires all four VMs to report healthy at the start. After a batch, Azure checks the upgraded instances. If the quote service fails its health check on the only upgraded VM, that batch breaches the 0% post-batch limit. Don't widen that limit to get the rollout moving. Azure waits one minute after a successful batch. If the health requirements are still met, the next batch can start without operator approval.

Before enabling this release, Contoso establishes the quote service's stop-acquiring and shutdown behavior. The approved installer or deployment integration stops the consumer from acquiring new requests on the VM Azure selects for the batch, before interrupting the application process. In-flight work must finish within the approved wait window or be safely returned or made available for retry through the queue's supported mechanism. After the update, the service must recover readiness before the batch can pass its health gate. Azure doesn't implement the application's queue-draining logic.

Don't stop all four consumers in advance or assume the operator chooses Azure's next batch. Planned draining belongs inside the selected VM's update lifecycle. Making a VM report unhealthy before Azure evaluates its pre-batch gate can prevent the batch from starting; don't conceal a readiness failure to bypass that gate.

Diagram that shows Azure checking fleet health before a batch and the health of upgraded VMs before starting the next batch.

For a zonal fleet, preserve zone-aware batching unless the capacity review permits crossing zones; enabling cross-zone upgrade ignores zone boundaries when forming batches. Contoso's regional fleet doesn't establish zone redundancy. MaxSurge would create new VMs from the latest model, check their health, then remove the old VMs. It needs extra quota, addresses, and allocation capacity. If the quota check before a batch fails, Azure falls back to an in-place upgrade. MaxSurge doesn't reserve spare capacity. If Contoso must keep every serving VM available, don't start or continue a rollout that could fall back to updating those VMs in place.

Stop further changes

The release pipeline starts the application rollout by changing the model's installer configuration and release tag. Don't use az vmss rolling-upgrade start to deploy an application: it starts an OS image upgrade. When the quote service returns 503 on the first VM updated to v2-bad, use this containment procedure:

  1. Hold new releases, keep repairs disabled, and freeze scaling at the current count. Don't replace the affected VM or add a VM from the suspect model. Record the VM's ID and extension status, and save the service logs, /health response, and reference quote.
  2. Stop the affected quote service from acquiring new requests, and establish the state of its in-flight requests. Don't interrupt the three healthy consumers unnecessarily. If the approved isolation procedure stops the whole service, capture available endpoint evidence first and repeat the health and quote checks after its controlled restart. If the service has already failed and can't drain, confirm that redelivery and duplicate-safe result handling cover that failure before forcing a disruptive action.
  3. In the rolling-upgrade banner, open View details. Find when the updated VM first changed from Healthy to Unhealthy. Compare that timestamp with the rollout timeline to identify the batch that was running. In Activity log, inspect the scale-set update and its Change history; save the operation's UTC time and correlation ID.
  4. Read the latest rollout status. If it's still active, use Cancel upgrade or az vmss rolling-upgrade cancel. If the health gate already ended it, record the terminal status rather than issuing another change. A VM update that started before cancellation can still finish. Check the rollout status again, then list the VMs to identify which ones Azure updated. Query /work on each VM to confirm which application release is actually running.

Diagram that shows how Contoso stops further changes, preserves evidence, and identifies the running release on each VM.

In PowerShell, confirm the Azure CLI subscription with az account show. Set $Rg to the intended resource group and $Name to the Uniform scale set. Read the rollout status without changing it:

az vmss rolling-upgrade get-latest --resource-group $Rg --name $Name

Only if the rollout is still active on that scale set, cancel it:

az vmss rolling-upgrade cancel --resource-group $Rg --name $Name

Cancellation isn't rollback. It neither rewrites the desired model nor uninstalls software on an updated VM. Uniform can optionally roll back failed instances on a policy breach; Contoso leaves rollbackFailedInstancesOnPolicyBreach off. Flexible orchestration doesn't support automatic rollback of failed VMs after a rolling-policy breach. Rollback during an OS image upgrade is a separate mechanism.

Restore the model, then reconcile the VMs

Comparing the model with the application running on each of the four VMs shows why both steps matter:

Observation Desired release What runs on the VMs What it proves
Rollout stops after the first batch v2-bad The service returns 503 on the updated VM; the other three still run v1. The rollout has stopped, but the model still specifies v2-bad. Replacing a VM or adding a fifth VM would install that release.
Approved model is restored in Manual mode v1 The updated VM still runs v2-bad. A new VM would get v1; existing VMs haven't necessarily applied it.
VMs are reconciled and the service is checked v1 All four VMs have the approved model. On each VM, the service reports stable health and returns a v1 quote for 49 tiles. The application, not just the deployment, is recovered.

Diagram that shows why restoring v1 in the model and verifying a 49-tile v1 result on each of four VMs are separate steps.

Once Azure reports that the rollout has finished, failed, or been canceled, retrieve the approved v1 installer, exact image version, deployment template, and parameters. If you find an undocumented change inside a VM, record what changed before updating the VM. Don't include that change in the approved release. Exporting the scale-set model won't capture it. Stop if the required configuration can't be established.

Confirm that the approved installer supports the actual transition back to v1 and that v1 remains compatible with the current queue messages and order-system state. If compatibility can't be established, stop this downgrade procedure and obtain an approved roll-forward or other compatible recovery plan. Reimaging or replacing the VM doesn't reverse changes in those shared systems.

For a resource-group deployment, az deployment group validate checks the template. Set $TemplatePath to the approved v1 template and $ParametersPath to its reviewed JSON parameter file, not an export of the current model. Use what-if to preview which resources would change without applying those changes:

az deployment group what-if --resource-group $Rg --template-file $TemplatePath `
    --parameters "@$ParametersPath"

Use the preview to decide whether to proceed:

  1. Review the diff: the installer settings or command must select v1, and forceUpdateTag must be v1. The mode should be Manual, the count should remain four, and competing automation should stay off. Reject unexpected image, network, or capacity changes.
  2. After approval, deploy that artifact through the pipeline. Before updating any VM, inspect the deployed scale-set model. Confirm that the installer settings or command select v1, forceUpdateTag is v1, the upgrade mode is Manual, and capacity is still four. A successful deployment updates desired configuration; it doesn't prove the quote service has recovered on all four VMs.
  3. From the current inventory, set $AffectedId to one confirmed affected Uniform instance ID. Confirm that its quote service has stopped acquiring work and that any in-flight request has completed durably or can be retried safely. If you can't establish this, keep the rollout contained and escalate instead of applying the update. Apply the restored model to only that instance with az vmss update-instances. Stop on a CLI error; don't proceed to another VM to see if the error recurs.
az vmss update-instances --resource-group $Rg --name $Name --instance-ids $AffectedId

Diagram that shows the operator previewing the deployment, restoring the approved model, and applying it to one affected VM.

Wait for stable extension health and check /work on that VM. It must identify v1 and return 49 tiles for the reference quote. Resume the recovered consumer only through the approved readiness procedure. Read latestModelApplied across the fleet. For each VM where it's false, stop that consumer from taking new requests and confirm that in-flight requests have finished or can be safely retried. Update one VM at a time. A v1 response confirms the application release, not that the VM has applied the rest of the model. Keep repairs and scaling disabled if any VM hasn't applied the restored model or if the service fails either the health check or the reference quote on any VM. Before closing the incident, also confirm a fresh request completes through the normal queue-to-order-system path; a local /work response alone doesn't prove safe message completion.

Recover a VM in Flexible orchestration

On a Flexible scale set, stop the rollout if an updated VM can't report readiness. Suppose the quote service on one VM now runs v3 and its rich-health extension has already left Initializing. If its endpoint consistently returns HTTP 503 with an empty body, the extension reports Unknown once the configured probe threshold is met, not an explicit Unhealthy. That's still a reason to stop. Cancellation won't put v1 back.

Restore the approved v1 scale-set model in Manual mode so that VMs created from it use the approved configuration. Decide whether the affected VM should receive that whole profile or retain approved per-VM differences. For deliberate per-VM configuration, use the standard VM or extension operation targeting its resource ID. For model synchronization, az vmss update-instances takes the affected Flexible VM's name, not a Uniform numeric instance ID or its full resource ID.

Before either operation, confirm that the installer supports the actual transition from v3 to v1 and that v1 is compatible with current shared state. Stop the affected consumer from acquiring work and establish safe completion or redelivery of in-flight requests. If those conditions can't be established, stop and obtain an approved compatible recovery plan.

Before the recovery window, confirm that the Azure CLI and Compute API versions approved for this fleet support manual profile updates on Flexible VMs. Don't infer support from a successful Uniform update. If Azure rejects the operation, stop rather than broadening the target or silently switching methods.

Set $FlexRg and $FlexName to the Flexible resource group and scale set. Set $FlexVmName from the current VM inventory and confirm that the selected VM belongs to that scale set. Synchronize only that VM, and only if the whole profile is intended for it, the installer can safely restore v1, and the consumer has no requests at risk:

az vmss update-instances --resource-group $FlexRg --name $FlexName --instance-ids $FlexVmName

After the selected operation, compare the VM's image and extension configuration with its approved configuration. Don't assume the Uniform latestModelApplied inventory procedure supplies equivalent evidence for Flexible. Confirm stable application health and /work reporting v1 and 49 tiles. Resume the consumer only through the approved readiness procedure, then confirm a fresh request completes through the normal order path. Keep repairs and scaling held until the affected VMs pass these checks.

Diagram that shows a Flexible rollout stopping on Unknown health, followed by model restoration and verification of the affected VM.