Authoring ARM Templates in Visual Studio Code
Writing ARM templates for Azure? The tooling isn't very impressive. Fortunately, Visual Studio Code and assorted other tools add needed functionality.
Join the DZone community and get the full member experience.Join For Free
if you're writing arm templates for azure, you'll likely 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 heavy 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 lightweight experience. while 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 lightweight, multi-platform, open-source editor based on the electron framework. vs code supports syntax highlighting, code completion, snippets, etc., but one of its big benefits is its 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 you're new to vs code, this might help you get going, and if you're already using it, i'd love to hear any suggestions!
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 your platform, on the machine for it to work.
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.
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 you're in a json file. then, either start typing arm, or press ctrl-shift-p to bring up the command palette, then go to insert snippet. obviously, you can build on these and add your own snippets too.
it includes a set of utilities to undertake actions in azure directly from vs code, such as:
- 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.
chances are that if you're writing arm templates, you're also writing or using powershell — either in scripts as part of your deployment, or with powershell dsc to configure your vms once deployed. this plugin adds language support for powershell (including dsc) so that you can get intellisense, code completion, etc.
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.
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.
there are a huge number of themes to change the visual aspects of your editor, and which one you go with is really going to come down to personal preference. i'm currently running:
but who knows what i might change to tomorrow...
Published at DZone with permission of Sam Cogan, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.