Learn how to edit an existing JSON template using Visual Studio and then deploy the template using the Command Line Interface.
- [Narrator] We can also deploy templates using the command line interface. We're going to go ahead and create another resource group with our virtual machine and networking using the command line interface. We're going to call it SimpleVMRev5. I know, not very creative. I'm going to go back to our exercise files folder, and we happen to be in chapter 01_05, and you'll notice here that I have a text document, and I have our json template.
As before I have copied over the json template, but in this case I have actually made some changes to the parameters. You could use a separate parameters file if you wish to do so. In this case, I've opted to keep it simple, and edit the parameters within the template file. One thing you'll notice here though, I do have to provide a password. So I am providing our super secret password. Everything else has been modified to include rev five.
If you'll notice here, we have rev five and SG, rev five IP. We're keeping simple network the same because it will be deployed to a different resource group. I'm going to go ahead and save that and make sure it's okay. And go ahead and close down Visual Studio. Next we're going to go ahead and open up the Notepad file. You will see from our Notepad file, this is a very simple setup. We're going to log into Azure. We're going to set our subscription based on our subscription ID. We're going to go ahead and create a new resource group called SimpleVMRev5, and then we're going to go ahead and actually deploy the template itself, with the exception of I need to change my resource group to match my name.
And I'm specifying my template file, and in this case, I actually have an error here, because I'm pointing it to the wrong folder. So I'm glad I caught that. There we are. Now I'm going to go ahead and launch Command Prompt. Yup, good old Command Prompt, nothing fancy here, and I am going to run it as admin. I'm going to right click, run as admin. If you happen to receive a dialog box asking are you really sure you want to run as administrator, go ahead and click yes.
And then I'm just going to simply enter in the commands. Some of these I'm going to type, some of them I'm going to copy paste. You may encounter this issue when you log in using the command line interface. If you see this what you will do is open up the webpage, aka.msdevicelogin, and then you're going to enter in the code that is provided to you. So in another browser, I'm going to go ahead and enter this information. So this is the page I'm directed to.
You'll have to enter in your code, and then we can go ahead, click continue. We can see we already signed in. I'm going to go ahead, click on my account. I'm already signed in, so now I should be able to close this window, and we can see that we are now logged in via the command line interface. The next thing I need to do is set my subscription, and to do that I'm going to go ahead and just copy everything.
Go ahead click enter. We can see that the account has now been set to pay as you go. Our next step is to go ahead and create that resource group. We're going to do it in the East US again, and I'm just going to do a copy paste here. The command is Azure group create our SimpleVMRev5 in the east US. Perfect, it is now created, and we can continue on.
And finally, our last command, and I'm just going to copy and paste it and we'll step through it once it's pasted. The command is Azure group deployment create. We're going to create it within this resource group as SimpleVMRev5, the one we just created that will provide the path to our template file. So this is on our desktop in the exercise files in chapter 01_05 and it's the template, the json file. Go ahead hit enter, and then this will take several minutes to create as well.
So this would be a great time to go grab a cup of coffee. After several minutes, we can see that the template deployed to Azure, and one thing I want to point out here is you'll notice that incremental was the mode. Remember that incremental is the default mode when deploying templates. Let's go ahead, pop into Azure, and take a look at this. I'm going to go ahead and refresh, and then we should see SimpleVMRev5, and there we are. I also want to point out that you'll notice that another resource group has been created here, and this has to do with an existing storage group that I do have sitting in the background.
So every so often you'll see this pop in. Nothing to worry about. Let's drill into SimpleVMRev5, and as before, we have all of our resources within that resource group ready to go. As you can see, whether or not you use PowerShell, command line, or even the rest API for you developers out there, the process is very similar, and simpler, to create custom templates to redeploy your resources over and over again.
- 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