There came a news that the free developer account of azure had been expired end of Jan 2010 which means there’s no way to play with it for free. But I’m lucky that my location is not on their billing list which means I can use and try it till this June. So I think it should be better to explain a bit on how to deploy before it's withdrawn by Microsoft. As I had mentioned many times in the last 2 posts, deploying the azure application would be a little bit different. And I will continue using the application I created in the last post - the Whiteboard, although it's suck.
First we go to the windows azure development portal. After logged in with my Live ID we went into the portal and I can see the default project I requested before.
Click into this project the page it shows us how many items (services) I had created. If there's nothing created in my account we can see the Storage Account and Hosted Service links and how many of them I can use.
Since the Whiteboard project needs the table storage we firstly create a storage account. Just click the Storage Account. We named this service with the label Whiteboard and typed some proper description and press Next button.
In the next page we will give the storage account a public name so that it could be resolved on the internet by our hosted service which will be created later. We named it as http://whiteboard.blob.core.windows.net. We can check the availability of this public storage name by clicking the Check Availability button. Since we need this account to be communicated with our hosted service so we will create a new affinity group and named it as 'whiteboard', located it to the nearest server and press Create.
In the coming summary page the account information of this storage server will be shown to us. There are 3 endpoints indicates 3 types of storage services provided by windows azure: Table, Queue and Blob. Following is the access key for consuming them. If you are carelessness, like me, exposed the access key to someone else then you can use the Regenerate button to regenerate them. Next is the affinity group we had created in the last step and the CDN feature which had been disabled by default. Then let's back to the portal and create the hosted service, which is the website.
Back to the portal the storage service we had just created was appeared on the page. Click the new service link to create the hosted service. This time we clicked Hosted Service linkage.
We named it as Whiteboard Web and also some proper description and press Next. In the creating page we specify the URL of this hosted service, which is the public access URL of our website. We typed the whiteboard for the name and checked it's available. Then in the affinity group section since we need this service to be connected with the storage we created before so now we select the second radio button and chose the whiteboard affinity group and click Create.
In windows azure a hosted service divides into 2 versions: Staging and Production. It allows us to developing the application and deployed, tested on staging section without changing the production one. Once we feel it's good enough then we can simply move the staging one to production which I will explain later. We do the similar job when using the original dedicated server or virtual server by ourselves (i.e. added 2 website in IIS one assigned to port 80 which is the production app and the other to 8080 for staging app) but now windows azure takes care of it.
Now we finished the steps for creating the services on azure. The next step is to update the configuration of our web application to consume the azure services rather than the local development fabric. Let's back to our source code.
If you have the impression of the last post we created a configuration section in the Cloud Service project named DataConnectionString and aimed it to the local development storage. Now let's change it to the real azure service. Open the Web_Role node under the Cloud Service project, Roles folder and navigate to the Settings panel, changed the account information through the popup connect string editor. We filled the account information based on the storage account we had just created and save it.
And then right-click the cloud service project and publish it.
Once finished the Visual Studio will open the local folder that contains the necessary package files, and open the azure develop portal to us. In the portal we go to the hosted service page we created before and clicked the Deploy button under the staging section. We uploaded the package and the configuration files be published before and assign a version to it, let's say v1.0. And let's press the Deploy button.
Although the Microsoft said the deployment will take no longer than 90 seconds normally absolutely I'm the abnormal one. It always takes me at least 5 minutes. I think it's because few people played with it in China with low bandwidth. Anyway, after it uploaded and deployed we can see there are some buttons appeared under the staging section.
- Upgrade: This can be used when you want to upload a new version of your application.
- Run: Execute the cloud application. The code in WebRole.cs will be executed. The website cannot be accessed until you run it.
- Configure: Open the configuration file content that you can update through the portal.
- Delete: (I don't think you need the explanation.)
So let's run it.
After the azure portal finished the deployment and the initialization you can access the website through the URL under the staging icon. Now let's typed something and posted it to see if it works well on the cloud.
Once we are feeling well we can move it from the staging to production. Just click the recycling icon in the middle of the staging and production section. Then after another several minutes the application will be deployed on the production section.
You can see now the staging section was empty and the production section with our application ready.
Let went to the URL on the page which is http://whiteboard.cloudapp.net/. Since we are using the same storage account we can see the comment we posted when at staging section.
In this post I covered the steps when deploy the application onto the windows azure platform. Deploying azure application is very easy. What we need is to create the services, update the configuration, upload the packages and migrate to production section. The windows azure will take case of file extracting, IIS and firewall configuration, migration between staging and production, etc. I think that is what Microsoft said, "shorten your time to market".
We only explained and used the web role and the table storage so far. There are other 2 storages (Blog and Queue) and some other roles we didn't mention. In the next few posts I will cover all of these 3 storages more deeply.
Hope this helps,
All documents and related graphics, codes are provided "AS IS" without warranty of any kind.
Copyright © Shaun Ziyan Xu. This work is licensed under the Creative Commons License.
Note: Since I had removed the sample application of this post recently you will not be able to have an online example by refer the URL mentioned in this post.