In this blog post, I assume you already have an Azure subscription and a user account set up. If you do not, check out Windows Azure Training Series: Understanding Subscriptions and Users. You might also like to read Windows Azure Training Series: Understanding Azure Storage for an overview of Azure storage.
To use Azure storage, you need to create a storage account. To do this, first go to the Windows Azure Platform Manage Portal and log in. Then, click on the New Storage Account button at the top left corner of the portal as shown below.
You will be prompted to enter a unique URL (or account name) for this storage account. Azure storage is always accessed using a URL based on this name, plus the type of storage you’re accessing, plus the ”core.windows.net” domain. So, using the name shown below, accessing blob storage would be done using the URL, http://myuniqueaccountname.blob.core.windows.net/. To access table storage you would use the URL, http://myuniqueaccountname.table.core.windows.net/.
After entering your URL, choose a region where your storage account will be located and then click create.
After the account is created you can view its properties in the Properties grid on the right side of the management portal. The most important property is the primary access key. To access it, click on the View button.
The window shown below will open; it allows you to view and copy the access keys to the clipboard. You will need to add the access key to the configuration file of your Azure application.
In Visual Studio, open the ServiceDefinition.csdef file in your Azure service project, and add the configuration setting shown below.
Also, open the ServiceConfiguration.cscfg file, and set the value of that setting as shown below. Of course, you’ll use your own account name and account key.
Finally, you’ll need to add the following code to your WebRole.cs file.
Tune in next time and we’ll take a look at the code required to write to blob storage.
To learn more about Windows Azure, check out Learning Tree’s course, Windows Azure Platform Introduction: Programming Cloud-Based Applications.