Skip to content

Latest commit

 

History

History
68 lines (44 loc) · 5.04 KB

day.56.tshoot.arm.md

File metadata and controls

68 lines (44 loc) · 5.04 KB

Day 56 - Troubleshooting Azure Resource Manager (ARM) Template Deployment

If you are deploying ARM templates via Azure Pipelines, the Azure Portal, or PowerShell, it pays to know the basics of the types of errors you may get, where to find the error messages, and how to interpret them. Below are the resources you need to master Azure Resource Manager deployment errors no matter which deployment method you use.

In this article:

ARM Deployment Error Types
Finding error details in the Azure Portal
Enable debug logging in PowerShell
Debugging in VS Code
Finding error details in the Azure Portal
ARM Error References and Tutorial


SPONSOR: Need to stop and start your development VMs on a schedule? The Azure Resource Scheduler let's you schedule up to 10 Azure VMs for FREE! Learn more HERE


ARM Deployment Error Types

There are important differences between template validation error, and a template deployment error. A template validation error means there is a problem with the syntax or layout of your deployment template, which prevents the deployment from starting. A template deployment error means that your template syntax has been approved, but an error has occurred while provisioning the resources.

Both types of errors return an error code you can use to troubleshoot the deployment. Both error types appear in the Azure Activity Log. However, validation errors don't appear in your deployment history because the deployment never started. If you use the template deployment in the Azure portal and your template is invalid, you'll see an error like that shown in Figure 1 when you click the purchase button:

001 Figure 1. ARM Template Validation Error

Finding error details in the Azure Portal

If you have a conflict not caught in the pre-flight check, you can find the error in the properties of the failed deployment or the Azure Activity Log. To get to the Activity Logs

  1. Sign in to the Azure portal.
  2. Select Monitor > Activity log.
  3. Use the filters to find the log.

Enable debug logging in PowerShell**

Sometimes you need more information about the request and response to learn what went wrong. During deployment, you can request that additional information is logged during a deployment.

In PowerShell, you can set the DeploymentDebugLogLevel parameter to All, ResponseContent, or RequestContent. For troubleshooting, set -DeploymentDebugLogLevel All

New-AzResourceGroupDeployment `
 -Name MyArmDeployment `
 -ResourceGroupName MyArmResGroup `
 -TemplateFile c:\scripts\ArmTemplates\storage.json `
 -DeploymentDebugLogLevel All

Debugging in VS Code

If you load the Preview version of Azure Resource Manager (ARM) Tools for VS Code, you can troubleshoot ARM template deployment directly in VS Code. According to the extension documentation, the new language server now has a better understanding of Azure Resource Manager templates and can therefore provide a better error and completion experience beyond that provided using standard JSON validation, and:

  • Narrows down its schema validation based on the resource type and apiVersion properties of each resource.
  • No longer suggests changing the resource type if the apiVersion is not supported, or if a property is missing or invalid (as tools using standard JSON validation would do)
  • Errors provide better guidance for what actually needs to be fixed in each resource to match the schema

ARM Error References and Tutorial

Here are the key additional resources you should review to master troubleshooting ARM template deployment, including a step-by-step tutorial simulating an ARM deployment error.

Conclusion

Hopefully this gives you the resources you need to get comfortable with ARM deployment troubleshooting in a shortest possible time. Have a tip that's helped you troubleshoot ARM deployments? Leave a comment below.