Q: What’s an easy and cost effective (e.g. free) method for me to access Windows Azure storage and upload .VHD files?
NOTE: The following isn’t a complete list and there are many tools and suites available however I focused on tools that are easy to use and are primarily free.
A: There are a variety of tools available. Let’s start with scripting…
Assumptions for all the tools listed:
PowerShell – if you haven’t learned PowerShell now is a great time to learn!
The following will walk you through how to access Windows Azure storage with PowerShell.
1. First you’ll need to download and install the Azure command line tools:
2. Once the command line tools are installed, launch the Windows Azure PowerShell console.
3. Next you’ll need to download the publishing file:
From the Azure type in and execute:
This will open a browser window and automatically download the publish settings file (I used the default name however you can choose to rename it if necessary). Save it locally for reference in the following step.
4. Now let’s import the PublishSettings file:
5. Next we need to connect Windows Azure PowerShell from our machine to Windows Azure:
Using the Windows Azure PowerShell console in the previous step, type in each of the following and press Enter after each entry:
PS C:\> $mySubID = "<subscriptionID>" you’re setting a variable you’ll use in later commands
– Remove the <>, keep the “”
– SubscriptionID can be located by logging into Azure then on the left hand side select SETTINGS, and copying the SubscriptionID you’d like to access.
PS C:\> $certThumbprint = "<Thumbprint>" again you’re setting a variable you’ll use in later commands
– Remove the <>, keep the “”
– Thumbprints can be located by logging into Azure then on the left hand side select SETTINGS, and copying the Thumbprint that corresponds to the SubscriptionID you chose above.
PS C:\> $myCert = Get-Item cert:\CurrentUser\My\$certThumbprint
PS C:\> $mySubName = "<SubscriptionName>" again you’re setting a variable you’ll use in later commands
– Remove the <>, keep the “”
– SubscriptionName can be located by logging into Azure then on the left hand side select SETTINGS, and copying the Subscription Name under SUBSCRIPTION column that corresponds to the SubscriptionID you chose above.
PS C:\> Set-AzureSubscription -SubscriptionName $mySubName -Certificate $myCert -SubscriptionID $mySubID
PS C:\> Select-AzureSubscription -SubscriptionName $mySubName
PS C:\> Get-AzureSubscription will list all Azure subscriptions
Here’s what my entries and output looks like:
If you have multiple subscriptions (as I do), then you’ll need to target a subscription and storage account by typing and executing the following in the Windows Azure PowerShell console you have open:
PS C:\> Set-AzureSubscription -SubscriptionName $mySubName -CurrentStorageAccount " storage account name"
Here’s how to verbosely list all of the VHD in the storage account selected above, type in and execute:
PS C:\> Get-AzureDisk
This is a lot of information to consume, let’s simplify the output by typing and executing:
PS C:\> Get-AzureDisk | findstr /i MediaLink
Much better… 🙂
OK, now that you have a PowerShell connection to Azure the following walks-through how to manage files:
Uploading a VHD:
From the Windows Azure PowerShell window you used in the previous step, type:
Add-AzureVhd -Destination <BlobStorageURL>/<YourImagesFolder>/<VHDName> -LocalFilePath <PathToVHDFile>
– For the LocalFilePath, local and network shares are supported.
Use one of the URLs from the output above.
For additional info, there’s a great detailed post here:
Creating and Uploading a Virtual Hard Disk that Contains the Windows Server Operating System
Saving or Downloading a VHD:
Save-AzureVhd -Source <BlobStorageURL>/<YourImagesFolder>/<VHDName> -LocalFilePath <PathToVHDFile>
Removing or Deleting a VHD:
First you’ll need to turn off the VM or detach the disk from the VM. This can be easily done through the Azure GUI.
Once the disk is detached you’ll need to locate the name of the disk. You can do this two ways:
1) By going in to the Azure Console and selecting VIRTUAL MACHINES from the list on the left side of the page.
2) By using the Windows Azure PowerShell console previously opened and connected to Windows Azure.
Type in and execute the following commands
i. PS C:\> Get-AzureDisk
ii. Look for the name of the data disk by locating the field “MediaLink”
iii. Right below the “MediaLink” string locate DiskName
iv. Copy the full DiskName – it will contain the name and a string of numbers at the end.
Now you can delete the data disk using the following command:
PS C:\> Remove-AzureDisk –DiskName “MyDataDisk” –DeleteVHD
Congratulations, you’ve managed data in Windows Azure using PowerShell!
I know that was quite a few steps however for automation, PowerShell is the way to go.
To learn more about working with Azure using PowerShell visit: http://msdn.microsoft.com/en-us/library/windowsazure/jj156055.aspx
Comprehensive list of Azure cmdlets: http://msdn.microsoft.com/en-us/library/windowsazure/jj152841.aspx
Let’s take a look at a few GUI options now:
Azure Storage Explorer – CodePlex – http://azurestorageexplorer.codeplex.com/ – $FREE
– Gives you the ability create, copy, rename, delete, etc.
CloudBerry Explorer – http://www.cloudberrylab.com/free-microsoft-azure-explorer.aspx – $FREE
– This is a great tool and has similar feature as other tools however I like the side by side windows where I can drag and drop between locations.
CloudXplorer by ClumsyLeaf software – http://clumsyleaf.com/products/cloudxplorer $FREE & $PAID
– I’ve seen this tool utilized quite a bit out there. It has similar features to the tools above and is easy to work with.