1. Home
  2. Training Library
  3. Microsoft Azure
  4. Courses
  5. Introduction to Azure Resource Manager

Demo: Deploying ARM JSON Templates

The course is part of these learning paths

AZ-103 Exam Preparation: Microsoft Azure Administrator
course-steps 15 certification 6 lab-steps 9
AZ-203 Exam Preparation: Developing Solutions for Microsoft Azure
course-steps 20 certification 1 lab-steps 7
AZ-301 Exam Preparation: Designing a Microsoft Azure Architecture
course-steps 14 certification 7 lab-steps 3
Architecting Microsoft Azure Solutions
course-steps 10 certification 6 lab-steps 5
Developing, Implementing and Managing Azure Infrastructure
course-steps 10 certification 7 lab-steps 2
more_horiz See 3 more
Start course
Duration1h 30m
star star star star star-half


The easiest way to get started with deploying an Azure Resource Manager (ARM) JSON Template, is to grab a precreated one off of the Azure Quickstart Templates repository on GitHub. In this video demonstration, we will find a template that defines the following resources: a Virtual Network, Network Interface, Public IP Address, Storage Account, and Virtual Machine. We'll use the Azure Cross-Platform (xPlat) CLI Tool to deploy this template, and specify the input parameters that will be used during deployment.


Hello and welcome to this demonstration of using the Microsoft Azure Cross Platform CLI Tool to perform a deployment of an Azure Resource Manager JSON template

The first thing we're going to do is take a look at the command that we need to use to deploy the template. So I'm going to call the Azure command here. And as you'll see, we have a command, its sub-command, that allows us to manage resource groups in Azure. So I'm going to call Azure group and you'll see that I have the option to create a new resource group. So let's go ahead and just create the resource group so that we can deploy the template into it. If I type azure group create --help, this is going to give me all of the parameters that I can use to create a resource group. Now you'll notice some similarities between the parameters for creating the resource group itself and the deployment commands that we're going to use in a moment. But be aware that there's a separate group command to create a group and then a separate command to create a deployment inside of an empty Azure resource group or an Azure resource group that already has some resources inside of it. So that command, if we run Azure Group again, is called Azure Group Deployment Create. So we have two choices. We can either create a resource group and immediately perform a deployment or we can create an empty resource group and then create a deployment inside of it. But to demonstrate the difference between these two commands, we're going to separate the creation of the Azure resource group with the creation of the deployment. So again, let's just arrow up to our previous command for creating an Azure resource group. And you'll see that we have the option to specify a name and location. So if I call Azure Group Create --name CloudAcademyARMJSON, and then I'm going to give it a location of West US.

So that command is going to go out to Azure and create an empty ARM resource group in the West US region. We now want to deploy an Azure Resource Manager template into that resource group. So let's take a look at how to do that. I'm going to go ahead and find a template in the Azure Quick Start Template GitHub Repository and I'm going to go ahead and grab the azuredeploy.json file and go to the raw view of that file. Now I'm going to go ahead and grab this template URI and we're going to use that in our deployment command. So let's call Azure Group Deployment Create - Help and see what we need to specify. So we first need to tell it what resource group we're going to deploy into. We can optionally specify a name for the deployment. We can either specify a template file that we have locally or we can use a template URI so that we can simply point Azure Resource Manager to a publicly accessible URL. And then we also have to specify input parameters for the ARM JSON template and we can do that using the "--parameters" or if we have a file on our file system, we can do "--parameters-file". So let's go ahead and fill this command out. So I'm going to call azure group deployment create --template-uri and then paste in my template URI. Actually I had a bug there. So let me call azure group deployment create --template-uri and then I'm going to switch over to my browser, do a Command C on Mac to copy that template URI and then do Command V to paste it into my console.

Now I also have to specify this parameters file. And inside of the quickstart template repository here, we actually get a template parameters file that we can simply fill out and utilize. So over here in Visual Studio Code, which natively supports JSON files, I'm going to hit Command N to create a new file. I'm going to paste the contents of this parameters file and then I can modify it. So I'm first going to hit Command S to save the file. I'm going to call this azuredeploy.parameters.json and save it to the local file system. So the next thing I need to do is fill out the actual parameter values that are getting fed into this template. So the storage account name, I'll call CloudAcademyARMJSON. The admin user name for the virtual machine that's going to be deployed, we'll call CloudAcademy. The password for that account, we'll call P@ssw0rd like so. And then finally we need to specify a DNS name for the publicly phasing IP address so that we can access that virtual machine using a DNS name. So let's just call this, for consistency, CloudAcademyARMJSON. I'm going to hit Command S to save that file to the local file system. And I can now come back to my Bash shell and type --parameters-file ~/AZ105/. Oh, let me go find that file really quick. So I'm just going to type out the full name here because tab completion isn't currently cooperating with me.

And then finally, I need to specify the resource group that we're going to deploy to. And if you remember from earlier, we created a resource group called CloudAcademyARMJSON. So I'm just going to go ahead and copy and paste that. And finally I'm going to hit the Enter key to confirm that command. And you can see that the Azure Cross Platform CLI Tool is now going out to my subscription and performing a template-based deployment using the template that I fed it from the template URI. It's feeding in the parameters from the local parameters file and it's going to deploy that entire template into the resource group called CloudAcademyARMJSON. Once the deployment has completed, we'll come back in a moment and take a look at the resources that have been created. Okay, so as you can see, we've gotten a timeout error, which is okay. It just means that the Azure Cross Platform CLI tool has lost its connection to the Azure platform while waiting for the ARM template deployment to succeed. So what we can do to check on the status of the deployment is call Azure Group Deployment. And then if we just hit Enter, we'll look at the Help here. And so I can do Azure Group Deployment Show and specify the resource group that I want to show the status of the deployment for. So a deployment object is actually a member of the resource group. So by passing in a resource group as the parameter, we're telling the Azure platform that we want to get a list of all the deployments inside of that resource group and their current status. So let's do Azure Group Deployment Show and then we will pass in the name of our resource group. So when we call this command, you'll see that we get the provisioning state of running, which means that it's still in process. And the other thing that you'll notice is that we get back a list of all the input parameters that we specified as part of the parameters file. So the new storage account name, the admin username, password, and DNS name for public IP were all specified by us inside of this parameters file.

So again, we'll come back in a couple of minutes when this is finished and take a look at the resulting resources.
Okay, we're going to rerun our Azure Group Deployment Show command. And as you can see, the provisioning state has changed to succeeded. So now that the deployment is succeeded, we can connect to the virtual machine and manage it. So the built-in parameter Windows OS version basically predetermined that this virtual machine is going to run a Windows Server 2012 R2 data center image. So when we RDP into the system, we should have a brand new Windows Server 2012 R2 system. So let's go ahead and run the Microsoft Remote Desktop Program. And we're going to go ahead and add a new connection. So we'll call the connection name CloudAcademyARMJSON. The computer name is cloudacademyarmjson.westus.cloudapp.azure.net. And we'll pass in the username, which is, I'm sorry, CloudAcademy, and the password that we specified inside the template. So we'll go ahead and just close this window and double click that connection to connect to it.
So I'm going to go ahead and do a show command on the virtual machine.

And the virtual machine is my simple VM. So let's do Azure VM list. And the VM is actually called MyWindowsVM. So let's go ahead and run that. And you'll see that the FQDN is actually cloudacademyarmjson.westus.cloudapp.azure.com. So we're going to come back in here and edit our file, RDP file, to connect to cloudacademyarmjson.westus.cloudapp.azure.com. So now that we've corrected that DNS name, you'll now see that we get the certificate error, that's from self-signed certificates, and we'll go ahead and connect to that system. So we're currently RDP-ing into our brand new Windows Server 2012 R2 virtual machine that we provisioned using an Azure Resource Manager template. So you can see how easy it is to get up and running very quickly with the Resource Manager API. So that system is going to go ahead and get logged in there. The desktop is coming up just now. But I want to show you one other command. Once you're finished with the virtual machine, if you're just using it for development or test purposes, you might want to remove it so that you're not billed for the additional cost of running that virtual machine. So in that case, we'll run the Azure Group Delete command. We'll do help on that command and you'll see all we have to do is specify the name parameter, which is CloudAcademyARMJSON, and then add --quiet so that it doesn't prompt us for confirmation. So let's go ahead and just take a look at that system. So there it is. We've got a Window Server 2012 R2 system. If we tap on the Windows button, you'll see we've got all of our default Start menu items in there and we can begin configuring the server as normal.

So let's switch back over to our desktop. So let's say that we're finished with that virtual machine now and we no longer need it. We're just going to go ahead and run this Azure Group Delete command and that's going to clean it up. But before we do that, I want to really quickly show you the virtual machine inside the Azure portal. If we come out to the Azure portal and select resource groups, we can see a list of all the resource groups in our subscription. So as you can see, we have a resource group here called CloudAcademyARMJSON and these are all the resources that were provisioned into it as part of the ARM JSON template that we deployed. So we have a virtual machine, a network interface, a public IP that's bound to that network interface, and that network interface is bound to the virtual machine. We also have a virtual network that the machine's been deployed inside of. And finally we have a storage account, which provides the backing storage for the virtual machine's VHD file. So we could manage our resource group through the Azure portal. But when you're scaling out, it's much more efficient to utilize automation through either Windows PowerShell or the Azure Cross Platform CLI Tool if you don't have a Windows machine accessible. So let's go ahead and hit Enter on this delete command here. And you'll see that the resource group is going to get deleted from our Azure subscription. This process can take a couple of minutes, so don't expect immediate results. But once that resource group is deleted, you won't be billed for any of the resources that are inside of that resource group any longer.

About the Author

Trevor Sullivan is a Microsoft MVP for Windows PowerShell, and enjoys working with cloud and automation technologies. As a strong, vocal veteran of the Microsoft-centric IT field since 2004, Trevor has developed open source projects, provided significant amounts of product feedback, authored a large variety of training resources, and presented at IT functions including worldwide user groups and conferences.