Deploy Resources to Azure With Azure Resource Manager (ARM)

In this blog post, I will show you how to deploy resources to Azure Resource Manager (ARM) and get into the learning of Infrastructure as a code.

In my previous blog post, I explained why you should start using ARM, but in a nutshell, ARM gives the ability to be more consistent with our deployment and have a record of them in a readable format that allows us to review at any point in the future without the need to reverse engineer what was done.

In this post I will use Azure Cloud Shell and VS Code, so make sure you have both.

VS Code extensions

To get started with the right tools. You will need the following two VS Code extensions the are listed below.

  • ARM Tools
  • Azure Account
Azure Resource Manager (ARM) Tools 
Microsoft I 421,904 | I Repository License 
I vo.12.o 
Language server, editing tools and snippets for Azure Resource Manager (ARM) template files. 
rhÉ extension is enabled globally. 
This extension is recommended based on the files you recently opened. Ignore Recommendation 
Details Feature Contributions Changelog Dependencies 
Azure Resource Manager (ARM) Tools for Visual Studio Code (Preview)
Azure Account 
Microsoft Repository License 
A common Sign-ln and Subscription management extension for VS Code. 
rhis extension is enabled globally. 
Feature Contributions Changelog 
Azure Account and Sign-ln 
The Azure Account extension provides a single Azure sign-in and subscription filtering experience for all 
Shell service available in VS Code's integrated terminal. 

Create a JSON file

After installing the extensions, I will create a .JSON file called sample.json which I will use for my first deployment.

After creating the file, I will open it and start typing ARM as shown belo and will select the the first option (arm!).

This will bring up an ARM template.

Below you can see the ARM template that was loaded by the ARM extension.

Create a MySQL Database

Let’s go ahead and create a MySQL database in Azure. In the resource, section starts typing my, and you will see the arm-MySQL option. You can start writing any service you would like to deploy, and you will see its template.

After selecting the MySQL option, The template will load the MySQL configuration. I will go ahead and rename the name and set the admin username and password.

Deploy Template using Azure Cloud Shell

To make this process a bit easier, I will use Cloud Shell to deploy the template. I will log in to Cloud Shell and use the PowerShell console, as shown below.

After login in I will run the following cmdlet which will create a new resource group for the deployment named ARMDemo1.

New-AzResourceGroup -Name ARMDemo1 -Location southeastasia

Next, I will upload the template file to Cloud Shell using the upload button on the top Shell screen of creating a new file and copy-paste the template.

Below, is the deplyment cmdlet which will deploy the MySQL database to Azure.

New-AzResourceGroupDeployment -Name Deploy001 -TemplateFile ./sample.json -ResourceGroupName ARMdemo1 -Verbose

After a minute or two the MySQL database will show up in the Azure resource group.

To remove the deployment you can use the following cmdlet.

Remove-AzResourceGroupDeployment -ResourceGroupName ARMDemo1 -Name Deploy001