Azure deployment script fails partway
The three causes we see most often, and how to make the script fail loudly instead of quietly.
Draft. The fix is known and correct, but we're still writing up the full step-by-step.
Causes we’ve seen
- VM size unavailable in the region, or capacity restricted for the subscription. Check with
Get-AzComputeResourceSkufor the region. - Resource providers not registered on a new subscription (for example
Microsoft.Compute,Microsoft.Network,Microsoft.DesktopVirtualization). Register them withRegister-AzResourceProvider. - Later steps skipped silently, because the script stopped on the first error and the output scrolled away.
Make it fail loudly
- Set
$ErrorActionPreference = "Stop"and wrap each stage intry/catchthat prints which stage failed. - Check prerequisites (providers, SKU availability, quota) before creating anything.
- Make steps idempotent, so you can safely re-run the script after a fix.
This guide is being expanded with full steps.
Seeing this in your environment?
We can check for this, and everything around it, as part of an audit.