Quantcast
Channel: TechNet Blogs
Viewing all articles
Browse latest Browse all 36188

Building a VM in Windows Azure using PowerShell in a few quick steps

$
0
0

Hello folks, its Rick here. In a previous post Michael gave you nice overview of Windows Azure Services and helped you setup your own VMs in cloud using the free trial thru the Azure portal. Today I would like to walk you through building a VM in Windows Azure using your favorite management tool ‘PowerShell’, and in doing so you will also unlock 133 cmdlets that will help you manage other services you may have running in Windows Azure. If you have not signed up for a 90 day trial yet, I suggest you give it a try. Also did you know if you have an existing MSDN subscription, you may be entitled to up to 1500 compute hours that’s $6500 in annual Windows Azure benefits at no charge.

Let’s get started;

1. Download the Windows Azure PowerShell and install it on a Windows 8, Windows 7, Windows Server 2012, or Windows Server 2008 R2 machine.

image

 

2. If you would like to use Windows Azure PowerShell snap-in you can directly launch it from your Start Menu/Screen, but if you are like me and rather import the module into your existing Windows PowerShell, you know the drill.

Set-ExecutionPolicy RemoteSigned

Import-Module "C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\Azure\Azure.psd1"     

3. Configuring connectivity between your workstation and Windows Azure; before a connection can be made from your Windows Azure Powershell module you first need to download your publish settings from Azure portal using the cmdlet below.

Get-AzurePublishSettingsFile    

4. Your browser will take you to https://windows.azure.com/download/publishprofile.aspx, where you can sign in to Windows Azure account download the publish settings file. Note the location where you save this file. This file has Azure API information, your subscription ID and more importantly the management certificate that needs to be imported locally on your machine using another cmdlet.

 

image  
 

5. Now we will go ahead the import the publish settings file we have just downloaded using the command below. Where <mysettings>.publishsettings is the file that you downloaded in the previous step. You should delete the publishing profile that you downloaded after you import those settings. The downloaded profile contains a management certificate that should not be accessed by unauthorized users.

Import-AzurePublishSettingsFile <mysettings>.publishsettings

image
   

You can optionally view the publish settings file you downloaded in Step 4, in Notepad.

 image

 

6. Let’s take a look at our current subscription, notice the certificate being good for one year since the time you set this up.

 image

 

7. Now let’s take a look what are some of the cmdlets that Azure PowerShell module unlocks for us, focusing on VM management. You can see the rest here.

 image

 

8. Let’s see what I already have running out there..

 image

 

9. We are almost ready to build the VM, but before we do that we have to use Set-AzureSubcription cmdlet to save our subscription information and set the storage account that was previously setup using the Azure portal. You can use the Get-AzureStorageAccount cmdlet to retrieve the StorageAccountName property.

 image

 

Set-AzureSubscription -SubscriptionName "Windows Azure MSDN - Visual Studio Ultimate" –CurrentStorageAccount portalvhdshmdl42f1wmfd7

You can verify the above command using the Get-AzureSubscription cmdlet again.

Above “portalvhds*” being the name of my storage.

10. Let’s build a new VM using the New-AzureQuickVM cmdlet, (note that as mentioned in the previous post, Azure provides pre built images in VHD, in following example we have run the Get-AzureVMImage and passing the name of a 2012 image. You can also use Test-AzureName cmdlet to verify if the VM or service name you are wanting to acquire is available.

New-AzureQuickVM -Windows -ServiceName TESTADDC03 -Name TESTADDC03 -ImageName MSFT__Windows-Server-2012-Datacenter-201210.01-en.us-30GB.vhd -InstanceSize 'Small' -Password Password!@# -AffinityGroup Chicago

image

You will see everytime you deploy a VM, it first gets created as a Cloud Service and then the VM itself gets deployed, you will see the progress bar for the VM creation as well.

 image

It took less than a minute to spin up this test VM for this demo, your time may vary.

 image

11. Let’s verify that our VM is up and running.

 image

 

image

 

This wraps up this quick tutorial, hopefully you can see that after you have your initial subscription ready and registered and at least one storage account setup, you can provision VMs using PowerShell in a matter of minutes. I invite you try this out yourself and see what other useful cmdlets you find in the Azure PowerShell module.

Until next time, Rick “is there a cmdlet for that” Sheikh !


Viewing all articles
Browse latest Browse all 36188

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>