Learn how to create, save to the Azure library, and download templates, which can be customized, using existing deployments in the Azure portal.
- [Instructor] I am going to show you how we create a template from an existing deployment. As you can see, I've already logged into Azure and I have three resource groups available. I have our LoadBalancing, our SimpleVM, and our VirtualNetworks. We're going to go ahead and take a look at the LoadBalancing resource group. In the overview, you are going to notice that we have several resources deployed to this resource group. We have a couple availability sets, we have several Vms, we have some networking, and we have load balancing as well, some IP addressing.
It took some time to provision this resource group manually, but what if we could go ahead, take this resource group and then convert this to a template? And that is easy to do, using the automation script. For this demonstration, what I'm going to do is flip over to the SimpleVM resource group only because it's smaller and it'll deploy a lot faster than having to go through several availability sets, several VMS. So I'm going to click on SimpleVM and you'll notice our resources here are seven items.
That is it, I created a simple network using the default, and I created an A1 virtual machine again using the default. To create a template from this, I'm going to go ahead and click Automation script and you'll notice here we have our Template, this is our JSON file, we have the Parameter file if we opt to use a separate parameters file, for those of you who like command line interface, or CLI, we also have two options there for you, the CLI and the CLI 2.0 which is currently in preview.
We have a PowerShell script, you can also use .NET and Ruby. For our purposes today, we're going to go ahead and work within Template. I can go ahead and add this to the Azure library that way it will always be available to us for deployment. I'm going to go ahead and provide a name and I'm going to add a description and then click Save.
We could go ahead and deploy this template right from here, if we click Deploy, and we can also download the template, which is what I'm going to do. I'm going to go ahead, click Download. The download will be a zip file. I'm going to go ahead and extract that zip file and I'm going to extract it to our Exercise folders. We now have that template local, now we can go ahead and manipulate it.
To do so, I am going to click Template, this is going to open up Visual Studio, the Community Edition which is a free downloadable version, and from here I can go ahead and manipulate our template file. You will see our schemas here, our content version, and then all of our parameters. When you're doing this, you'll probably want to convert most of these parameters into variables and provide new names. You'll notice here, that for our network interface, our default value for that network interface will be simplevm565.
Like I said, you'll probably want to convert these to variables and manipulate them. Within the resources section, we have the details for our resources that we used for this deployment. The first one I'm going to point out here will be our virtual machines and then we have the details about our virtual machine, its location, the API version, the name. As we scroll down, we'll see we have our network resource as well. I'm going to go ahead and change our virtual machine from the Standard_A1 to a Standard_A2.
And I'm going to go ahead and save this file. We'll be using this a little bit later on for some additional demos. Downloading the templates and manipulating them is a great way to become familiar and comfortable using JSON files for your template. There's a lot of information here and if you have to type it manually, I can almost guarantee that you're going to start to hate this process. Typically what I've found is Azure admins will download the templates that most closely replicate the environment that you're trying to create and then edit the template accordingly.
This tends to be the easiest and fastest way.
- Implementing Azure Resource Manager templates
- Creating a template from a deployment
- Deploying a template using the portal
- Deploying a template using PowerShell
- Using Azure Quickstart Templates
- Using service principals
- Locking Azure resources
- Securing Azure subscriptions
- Azure active directory roles
- Designing custom RBAC roles