Authoring ARM Templates in Visual Studio Code
If your writing ARM templates for Azure you’ll have found that the amount of tooling available for authoring templates is fairly limited. The default solution seems to be Visual Studio but this can be very heavyweight and resource intensive without gaining any of the real benefits of VS such as debugging. I’ve recently switched over from using Visual Studio to use Visual Studio Code, for a much more light weight experience. Whilst there still could be significant improvements to the tooling available for authoring ARM resources, I’ve found it to be a fairly enjoyable experience.
For those that don’t know VS code is a light weight, multi platform, open source editor based on the Electron Framework. VS code supports syntax highlighting, code completion, snippets etc. but one of it’s big benefits is it’s extension architecture. Due to the open nature of the platform, it has lead to a big repository of extensions, and in particular there are some great extensions for authoring Azure deployment recipes. Given that, here’s what I’ve got running in my editor at the moment, hopefully if your new to VSCode this might help you get going, and if your already using it I’d love to hear any suggestions!
Git
VS Code supports Git out of the box and provides controls for committing code right in the editor, but you do need to actually install Git for Windows, or the appropriate version for you platform, on the machine for it to work.
Azure Resource Manager Tools
The most important plugin for ARM Template development, this adds language support for ARM templates to give you Intellisense, Syntax Highlighting, In-line help and many other language functions.
ARM Snippets
Since writing this article I’ve changed snippet providers and now recommend you look at using the snippet file from the cross platform toolkit. See here for details
(https://i2.wp.com/res.cloudinary.com/samcogan/image/upload/v1489091583/Snippets_ubuido.png?resize=128%2C106)
Produced by Art Of Shell, this is a set of pre-defined snippets for ARM templates, it’s not a huge selection, but there are some very useful ones for parameters, storage and networks, and you can always add your own on top. To activate the snippets make sure that your in a JSON file then either start typing ARM, or press ctrl-shift-p to bring up the command pallet and go to Insert Snippet. Obviously you can build on these and add your own snippets too.
Azure Tools for VS Code)
A set of utilities to undertake actions in Azure directly from VS code, this includes:
- Create a Web App
- Creating a Batch Account
- Creating a Function
- Deploying an ARM Template
- Export a resource group to a template
- Get a storage account connection string
- List Azure Subscriptions
The ability to deploy your templates and to export a resource group are particularly useful.
PowerShell
Chances are that if your writing ARM templates your also writing or using PowerShell either in scripts as part of your deployment, or with PowerShell DSC to configure your VM’s once deployed. This plugin adds language support for PowerShell (including DSC) so that you can get Intellisense, Code Completion etc.
Code Runner
This handy plugin lets you execute code from inside VS Code It supports many languages, but I’ve found it most beneficial for running PowerShell.
Settings Sync
It’s pretty annoying to get your editor all setup how you want, then have to do it all again on another machine. Settings Sync lets you sync your settings, snippets and extensions across multiple machines.
Themes
There are a huge number of themes to change the visual aspects of your editor, and which you go with is really going to come down to personal preference. I’m currently running:
– vscode-icons to add icons to my explorer window
– One Dark Theme
But who knows what I might change to tomorrow…