
I will begin with the fact that yesterday they sent me an invitation to participate in testing Windows Azure.
And now I want to share my first experience in creating cloud applications. This will be a
simple image hosting service .
For those who still do not know what Windows Azure is, I suggest reading the article “
What is the Azure Services Platform? "In English or a short
description on Wikipedia in Russian.
So let's get started.
Windows Azure CTP has the following limitations:
- Total computation time: 2000 hours (≈ 83 days in 24/7 mode)
- Storage capacity: 50 GB
- Maximum storage traffic: 20 GB / day
I have the opportunity to create 2 types of service components:
- Storage Account - distributed storage for large volumes of structured and unstructured information,
- Hosted Services is the 64-bit computing cloud of the Azure Services Platform, which is the hosting for cloud applications.
Here is the interface for creating new components:

')
Since it was decided to host the images, for this task it was necessary to create one data storage (Storage1) and one cloud (Cloud1).
To work with Windows Azure in Visual Studio 2008, you need to install:
The SDK contains an archive with ready-made examples. One of them (
Thumbnails ) I took as a basis. The SDK also has a
StorageClient project, which consists of classes that make it easy to work with storage. We connect it as a reference to the service.
For example, the code for loading data into Blob storage will look like this:
//
BlobStorage blobStorage = BlobStorage.Create(StorageAccountInfo.GetDefaultBlobStorageAccountFromConfiguration());
// "photogallery"
BlobContainer blobContainer = blobStorage.GetBlobContainer( "photogallery" ).CreateContainer( null , ContainerAccessControl.Public);
//
BlobProperties props = new BlobProperties( "NameOfFileInContainer" ) { ContentType = upload.PostedFile.ContentType };
//
blobContainer.CreateBlob(props, new BlobContents(upload.FileContent), true );
After installing Windows Azure Tools in Visual Studio, new project types will appear:

Let's create Worker Cloud Service. This will be a service that will work in the cloud and generate previews for images.
The code template of its class is:
public class WorkerRole : RoleEntryPoint
{
public override void Start()
{
// This is a sample worker implementation. Replace with your logic.
RoleManager.WriteToLog( "Information" , "Worker Process entry point called" );
while ( true )
{
Thread.Sleep(10000);
RoleManager.WriteToLog( "Information" , "Working" );
}
}
public override RoleStatus GetHealthStatus()
{
// This is a sample worker implementation. Replace with your logic.
return RoleStatus.Healthy;
}
}
As you can see, the service every 10 seconds writes to the log that it is running.
Let's connect to the Reference project with storage classes (Microsoft.Samples.ServiceHosting.StorageClient):

In order not to ruin the article, I will not give you the service code, here is a
link to it .
After writing the service code, you need to upload it to the cloud. To do this, prepare a package for the "publication":

After that, 2 files will be created (the package itself with the service code and the configuration file indicating the number of nodes for the service) that need to be uploaded to the cloud:

The publication procedure consists of two stages:
- Loading the project in Staging for verification

- Translation of a proven project into Production
After publication, the picture looks like this:

Now we have a service that works in the cloud, and storage. The last thing left is to make a web shell.
It's more and more familiar here, let's manage with one aspx-page (
Default.aspx ,
Default.aspx.cs ), which I posted on the hosting from the masterhost (although it was possible to entrust this to the cloud).
The page contains one UpdatePanel, which contains the ContentTemplate with thumbnail links.
UpdatePanel is updated every 5 seconds, getting all created previews in the repository at the moment. Well, very simple image hosting. =)
Everything is ready:
tinyakov.net/img .
You can get down to the fun part - testing!
I will update the load graph from time to time.

Thanks for attention! =)
For those who want to touch the Window Azure platform - register for an invitation
here .
I will try to answer your questions in the comments.