Today I am going to show you how to upload files to Azure Storage using the Azure Resource Manager PowerShell cmdlets. We are going to upload all of our resources to the resource group and storage account that we created in this previous post. Once you have built your ARM template, VHD or DSC Configuration you can use the script below to upload the files to Azure storage. This scripts uploads files as a block blob type, you can read more about Azure Storage types here. I will cover this a bit more in a future blog post where I will show you how to upload a custom VHD to Azure, for now just note that you should not use the script below as is to upload a VHD.
If($cred -eq $null)
$cred = Get-Credential
$Account = Add-AzureAccount -Credential $Cred
$ResourceGroupName = 'Template'
$location = 'Central US'
$StorageAccountName = '<mystorageaccountname>'
$StorageType = 'Standard_LRS'
$storageContainer = '<Containername>'
$File = '<Enter the path here>'
$StorageAccountName = $StorageAccountName.ToLower()
$storageContainer = $storageContainer.ToLower()
$storageKey = Get-AzureStorageAccountKey -ResourceGroupName $ResourceGroupName -AccountName $StorageAccountName
$StorageContext = New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $storageKey.Key1
Set-AzureStorageBlobContent -File $File -Context $StorageContext -Container $storageContainer -BlobType Block