windows azure 第一个程序Hello World

就像其他程序设计语言一样,首先从Hello World开始整个windows azure的学习。下面来自:http://weblogs.asp.net/jeffwids/archive/2010/03/02/getting-started-with-windows-azure-part-2-creating-a-windows-azure-hello-world-application.aspx

Below are the steps to create a simple Windows Azure Hello World application. These steps assume that you have installed the Windows Azure Tools for Visual Studio. See Part 1 - Setting up your development environment for more information on setting up your development environment.

Open Visual Studio 2008 and choose New Project. Then expand the language of your choice and click on the “Cloud” category to find the Windows Azure Cloud Service project type.

windows azure 第一个程序Hello World

Select the Windows Azure Cloud Service project type and then you will be presented with the Role selection dialog. Choose the ASP.NET Web Role and move it to the right-hand frame. You can edit the name of the role by clicking on the edit (pencil) icon for that role.

windows azure 第一个程序Hello World

You will then have Visual Studio projects like the following:

windows azure 第一个程序Hello World

Modify the Default.aspx page to include your “Hello World” text or anything else you would like and then hit F5 to test.

After Windows Azure finishes initializing the Development Storage, you will be presented with your Hello World page running on your local machine:

windows azure 第一个程序Hello World

At this point you are ready to deploy to the cloud but first you need to sign up for the service. I will move on with how to sign up and create the Windows Azure Portal Account and then come back to publishing and deploying your Hello World project later….

Signing up for the Windows Azure Service

Next up is to sign up for the Windows Azure Service through Microsoft Online Services. Signing up for a Windows Azure account can be a little confusing since you don’t sign up for Windows Azure directly but sign up with Microsoft Online Services which manages all of your subscriptions to the Microsoft Online Services (Azure is one of them; there also is the hosted Exchange and SharePoint which you can sign up for too).

You can see the various Windows Azure offers from this page and here is a Windows Azure Comparison chart which shows that there is a free offer called “Introductory Special”. The Introductory Special offer says it lasts only until July so I guess at that point Microsoft Online Services will start charging your credit card for any services that are in use.

WARNING: The introductory offer only includes 25 hours of compute time. You can easily burn through that by just leaving your deployment running(faster if you have both a staging and production deployment running).Make sure you DELETE (not suspend; you must DELETE)your hosted service deployment (see below) when you have finished with this tutorial.

windows azure 第一个程序Hello World

Clicking on the Buy button takes me to the Microsoft Online Services customer portal where you can sign in with your Windows Live account and sign up for the Windows Azure Service. NOTE: Signing up on the Microsoft Online Services site is a multi-step process where you first create your account, then checkout with the Windows Azure Introductory Special in your shopping cart, activate your service, and finally specify the service administrator.

Here is the Service Activation Screen where I have specified the project name as “AzureHelloWorld”. This project name will be the project that is created in the Windows Azure Portal later on (what’s up with those purple borders around everything?!?).

windows azure 第一个程序Hello World

Now you will have a subscription to Windows Azure and after a little bit the Microsoft Online Services Customer Portal will show that the Service is Active:

windows azure 第一个程序Hello World

Now you can go to the Windows Azure Portal (http://windows.azure.com) and sign in with the same Windows Live account that you used to sign up for the subscription at Microsoft Online Services.

Now you will see the Windows Azure Portal home page with a single project named from when you activated the service (in my case, AzureHelloWorld).

windows azure 第一个程序Hello World

Select this project and choose New Service which is located to the right and just above the project name:windows azure 第一个程序Hello World

Choose the Hosted Services from the two Windows Azure services that are presented:

windows azure 第一个程序Hello World

Then name the service:

windows azure 第一个程序Hello World

Then choose a url for your service and also the region where it will be running:

windows azure 第一个程序Hello World

Clicking Next will get you to the Deployment page:

windows azure 第一个程序Hello World

Now you are at the point where you can deploy your Hello World project that you created earlier, but first you have to use Visual Studio to Publish it.

Return to your Hello World Visual Studio Windows Azure project and right click on the HelloWorld Azure Project and click “Publish…”:

windows azure 第一个程序Hello World

This will create the deployment package and the configuration package (and open Windows Explorer to their location too):

windows azure 第一个程序Hello World

A new browser will be opened and you will be taken to the Windows Azure Portal but you can close that and return to the previous window where the Deploy cube was showing:

windows azure 第一个程序Hello World

Click that “Deploy…” button and browse to the application package (*.cspkg) and configuration settings (*.cscfg) and then give a name for this deployment:

windows azure 第一个程序Hello World

and finally click the Deploy button. Your files will begin copying:

windows azure 第一个程序Hello World

And then you will see your package getting deployed:

windows azure 第一个程序Hello World

Then once it is deployed, you can click Run and your application will begin initializing:

windows azure 第一个程序Hello World

This took a while for me but eventually it finished (I actually went to lunch so I am not sure how long it took but it was greater than 10 minutes).

windows azure 第一个程序Hello World

And now when you browse to the cloudapp.net web site url on your console you will get your Windows Azure Hello World:

windows azure 第一个程序Hello World

windows azure 第一个程序Hello World

And there you have it… a successfully created and deployed (and running) Windows Azure Hello World application from beginning to end.

DON'T FORGET: Make sure your DELETE your hosted service deployment when you are finished trying out Windows Azure. The introductory offer only includes 25 hours of compute time. You can easily burn through that by just leaving your deployment running(faster if you have both a staging and production deployment running). And only suspended it does not stop the hours from accumulating. You will need to DELETE the hosted service deployment to stop the compute hours from accumulating.

现在也就只能在本地测试,那个什么免费的服务Introductory Special在China Mainland没有开放,ms给的解释如下:

Unfortunately, China Mainlandwill not be supported during our PDC release. Please understand there're a lot of legal issues for us to solve before we can provide our service in a particular country.Without a credit card in a supported country, you will not be able to use our services.We will supportChina in the future. Below is a list of countries that we plan to support during our PDC and March 2010 releases:无语。。。