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

No comments:

Post a Comment