The
second service available when you register to the Windows Azure
Services Platform is the Storage Account. It provides a web space for
uploading files (blob storage), for organizing simple data (tables
storage), and for sending/receiving simple messages (queue storage). To
enable your Storage Account, follow these steps:
1. | Log into the Windows Azure Developer Portal and go to the services page shown in Figure 2;
|
2. | Click New Service; when the Create New Service page is loaded, click Storage Account.
|
3. | Provide a label and a description for your account; then click Next.
|
4. | Type
the public name that will be part of your account’s URL and check for
its availability, leaving unchanged the location options. Figure 1 shows an example.
|
Now click Create
so that the Storage Account creation is finalized. When you create the
Storage Account, a Shared Key is also generated. This is a unique
identifier that you need for
accessing the storage from client applications and that is for login
purposes. You can check this out by clicking the new account name on
the left of the page, under the Windows Azure title. As mentioned when
discussing local tests, a local developer account is also created and
replicates locally what you can do with the online services. The local
developer account has a built-in storage account with a prefixed user
name (devstoreac-count1) and shared key, so for this you need to do
nothing. About the online services, the Storage Account has the
following endpoints:
In the preceding bulleted list, publicname
stands for the account public name you provided a few steps ago. Such
endpoints are the way you access contents in the Storage Account via
Http (or Https if available). For the local developer account, the
endpoints will be the following (requires the Windows Azure Simulation
Environment running):
http://127.0.0.1:10000 for the blob storage
http://127.0.0.1:10001 for the queue storage
http://127.0.0.1:10002 for the tables storage
Because both the online and
local services do not offer tools for managing contents on the Storage
Account, you need to recur to external client tools or to build your
own tool utilizing the Windows Azure SDK API. Fortunately there are
several free tools, such as the Windows Azure Management Console
Snap-in that is related to blobs and queues.
Using the Windows Azure Management Console Snap-In
Often you need to store files
for your applications when deployed to Windows Azure. This can be
accomplished in two ways, both as an administration task and
programmatically. If you need to store files programmatically, look at
the additional Windows Azure examples located on MSDN Code Gallery
here: http://code.msdn.microsoft.com/windowsazure samples and search for the StorageClient
sample application, which implements code taking advantage of the REST
APIs for managing the blob storage programmatically. If you instead
need to upload files to the Blob storage as a simple repository for
your applications, an easy way is installing the Windows Azure
Management Console Snap-In. This can be found on Code Gallery and as
well here: http://code.msdn.microsoft.com/windowsazuremmc.
Download the compressed archive and extract it to a folder. Now run the
StartHere.cmd file, which contains scripts for building the application
and for installing the snap-in to the Microsoft Management Console in
Windows.
The
installation process requires the .NET Framework 3.5 SP 1 be installed
on your machine. This is because the component is distributed in source
code and the setup procedure will build the binary library for you. If
you are running Windows 7 you do not need to install the framework.
|
When you run the utility, it looks like Figure 2.
The first step is
establishing a connection to the local developer account or to the
online services. For example, right-click on Azure Account and select
the New Connection command. Now fill the text boxes in the dialog with your account name and key, as shown in Figure 3.
You notice that Service URLs will be automatically populated for you when writing the account name. When you click OK
the connection is established, in this case to the online Storage
Account. If you need a connection to the local developer account,
simply select the Local Connection command. (You will not be prompted for credentials.) When ready, click on the BLOB Containers
item in the left tree view control. This shows existing containers and
enables you to add new containers. Basically a container is just a
folder where you can upload files. In the Windows Azure terminology,
files are called blobs. Figure 4 shows what I have on my Storage Account, which is a container named videos and where there is one file stored, as you can see at the bottom of the application.
On the right side of the
application, you can find a pane offering common commands. You can add
a new container, upload an existing one, remove containers, or just
upload and delete blobs. It is worth mentioning that when you create a
new container you can make it public or private. If you mark it as
private, you need your shared key to access it every time. If your
container will store files that must be reached by all users, it will
be marked as public. You can check this out by clicking the Add Container
command from the right pane. Also notice that container names must be
lowercase. If you try to type uppercase characters, they will be
automatically converted into lowercase. After you have uploaded blobs
to the Storage Account, you can access them simply via Http URLs.
Continuing the example of my account, represented in Figure 4, to access the VideoForAzure.Wmv file, you simply need the following URL: http://alessandrodelsole.blob.core.windows.net/videos/VideoForAzure.wmv. If it is a media or browsable content, you can type the address in your Web browser address bar or just use the URL in
your applications according to your needs. In case your blobs are
stored within the local developer account, you simply invoke them with
the local URL, keeping in mind that the Windows Azure Simulation
Environment must be running: http://127.0.0.1:10000/VideoForAzure.Wmv.