Azure Cross-Platform Automation
Step-by-Step: Create a Virtual Machine with Azure xPlat CLI
During this course, we will take a look at the Microsoft Azure Cross-Platform (xPlat) CLI Tool. The Azure xPlat CLI is a Node.js application that enables you to automate many common tasks within Microsoft Azure. Microsoft is developing the Azure xPlat CLI as an open source project, which is hosted on GitHub. If you run into any problems, have questions about how the tool works, or need clarification in the documentation, you can register for GitHub, and post a new issue on the issue tracker, for the Azure xPlat CLI project. The Azure xPlat CLI tool works with both the newer Azure Resource Manager (ARM) and the classic Azure Service Management (ASM) REST APIs.
Some of the common tasks that you might perform with the Azure xPlat CLI are: deploying Azure Resource Manager (ARM) JSON Templates into ARM Resource Groups, deleting Resource Groups, starting or stopping Azure IaaS Virtual Machines, deploying or deleting Virtual Machines, resizing Virtual Machines on-demand, managing Virtual Networks, Subnets, Network Security Groups (NSG), VPN Gateways, custom Route Tables, and much more!
If you have thoughts or suggestions for this course, please contact Cloud Academy at email@example.com.
Okay, now that we have provisioned our virtual network and subnet, we next need to create our storage account. So let's call the "azure storage" command and take a look at the commands that allow us to create a storage account.
So let's scroll up a little bit here, and you'll see that we have a "storage account create" command. We can also delete and list storage accounts. We can also get the storage account keys to actually access the content within the storage account. But first, let's go ahead and call "azure storage account create." So "azure storage account create," and then we'll add "--help" to that.
As you can see, we have to specify a location, or Azure region for the storage account. So we'll just call "azure location list," and that's going to show us all of the available regions to create storage accounts in. So let's go ahead and grab "West US" here since our virtual network and virtual machine will also belong to the West US region. So we're going to also add the "resource-group" parameter and the "type" parameter.
Now, there are several different types of storage accounts. There is locally redundant storage, there's zone redundant storage, there's geo-redundant storage, there's read access geo-redundant storage, and then there's premium locally redundant storage. So let's create our virtual machine using premium locally redundant storage.
So let's go ahead and run "azure storage account create." We'll specify the resource group that we're going to create it in, which is "CloudAcademyVNet." We'll specify a name for the storage account. Let's just call it "cavnet." Then we're going to specify the location, or the azure region, to deploy it in. And then, finally, we'll specify the type of storage account.
So the type of storage account is going to be premium LRS, for locally redundant storage. So let's hit enter to run that. And as you can see, we've actually specified an invalid parameter. So the name parameter for the storage account is actually not a separate parameter, it's simply a positional parameter that comes at the end. So let's actually delete that and then add "cavnet" at the end. So now it's going to go out and create a storage account of type premium LRS in the West US region in the resource-group "CloudAcademyVNet," and the name of it will be "cavnet."
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.