Freigeben über


Working with Windows Azure Storage

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:

Command Line

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:

https://go.microsoft.com/?linkid=9811175&clcid=0x409

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:

PS C:\> Get-AzurePublishSettingsFile

 

clip_image001

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:

PS C:\> Import-AzurePublishSettingsFile <PathToFile>

clip_image003

 

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:

clip_image005

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.

clip_image006

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:

clip_image008

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"

clip_image010

Here’s how to verbosely list all of the VHD in the storage account selected above, type in and execute:

PS C:\> Get-AzureDisk

clip_image012

This is a lot of information to consume, let’s simplify the output by typing and executing:

PS C:\> Get-AzureDisk | findstr /i MediaLink

clip_image014

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:

PS C:\> Add-AzureVhd -Destination <BlobStorageURL>/<YourImagesFolder>/<VHDName> -LocalFilePath <PathToVHDFile>

clip_image016

- 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
https://www.windowsazure.com/en-us/manage/windows/common-tasks/upload-a-vhd/

Saving or Downloading a VHD:

PS C:\> Save-AzureVhd -Source <BlobStorageURL>/<YourImagesFolder>/<VHDName> -LocalFilePath <PathToVHDFile>

clip_image018

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.

clip_image019

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

clip_image021

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: https://msdn.microsoft.com/en-us/library/windowsazure/jj156055.aspx

Comprehensive list of Azure cmdlets: https://msdn.microsoft.com/en-us/library/windowsazure/jj152841.aspx

Let’s take a look at a few GUI options now:

Azure Storage Explorer – CodePlex - https://azurestorageexplorer.codeplex.com/- $FREE

- Gives you the ability create, copy, rename, delete, etc.

clip_image023

CloudBerry Explorerhttps://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.

clip_image025

CloudXplorer by ClumsyLeaf software - https://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.

clip_image027

Comments

  • Anonymous
    January 01, 2003
    Well done

  • Anonymous
    January 27, 2014
    One of the benefits when working with Hyper-V and Windows Azure is the portability of Virtual Machines

  • Anonymous
    March 09, 2014
    Hi there,

    I'm involved in the development of GUI tool to simplify a task of moving VMs to Azure cloud.
    It captures a VHD from your server, uploads it to Azure and creates a VM in any region or affinity group, subscription you like. So it's alike disk2vhd and Azure Storage Explorer combined.

    See: http://cloudscraper.migrate2iaas.com/azuredownload

    It’s in a beta development stage, so it’s free to use.

    Thanks in advance for giving it a try!

  • Anonymous
    September 03, 2014
    very helpful!

  • Anonymous
    October 07, 2014
    Are you interested in providing application access and presentation without the need to deploy hardware

  • Anonymous
    November 14, 2014
    Have you ever wanted to publish videos or training material without having to deploy a new server or