Azure – Creating Storage Account and Uploading VHD using PowerShell

A pretty basic script here.

Create Afinity Group

Create and Get Storage Account

Get Primary keys  and Generate Context

Create a new Container and Upload the VHD.

New-AzureAffinityGroup -Name "2053320532afinitygroup" -Location "East US"
$AfinityGroup = Get-AzureAffinityGroup -Name "2053320532afinitygroup"
New-AzureStorageAccount -StorageAccountName "2053320532storage" -AffinityGroup $AfinityGroup.Name
$StorageAccount = Get-AzureStorageAccount -StorageAccountName "2053320532storage"
$StoragePrimaryKey = (Get-AzureStorageKey -StorageAccountName $StorageAccount.StorageAccountName).Primary
$StorageContext = New-AzureStorageContext -StorageAccountName $StorageAccount.Label -StorageAccountKey $StoragePrimaryKey

New-AzureStorageContainer -Name "storeddisks1" -Permission Container -Context $StorageContext
$Container = Get-AzureStorageContainer -Name storeddisks1 -Context $StorageContext
$Url = ""
Add-AzureVhd -LocalFilePath D:\Azure\WindowsAzureTest2.vhd -Destination $Url

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s