Sunday, May 17, 2015

Getting Started with Azure Powershell

I've been working with the Azure management and preview portal for a while now.  I figured its time for me to start leveraging Azure Powershell! 

Here are the basic steps I used to get started:

1. Download and install the Azure PowerShell modules using the Web Platform Installer 5.0:
http://www.microsoft.com/web/downloads/platform.aspx



2. Launch Azure Powershell (I used Windows PowerShell ISE) and connect to your subscription using Azure AD authentication (preferred method for logging in). 

Add-AzureAccount

A sign in window will pop-up where you will supply your AD credentials.  After a successful log-in you will get a message with your subscription(s) information.

3. Once you've successfully logged in, you can run some simple commands:

Get-AzureAccount
Provides a summary of the subscriptions associated with the account.

Get-AzureSubscription:
Provides a dump of subscriptions you have access to

Select-AzureSubscription:
Selects current subscription
Select-AzureSubscription "Subscription Name" (Caps Sensative)

Get-AzureRoleSize
How to find Azure VM sizes. 

Start-AzureVM 
Start-AzureVM -ServiceName "MyCloudService" -Name "MyVM"

Get-AzureVM 
Retrieve info about an Azure VM
Get-AzureVM -ServiceName "MyCloudService" -Name "MyVM"
Get-AzureVM -ServiceName "MyCloudService" -Name "MyVM" | Select IpAddress

Stop-AzureVM 
-Force releases the public, and VIP associated with the could service
Stop-AzureVM -ServiceName "MyCloudService" -Name "MyVM" -Force

Remove-AzureVM
-DeleteVHD deletes VHDs assocated with the VM
Remove-AzureVM -ServiceName "MyCloudService" -Name "MyVM" -DeleteVHD
 
Remove-AzureDisk
Deletes VHDs
Remove-AzureDisk "DiskName" -DeleteVHD 

Remove-AzureService
Removes Cloud Service 
Remove-AzureService -ServiceName "MyCloudService" 
  
Get-Help Azure
Lists all cmdlets in the Azure module

Convert-VHD
Converts from vhdx to vhd format
Convert-VHD –Path c:\VHDs\MyVM.vhdx –DestinationPath c:\VHDs\MyVMVHD.vhd
  
Add-AzureVHD
Migrates local VHDs to Azure.  This cmdlet is aware of empty space.
Add-AzureVHD -Destination "https://MyStorage.blob.core.windows.net/vhds/MyVHD.vhd" -LocalFile Path X:\MyVMs\VHDs\MyVM.vhd -NumberOfUploaderThreads 5




Add-AzureDisk
After uploading your VHD to Azure storage, it must then be tagged as an Azure disk
Add-AzureDisk -OS Windows -MediaLocation "https://MyStorage.blob.core.windows.net/vhds/MyVHD.vhd"-diskname "MyDiskName


Additional Azure SDKs and Command-Line tools:
http://azure.microsoft.com/en-us/downloads/#cmd-line-tools

Thursday, May 14, 2015

Microsoft Virtual Machine Converter (MVMC) - "The Certificate With Thumbprint was not found in the personal certificate store"

Recently, I've been testing the Microsoft Virtual Machine Converter 3.0/3.1 product to push VMs up to Azure.   Upon entering the Subscription ID and Cert Thumbprint, I would get the following error:

"The Certificate With Thumbprint <thumbprint> was not found in the personal certificate store"

I used the typical method of creating a Azure management cert (makecert - in Windows SDK)



makecert -sky exchange -r -n "CN=MyCert" -pe -a sha1 -len 2048 -ss My "MyCert.cer"
 

Turn out, I had the cert in the my personal store, but it needed to be imported into Trusted Root Certification Authorites:


Instructions on Exporting and Importing the cert into the appropriate folder is located in the following Microsoft KB:

https://support.microsoft.com/en-us/kb/2977336?wa=wsignin1.0