Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Authoring ARM Templates in Visual Studio Code

DZone's Guide to

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.

· Cloud Zone
Free Resource

Are you joining the containers revolution? Start leveraging container management using Platform9's ultimate guide to Kubernetes deployment.

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!

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 your 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

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.

Azure Tools for VS Code

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.

PowerShell

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.

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 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...

Using Containers? Read our Kubernetes Comparison eBook to learn the positives and negatives of Kubernetes, Mesos, Docker Swarm and EC2 Container Services.

Topics:
microsoft azure ,cloud ,visual studio code ,arm templates

Published at DZone with permission of Sam Cogan, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}