Today I am going to use the Azure PowerShell Module to create a new Azure Resource Manager storage account and 3 containers to store different resources that we will need throughout this blog series. The first container we are going to name vhdimages, we will store custom VHD images here, the second container is named armtemplates, we will store our json/Arm templates here and the last container is named configurations we will store a DSC configurations hear. Optionally you could store everything in a single container but I have chosen to create separate containers for organizational purposes
If you have not used the Azure PowerShell Module yet you can download it here. If you are reading this before October 2015 I recommend that you take a look at this Wiki article Deprecation of Switch Azure Mode in Azure PowerShell to understand some of the upcoming changes to the Azure PowerShell module. I plan to update all of these scripts to use the late September release of the module once it is release. Need to know how to connect to Azure with PowerShell check out this blog post.
There are a few rules to know while working with azure storage accounts, each storage account in azure must have a unique name, so it may take a few attempts to find a name that is not already in use by another azure user. Storage accounts and container also can only contain lowercase characters or number.
$ResourceGroupName = 'Templates'
$location = 'Central US'
$StorageAccountName = 'mystorageaccountname'
$StorageType = 'Standard_LRS'
$storageContainerVHD = 'VHDImages'
$storageContainerARM = 'Armtemplates'
$storageContainerDSC = 'Configurations'
$StorageAccountName = $StorageAccountName.ToLower()
$storageContainerVHD = $storageContainerVHD.tolower()
$storageContainerARM = $storageContainerARM.tolower()
$storageContainerDSC = $storageContainerDSC.tolower()
New-AzureResourceGroup -Name $ResourceGroupName -Location $location
New-AzureStorageAccount -ResourceGroupName $ResourceGroupName -AccountName $StorageAccountName -Type $StorageType -Location $location
$storageKey = Get-AzureStorageAccountKey -ResourceGroupName $ResourceGroupName -AccountName $StorageAccountName
$StorageContext = New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $storageKey.Key1
New-AzureStorageContainer -Context $StorageContext -Name $storageContainerVHD -Permission Off
New-AzureStorageContainer -Context $StorageContext -Name $storageContainerARM -Permission Off
New-AzureStorageContainer -Context $StorageContext -Name $storageContainerDSC -Permission Off