Windows azure platform (13) develops a simple hello World

Source: Internet
Author: User
Tags windows azure sdk sql server express microsoft website azure sdk

In the previous chapter, I spent about eight chapters on the concept of Windows azure. From this chapter, we entered the actual hands-on and coding process.

Although Windows azure cloud computing is ultimately to deploy applications to Microsoft's cloud data center, Microsoft also provides the Windows azure SDK to facilitate debugging through local Visual Studio 2010, use the azure emulator simulator to simulate the execution of Windows azure.

 

Make the following preparations:

1. Install Windows 7 or above, or install Windows Server 2008, Windows Server 2008 r2

2. Install iis7 and configure ASP. NET and wcf http service

3. install Microsoft Visual Studio 2010 Professional edition or later development tools (or install Microsoft Visual Web Developer 2010 express), and ensure that you have a certain understanding of Microsoft Visual Studio and C.

4. Install SQL Server Express

5. Install Windows azure SDK for. Net (the latest version is November 2011), http://www.microsoft.com/download/en/details.aspx? Id = 28045

6. For specific installation requirements, please refer to the Microsoft website http://www.microsoft.com/download/en/details.aspx? Id = 28045

After the installation is complete, you can right-click the Visual Studio 2010 shortcut on the desktop, and choose Properties and compatibility to run the tool as an administrator.Program

 

Let's make a simple hello world first!

Start Visual Studio and select new project. At this time, you will find a cloud project under the C # project. I will change the project name to hellowindowsazure, and then select "OK"

In this case, the form "new windows azure project" is displayed"

Select "ASP. NET web role", click the ">" button in the middle, select "worker role", and press the ">" button in the middle.

Webrole1 and workerrole1 are displayed on the right. This is the two role of Windows Azure I introduced earlier.

We can see that webrole1 is actually an ASP. NET web application.

Then I want to change the solution name of webrole1. I move the mouse over "webrole1" and the "click to rename the project" appears. The solution input box is displayed to facilitate your input.

I changed this solution to mywebrole and press enter to save it. (The worker role name can be modified in the same way)

After saving, press "OK ".

In this case, the familiar Visual Studio project appears. On the right side of the Solution Explorer (solution form), we can see

 

Here we first change the configuration to expand the hellowindowsazure project --> roles --> mywebrole --> right-click --> attribute

A new window will pop up.

I changed instance to 3 and VM Size to small.

 

Next, let's look at the project mywebrole.

This project is a typical ASP. Net project with familiar aspx, aspx. CS, global. asax, Web. config, etc.

However, I have added a webrole. CS file, which will be detailed in the following chapters.

 

Finally, wokerrole1 is a project named workerrole. cs. We double-click it to open the file. The content is as follows:

Let's go to the run function and make some modifications, such as the Red area.

Then press F5, and an empty ASP. NET page will appear.

This page is the startup page we set in mywebrole project. Note that the Web role is actually used for display. The displayed content is our ASPX page.

The page is successfully executed. In addition, a Windows icon appears in the lower right corner of the desktop during startup:

Open the taskbar, right-click the image, and select "show compute emulator UI"

Windows azure comput emulator and computing simulator will appear

Expand deploymenet (505), hellowindowsazure, and workerrole. The red area is displayed, indicating that the simulator simulates the running of three independent computing nodes, we can select a green computing node for switching:

 

Move the mouse over workerrole1 and select "0" in green"

Take a closer look at the yellow area of my subject: enter a text section every 10 seconds in the information area. The executed content is the function in webrole. CS:

 

CodeIn the clip, thread. Sleep (10000) indicates the content in the callback function body executed every 10000 milliseconds (10 seconds.

We found that the worker role is like a Windows service and has no interface. It is executed silently in the background. Of course, you can also change thread. Sleep (10000) and modify the time of each execution.

 

Well, this part of content is here, and there are a lot of content in this chapter. I hope everyone can download Microsoft's Windows azure SDK for actual development, if you have any questions, please send me a letter on the site. Thank you!

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.