AZ-401: Ordered Deployments Hotfixes and Workload Recovery
Use one bounded release job to check the selected release, apply its compatible database change, deploy the chosen application variant and verify the running workload. Keep later deployment steps stopped when an earlier check fails. Recovery must identify both the code version and the data state; redeploying an older artifact does not automatically reverse a database change.
The worked route uses existing nonproduction Azure App Service targets and Azure SQL Database, with an already authorized Azure Resource Manager connection and a suitable Windows agent. It includes a container route, a packaged-application alternative and DACPAC or SQL-script database variants. No deployment, script, database operation or recovery test was executed while producing this article.
Establish the release contract before changing a target
Complete the artifact-identity and progressive-delivery prerequisites. Select one approved release and record its source revision, immutable artifact or image identity, configuration and compatible database state. Keep the previous known-good release and its dependencies available before starting the exercise.
A data-tier application package (DACPAC) describes a database deployment input. It is not a backup or a promise that every resulting data change can be undone. Have the database owner approve the exact change and the recovery decision independently of the application task.
| Required input | Evidence needed before the job runs |
|---|---|
| Owned targets | Exact nonproduction app, existing slot, resource group, database and their owners |
| Selected payload | Actual image reference or package file, database file and approved identity/hash; no ambiguous latest release |
| Existing agent | Windows, the required SQL deployment tooling and the selected App Service task variant's supported requirements |
| Authorization | Pipeline access to the named service connection, target access and separately verified database authentication |
| Network | Agent access to deployment and database endpoints, permitted registry access and the approved firewall arrangement |
| Script interfaces | Existing supported PowerShell or Bash step interface and reviewed workload verification scripts with explicit failure behavior |
| Recovery | Previous application/configuration, database compatibility decision, data protection and a person authorized to choose recovery |
| Observable health | Actual expected release identity, representative behavior, error/usage signals and an owner-selected observation period |
Do not infer database access from a successful Azure login. The SQL task offers different authentication modes, and its integrated mode requires a private agent. Confirm the exact chosen mode and its tools and permissions; do not assume all three task types accept every federation arrangement.
The App Service task pages also expose variant-dependent requirements, including different rendered agent minima. Validate the installed task and selected variant together rather than choosing one minimum for this entire job. Do not disable certificate validation to make deployment succeed.
Define one ordered execution boundary
Azure Pipelines supports command-line, PowerShell and Bash scripts as steps. Steps within a job execute sequentially on the same agent by default; separate jobs do not automatically have that ordering or workspace. The following YAML (YAML Ain't Markup Language) arrangement keeps the worked sequence in one existing Windows release job.
The examples assume that release variables are already supplied through the owner's approved pipeline configuration. Their values must identify the actual selected files and targets. The service-connection name is a literal example to replace with the one specifically authorized for this pipeline.
Use the order:
- Check the release input and the approved change.
- Apply the selected database variant.
- Deploy either the container or the packaged application.
- Run the established workload verification.
- Permit further exposure only after the recorded result supports it.
Do not combine both application alternatives merely to demonstrate more tasks. They are different release routes. Likewise, choose either the reviewed DACPAC deployment or the reviewed SQL script for this change.
Implement the script and DACPAC portion
This first fragment shows a PowerShell preflight and the database task. The preflight compares the actual selected file with its approved hash; that local file check does not validate the database contents, authorization or network.
jobs:
- job: DeploySelectedRelease
pool:
name: ApprovedWindowsReleasePool
steps:
- powershell: |
$ErrorActionPreference = 'Stop'
if (-not (Test-Path -LiteralPath $env:RELEASE_DACPAC -PathType Leaf)) {
throw 'The selected database package is missing.'
}
$actual = (Get-FileHash -LiteralPath $env:RELEASE_DACPAC -Algorithm SHA256).Hash
if ($actual -ne $env:APPROVED_DACPAC_HASH) {
throw 'The database package does not match the approved release.'
}
displayName: 'Check the selected release input'
env:
RELEASE_DACPAC: $(ReleaseDacpacPath)
APPROVED_DACPAC_HASH: $(ApprovedDacpacHash)
- task: SqlAzureDacpacDeployment@1
displayName: 'Apply the approved database package'
inputs:
azureSubscription: 'release-nonproduction'
AuthenticationType: 'server'
ServerName: '$(SqlServerName)'
DatabaseName: '$(SqlDatabaseName)'
SqlUsername: '$(ReleaseSqlUser)'
SqlPassword: '$(ReleaseSqlPassword)'
deployType: 'DacpacTask'
DeploymentAction: 'Publish'
DacpacFile: '$(ReleaseDacpacPath)'
IpDetectionMethod: 'IPAddressRange'
StartIpAddress: '$(ApprovedAgentIpStart)'
EndIpAddress: '$(ApprovedAgentIpEnd)'
DeleteFirewallRule: true
The illustrated SQL Server authentication requires an existing authorized credential. Supply its password through the established secret mechanism, never as a literal in the file or diagnostic output. This example does not provision a login or grant permissions.
The approved IP range must describe the actual allowed agent path. The task's firewall option is an operational change, not a reason to open a broad range. Inspect any temporary rule and its cleanup after success, failure or interruption; do not assume a lost agent completed cleanup.
For a SQL-script release, keep the same verified connection, database, authentication and network inputs, but replace the DACPAC-specific deployment inputs with:
deployType: 'SqlTask'
SqlFile: '$(ReleaseSqlScriptPath)'
Remove the DACPAC-only DeploymentAction and DacpacFile inputs. Change the preflight to check the actual approved SQL script and its approved hash. Do not run both variants against the same target unless that is the separately reviewed change.
Neither mode establishes transactionality or a universal reverse migration. Review the proposed change, compatibility and data protection before execution. If an earlier attempt may have partially changed the database, inspect the actual state before retrying.
Use Bash through its verified existing interface
A reviewed Bash script can replace the preflight where the selected Windows agent already has a compatible, validated Bash interface. It does not make the SQL task Linux-compatible. Keep the job on a supported Windows agent for this SQL route.
For example, the owner may already provide a reviewed release/preflight.sh that checks the release contract and exits nonzero on failure. A bounded calling step is:
- bash: |
if [ ! -f "$RELEASE_INPUT" ]; then
exit 1
fi
if ! bash release/preflight.sh "$RELEASE_INPUT"; then
exit 1
fi
displayName: 'Run the reviewed release preflight'
env:
RELEASE_INPUT: $(ReleaseSqlScriptPath)
This is an alternative to the PowerShell preflight, not an extra deployment method or a supplied implementation of that workload-specific script. The script's existence, reviewed content, expected inputs and exit-status contract are required inputs. If they are missing, establish them before using this branch.
Inspect script behavior as carefully as task inputs. A script that catches an error and returns success can defeat the intended stop behavior. Do not insert untrusted event text into executable code or add credentials to compensate for a failed preflight.
Add the container deployment variant
For the container route, append the following task after the database step in the same job. Select an existing nonproduction slot and an exact owner-approved image reference that the target can retrieve.
- task: AzureWebAppContainer@1
displayName: 'Deploy the selected container'
inputs:
azureSubscription: 'release-nonproduction'
appName: '$(ContainerAppName)'
deployToSlotOrASE: true
resourceGroupName: '$(ReleaseResourceGroup)'
slotName: '$(ReleaseSlotName)'
containers: '$(ReleaseImageReference)'
This task targets App Service, not every container platform. Its reference explicitly warns that an incorrect image can fail to produce a task error. Inspect the target's container/deployment logs and actual running image, then verify the workload. A green task alone is insufficient.
The new application must be compatible with the database state just applied. If it is not, changing task order without a compatibility design is not a safe fix. Stop and have the application and database owners agree on a supported transition.
Use the packaged-application alternative
For an existing supported Windows App Service target, replace the container task with this package task:
- task: AzureWebApp@1
displayName: 'Deploy the selected application package'
inputs:
azureSubscription: 'release-nonproduction'
appType: 'webApp'
appName: '$(PackageAppName)'
deployToSlotOrASE: true
resourceGroupName: '$(ReleaseResourceGroup)'
slotName: '$(ReleaseSlotName)'
package: '$(ReleasePackagePath)'
deploymentMethod: 'zipDeploy'
Use one verified compatible package at the exact selected path. Do not use a broad wildcard that could select an older build. This route assumes a package layout supported by the chosen deployment method; the task's troubleshooting guidance distinguishes incompatible MSBuild package layouts.
A Linux App Service target uses a different appType and applicable runtime/deployment settings. Check that actual variant rather than transferring every Windows input unchanged. A package upload result still does not establish that the expected application started or can use its dependencies.
Verify the workload and prove the stop behavior
Append the existing owner-reviewed verification script after the chosen application task. In this illustrative PowerShell interface, the script must raise a terminating error when verification fails; any native commands it invokes must have their exit codes handled explicitly.
- powershell: |
$ErrorActionPreference = 'Stop'
& '.\release\verify-workload.ps1'
displayName: 'Verify the selected workload'
Before using this step, verify the actual script and its established target inputs. It must check the intended nonproduction workload, expected release identity and meaningful behavior. A generic request to an arbitrary endpoint or a script that merely prints success is not a replacement.
Observe error rate, dependency behavior and representative usage over the agreed period. No errors in an idle application do not prove a release healthy. Keep the target's actual release and database state in the evidence alongside the run and source identities.
The examples add no continue-on-error or unconditional downstream deployment override. Preserve the existing pipeline's reviewed failure behavior and verify it with owned negative cases before relying on this release route:
| Case | Expected evidence and response |
|---|---|
| Missing or wrong release file | Preflight fails; database and application changes do not start |
| Database authentication or approved-network failure | Actual task failure and stopped application deployment; do not widen access as a workaround |
| Database change rejected | Preserve diagnostic/state evidence; inspect whether any change occurred before deciding to retry |
| Wrong container reference | Inspect target logs and image identity even if the task appears successful; do not advance exposure |
| Package deployed but behavior unhealthy | Verification fails and further exposure stops; task color does not override workload evidence |
| Verification script reports failure | The job's actual result and later-step behavior demonstrate the stop contract |
| Interrupted job | Determine which operations completed, whether temporary firewall changes remain and whether recovery is required |
These are expected tests for an authorized nonproduction exercise, not outcomes observed here. Do not deliberately break a shared credential or network rule to simulate failure. If a safe negative case cannot be performed, record the unverified behavior.
Resource-owner approval remains separate. Azure checks are configured on consumed resources outside author-written pipeline YAML. A job graph alone cannot award approval. GitHub Actions also has its own dependency, token and environment-protection behavior, with feature availability and bypass conditions; do not paste Azure tasks into a GitHub workflow or claim identical enforcement.
Handle a hotfix and recover a compatible workload
When health deteriorates, stop further exposure and preserve the failed run's identities and logs. Identify whether the fault is in the image/package, configuration, database change or dependency before selecting a recovery action.
For a hotfix, select a new reviewed artifact and record the emergency approver and any accelerated checks. The safe-deployment guidance allows defined emergency adjustments, not unrecorded removal of controls. Preserve omitted or accelerated verification as follow-up work rather than describing it as completed.
For application recovery, first verify that the retained known-good artifact remains compatible with the current database and configuration. Redeploy through the same verified target and authorization boundary, then repeat workload verification. A successful redeployment is an intermediate observation, not the end of recovery.
Existing App Service slots can support a separately approved swap or swap-back procedure on supported tiers. Review slot-specific settings, connection strings, network behavior and the actual source/target. Swapping application content does not reverse external database state. Do not initiate a swap merely because this task example uses a slot.
If data compatibility is uncertain, stop automatic rollback and obtain the database owner's recovery plan. Recovery may require an approved roll-forward change or a separately validated data-recovery operation. Do not promise that rerunning an older DACPAC restores lost data.
Retain the release manifest, database change identity, observed target state and recovery evidence for the needed window. Azure pipeline-run deletion removes associated logs and artifacts; it does not govern package-feed retention. Check that image, package and other deployed dependencies remain available under their own retention policies.
Restore only owned exercise changes and verify the original valid workload again. Report any remaining temporary rule, unhealthy dependency or incomplete check. Recovery is complete only when the actual agreed workload and data conditions are verified, not when the last task turns green.
Authoritative Sources
- Key Azure Pipelines concepts — Jobs, scripts, stages, steps and artifact boundaries.
- Azure Web App for Containers v1 — Existing target/slot and image inputs, requirements and incorrect-image warning.
- Azure Web App v1 — Package variants, connection/slot inputs, deployment methods, troubleshooting and variant requirements.
- Azure SQL Database deployment v1 — Authentication, DACPAC/SQL-script inputs, Windows/private-agent/tool requirements and firewall options.
- Safe deployment practices — Workload health, failure response, stateful recovery and emergency protocols.
- App Service deployment slots — Supported scope, slot-specific settings and swap/recovery behavior.
- Azure pipeline retention — Run-related evidence deletion versus package retention.
- Azure pipeline approvals and checks — Resource-owner admission outside pipeline YAML.
- GitHub Actions workflow syntax — Distinct job dependencies and token scope.
- GitHub deployments and environments — Conditional protection, secrets and bypass behavior.

