This makes me laugh, because a couple of weeks ago a customer asked me if there was a way to understand the money consumption in azure while working from the management portal, and here we are:
If you ever worked with Windows Azure, you’ve probably stumbled in the bad practice to let the control panel create the storage for you, with an unreadable and forgettable name, and with the worst thing you can do, leaving the storage outside an affinity group, that guarantee low latency between services and storage that should communicate each other.
It is possible with the Windows Azure PowerShell module to copy a storage blob across storage accounts and regions… asynchronously!
For example, you would need to move a virtual machine disk between storage account:
Import-Module Azure Select-AzureSubscription "My Subscription Name" $destContext = New-AzureStorageContext –StorageAccountName "MyStorageAccountName" -StorageAccountKey "MyStorageAccountKey" $blob = Start-AzureStorageBlobCopy -SrcContainer vhds -SrcBlob "xxxx.vhd" -DestContainer vhds -DestBlob "xxxx.vhd" -DestContext $destContext
Then to check the status of the copying, you can execute this command:
$blob | Get-AzureStorageBlobCopyState
To start using Windows Azure PowerShell, you need to run just a couple of commands.
First import the windows azure powershell module:
Retrieve all your subscriptions (certificate method, you should prefer to use the Azure AD method instead, see below):
A browser window opens at https://windows.azure.com/download/publishprofile.aspx, where you can sign in to Windows Azure and download the publish settings file.
Then import the subscription publish settings file:
You should delete the publishing profile that you downloaded after you import those settings. The downloaded profile contains a management certificate that should not be accessed by unauthorized users.
There’s a new way to login azure on powershell, without using the certificate method:
Use the Azure AD method (newest and preferred way)
- Open the Azure PowerShell console, as instructed in How to: Install Azure PowerShell.
- Type the following command:
- In the window, type the email address and password associated with your account.
- Azure authenticates and saves the credential information, and then closes the window.
Now you can make a lot of operations against the azure fabric (a lot more than you can do from the web portal), like getting the list of containers and the the list of the blobs of a container.
First you select the subscription you want to use:
Select-AzureSubscription -SubscriptionName "My Subscription Name"
Then you set the storage account you want to query on:
Set-AzureSubscription -SubscriptionName "My Subscription Name" -CurrentStorageAccount "mystorageaccount"
(to get the storage account name, you can run Get-AzureStorageAccount)
And now you can get the list of the containers:
and the list of the blobs of a specified container:
Get-AzureStorageBlob -Container "containername"