Chapter 3. Virtual Machines

Creating Virtual Machines with PowerShell

In this chapter you will learn about using the Microsoft Azure PowerShell cmdlets to create a virtual machine with Microsoft Azure platform images. As part of learning this process, you will learn how to specify the initial configuration settings such as the local administrator account name and password, the virtual machine size (CPUs and memory), network endpoints, and underlying storage. From there you will learn how to use those same concepts to modify the configuration of existing virtual machines, whether they are running or not.

To get started creating your first virtual machine using PowerShell, you will need some environment information from Microsoft Azure. This is the same information that you use in the portal, such as the region name and the storage account that will be used as the location where your virtual machine disks are created.

For the first part of this chapter, I would recommend creating a new PowerShell file and saving it with a name such as chapter3create.ps1. Some portions of this chapter will be saved to the script and edited in the Script pane (top portion of the ISE) to make it easier to follow, and some portions should be executed in the Console pane (bottom portion of the ISE) for immediate results.

The first call related to Microsoft Azure of your new script should always be to Select-AzureSubscription to ensure that you are executing commands against the correct Microsoft Azure subscription. ...

Get Automating Microsoft Azure Infrastructure Services now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.