Template Validation and What-If Operations
You'll learn how to safely check your ARM templates for errors and preview changes before deploying them to Azure.
Why Validate Before Deploying?
Imagine submitting a building permit with architectural errors—the city would reject it, costing you time and money. Similarly, Azure ARM templates can contain syntax errors, invalid resource configurations, or unintended changes. Instead of discovering these mistakes during deployment (when they could break production), you can validate and preview beforehand.
Template Validation
Validation checks your template's JSON syntax and ensures all resources use valid API versions, required properties, and proper parameter types. It catches mistakes like typos in resource names, missing dependencies, or incorrect property values.
When you validate via CLI or Portal, Azure checks the template structure without actually creating resources. Think of it as a spelling and grammar check before publishing a document.
What-If Operations
What-If goes one step further—it shows you exactly what will change when you deploy. Azure compares your template against the current state of your resource group and produces a report:
- Green (+): New resources to be created
- Orange (~): Existing resources to be modified
- Red (-): Resources to be deleted (in Complete mode)
- No change: Resources that remain untouched
This is like having a preview button before publishing changes to a website—you see the diff before committing.
When to Use Each
Use validation for quick syntax checks during development. Use what-if before every deployment to production, ensuring no surprises from unintended deletions or modifications.
Key Takeaway: Always validate template syntax and run what-if operations to catch errors and preview changes before deploying ARM templates to Azure.