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 = "https://2053320532storage.blob.core.windows.net/storeddisks1/WindowsAzureTest2.vhd"
Add-AzureVhd -LocalFilePath D:\Azure\WindowsAzureTest2.vhd -Destination $Url
Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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