Learn how to edit the previously downloaded JSON template using Visual Studio and then deploy the template using PowerShell.
- [Instructor] We've seen how easy it is to deploy templates using the Azure library. Now let's go ahead and reuse that same template to deploy using PowerShell. As you may recall, when I downloaded the template files, remember it was in the zip format, and I expanded it to our CH01_02 folder. For this demonstration, the only two files I actually need are template and deploy. Before I copy these over to our CH01_04 folder, I want to point out the parameters file.
I could bring this over as well, and I can manipulate all the parameters within this file. Again, for our demonstration purposes, I'm going to manipulate the parameters within the template file itself. Go ahead and copy these. You'll notice I already have these two files here. I'm going to go ahead and replace these files so we're looking at clean install files. Let's start off with the template file. I'm going to go ahead and open this. This will launch our Visual Studio Community Edition.
Here, we can go ahead and manipulate those parameters. We know that certain resources require unique names. Therefore, I'm going to add in rev4 into some of the resource names. This will take care of the naming. I'm going to go ahead and save this. Everything's green, good. We did modify this template at one point to a Standard A2. We're going to leave that as is. That's all we need to do here.
Next, we're going to go ahead and launch the deploy PowerShell script. To do so, I'm going to go ahead and launch ISE, or the integrated scripting environment, for PowerShell. I'm going to right click and then run as administrator. If you happen to receive a dialog box asking are you really sure you want to run as administrator, go ahead and click yes. I'm going to go ahead and open up the deploy PS1, which is in our CH01_04 folder.
We have some basic information about the script itself, and we'll notice here that we do have some parameters that we will be passing through as well. One thing I do have to change here is the template file location. I'm going to go ahead and add in the path for that file. I'm not using the parameters file, therefore, I can leave it. I'm going to go ahead, just do a quick save on that, and we'll continue to scroll through it, just to look at it a little bit.
Here, we can see we're going to sign in, we're going to select the subscription. The resources providers will be registered. We're going to go ahead and create a resource group. Finally, the deployment will start. Normally, when I work in ISE for demos, I like to step through each line of the script. In this case, I'm going to let the whole script run. The first thing I need is my subscription ID. You will need that from your Azure subscription. I already have mine handy, so I'm just going to do a copy and a paste for it. I'm going to go ahead, hit enter.
Now I need to provide my resource group name, and I'm going to call it rev4, again, to keep it consistent. My deployment name. I now have to log into Azure. Our resource providers have been registered now. Now I need to provide the location for our resource group. In this case, I'm going to pop it into the East US. Once the resource group has been created, we'll be prompted to provide the password.
This is the password for the virtual machine. It'll take a few minutes for the script to run. After several minutes, we can see that our deployment has succeeded. Let's go ahead, pop back into Azure, and take a look at it in a little bit more detail. You will notice we now have a SimpleVMrev4. I'm going to drill into that a little bit. We see all of our resources have been created once again. Again, we're using a very simple script here in order to demonstrate this.
You can see the power of using templates in Azure for your deployments.
- 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