« How to speed up Windows Azure Development (Part 2 of 2, 9 minutes) | Main | Windows Azure CloudDrive - Creating a Web Role that mounts the CloudDrive from Azure Storage and reads text files (Part 2 of 2, 22 minutes) »

Windows Azure CloudDrive - Creating a VHD and Uploading it to Azure Storage (Part 1 of 2, 30 minutes)

This is part 1 of 2 screencasts I recorded that shows a Microsoft .NET developer how to use the new Windows Azure CloudDrive feature -

  • For Part 2, Creating a Web Role that mounts the CloudDrive from Azure Storage and reads text files (Part 2 of 2, 22 minutes) – click here.
  • For the Summary entry on blog.ehuna.org, click here.

In this video I go over the details on how to create a VHD file in Windows 7 and the code you need to upload it as a Page Blob in Windows Azure Storage.

I found the code that uploads the VHD to a Page Blob to Azure Storage in the cloud on Thomas Conte’s MSDN blog – thanks Thomas!  Also, thanks to Neil Mackenzie on the Azure forums who helped me out with many issues I ran into.

For more articles, screencasts and tips check out www.ehuna.org – you can also follow me on twitter.com/ehuna

See below for more details on what's covered in the screencast and download the Visual Studio 2010 VB.NET projects here:

  http://blog.ehuna.org/files/Visual-Studio-Solution-AzureSpeed1.zip (134 KB)

Windows Azure CloudDrive - Creating a VHD and Uploading it to Azure Storage (Part 1 of 2, 30 minutes)

Here’s what is covered in the video:

  • 00:00 - Introduction / Overview (see notes here).
    • Development Tip: access files that are normally in CloudDrive - when ASP.NET web site is running in IIS (not in the cloud)

Creating the VHD Manually

Windows 7 or Windows Server 2008 R2

  • 09:25 - Windows 7 > Control Panel > Disk Management
  • 10:05 - Disk Management > Create VHD
    • Folder: C:\Data\Personal\projects\MyVHDDrive\MyVHDDrive\data
      • File: myvhddrive.vhd
      • Size: 16 MB (fixed size)
    • You can also create a VHD through the CloudDrive APIs.
  • 11:38 - Initialize Disk > Format > NTFS > Assign drive letter of "V"
    • NTFS has large overhead for small drives: 16 MB drive only has 3.9 MB of free space.
  • 13:19 - creating a folder and files in the VHD
    • Folder: "datafolder"
      • Files "textfile1.txt" and "textfile2.txt"
      • Add some content to the text files using Notepad.
  • 14:00 - Disk Management > Detach VHD

Uploading the VHD to a Page Blob in Azure Storage
Console Application created using Visual Studio 2010 RC

  • 15:09 - Visual Studio 2010 RC test project - console application called "MyVHDDrive".
  • 15:40 - No reference to "C:\Program Files\Windows Azure SDK\v1.1\ref\Microsoft.WindowsAzure.CloudDrive.dll"
    • This console app does not run in the Azure fabric.
  • 16:00 - Azure Storage parameters in app.config
<add key="AzureStorageAccount" value="YOURstorage"/> 
<add key="AzureStorageKey" value="YOURKEY"/>
<add key="BlobStorageEndpoint" value="http://YOURstorage.blob.core.windows.net/"/>
<add key="QueueStorageEndpoint" value="http://YOURstorage.queue.core.windows.net/"/>
<add key="TableStorageEndpoint" value="http://YOURstorage.table.core.windows.net/"/>
<add key="BlobContainer" value="vhddrives"/>
  • 17:08 - Folder and File name of VHD
<!-- The location where the VHD file is located --> 
<add key="VHDDriveName" value="myvhddrive.vhd"/> 
<!-- The name of the VHD drive to deploy to Azure Storage -->
<add key="VHDDriveNamePageBlob" value="myvhddrive.vhd"/> 
  • 18:23 - Imports
Imports System.Xml 
Imports System.Xml.Linq 
Imports System.Configuration 
Imports System.IO 
Imports System.Text.RegularExpressions 
Imports System.Collections.Generic 
Imports Microsoft.VisualBasic.FileIO 
Imports Microsoft.WindowsAzure 
Imports Microsoft.WindowsAzure.Diagnostics 
Imports Microsoft.WindowsAzure.Diagnostics.Management 
Imports Microsoft.WindowsAzure.StorageClient 
Imports Microsoft.WindowsAzure.ServiceRuntime
  • 18:50 - VB.Net Module: Static Shared classes - much simpler code.
  • 19:23 - Running and testing that settings are loaded properly.
  • 20:26 - Running and doing some data validation on the input settings
  • 21:31 - Checking the code that uploads the VHD to the Page Blob in Azure Storage
oStorageCredentialsAccountAndKey = New StorageCredentialsAccountAndKey(sAzureStorageAccount, sAzureStorageKey)
oCloudStorageAccount = New CloudStorageAccount(oStorageCredentialsAccountAndKey, _ 
uriBlobStorageEndpoint, uriQueueStorageEndpoint, uriTableStorageEndpoint) oCloudBlobClient = oCloudStorageAccount.CreateCloudBlobClient() oCloudBlobContainer = oCloudBlobClient.GetContainerReference(sBlobContainer) oCloudBlobContainer.CreateIfNotExist() oCloudPageBlob = oCloudBlobContainer.GetPageBlobReference(sVHDDriveNamePageBlob) sVHDUri = oCloudPageBlob.Uri.ToString oFileStream = IO.File.OpenRead(sVHDDriveNameFull) […]
  • 24:15 - Running and debugging the code - placing breakpoints and checking variable values
    • Showing the URI of the Page Blob that hosts the VHD file.
    • Using Cloud Storage Studio to download a VHD from an Azure Storage Page Blob and then mounting it.
  • 27:06 - Windows Azure Local Development Fabric - simulation of Page Blob - where to copy your files to simulate the VHD in local storage
    • The directory is normally: C:\Users\[USERNAME]\AppData\Local\dftmp\wadd\devstoreaccount1\[CONTAINER]\[DRIVE.VHD]\[FOLDER]
    • If you ran into the path max length issue, look at _CSRUN_STATE_DIRECTORY: C:\t\wadd\devstoreaccount1\[CONTAINER]\[DRIVE.VHD]\[FOLDER]
  • 29:30 - Conclusion
| More

Comments



About

This page contains a single entry from the blog posted on March 12, 2010 10:21 PM.

The previous post in this blog was How to speed up Windows Azure Development (Part 2 of 2, 9 minutes).

The next post in this blog is Windows Azure CloudDrive - Creating a Web Role that mounts the CloudDrive from Azure Storage and reads text files (Part 2 of 2, 22 minutes).

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.35