I found myself recently working on ARM (Azure Resource Manager) templates using Visual Studio 2019 and it was slow going looking up samples, cross referencing properties, etc. This was taking a lot of time so I decided to do some digging to see if there’s a better way – here’s what I discovered!
Tools
There’s definitely been changes in the tools for authoring ARM templates, VS Code in particular has jumped forward in their support!
- VS Code: This is probably the best experience I’ve seen to date. There’s an extension that provides an outline experience, has autocomplete/intellisense, and even some snippets & template validation. More info here: https://danielpaulus.com/arm-templates-with-visual-studio-code/
- Visual Studio: There’s a type of project, “Azure Resource Group”, that enables you to author ARM templates. More info here: https://docs.microsoft.com/en-us/azure/azure-resource-manager/vs-azure-tools-resource-groups-deployment-projects-create-deploy . There’s some very basic templates (not as useful) but once you get to the editor, there’s an outline view, template validation and you can publish them directly to Azure from Visual Studio.
- Notepad++ (and other text editors): You get highlighting (if you use “JSON” as the file type), but not much more than that…
- PowerShell: It’s good to use PowerShell to deploy the template once you think it’s right. I typically do this as an ‘iterative development’ for the ARM template by deploying the template to the same resource group until everything works the way I expect, and then deploy to a new resource group to confirm I didn’t miss anything. You can do this using the New-AzResourceGroupDeployment commandlet…
Resources
The tools gets you part of the way there, but we need docs and samples to figure out the rest! Here’s some resources I typically use when creating ARM templates:
- Azure Quickstart Templates: This is a great resource that’s kept up to date by the various azure teams. It has tons of various examples on ARM templates for deploying resources to Azure. Link here: https://azure.microsoft.com/en-us/resources/templates/ .
- Azure Portal: If you have the resources deployed in Azure, you can always go to the resource group and export the ARM template. This is typically verbose – it contains every single property & setting and isn’t typically generalized to reuse, but it gives you a good starting point on the overall structure & what’s needed. More info here: https://docs.microsoft.com/en-us/azure/azure-resource-manager/export-template-portal
- Azure Resource Explorer: This is another way to get the ARM template (and all Rest API info) for resources in Azure. It’s a preview (not in production) but it’s pretty useful as a reference. It’s essentially the same info you would get when exporting the template from Azure https://resources.azure.com/
- Azure Docs: if you have any question on a particular resource, the Azure docs typically have good information about the template structure. Here’s an example for Azure Functions: https://docs.microsoft.com/en-us/azure/azure-functions/functions-infrastructure-as-code
If you have any other tools & resources you use, please comment below!