Windows Azure Platform Experience (1): Windows Azure

Source: Internet
Author: User
Tags cgi web windows azure sdk hosting web hosting virtual environment visual studio 2010 azure sdk

Create a Cloud service project

First understand the web hosting role feature, and with this feature, we create a new Web site and then host it in Windows Azure.

Start Visual Studio 2010 as an administrator and create a new Azure cloud service project. Select the Windows Azure Cloud Service project template for the cloud template type. Name the new project "Helloazure", and immediately after clicking OK, a new wizard pops up.

In this wizard, you can create some different types of roles for this cloud application so that I can install and configure these roles in a real-world application. As you can see, there are a number of different ASP. NET Web roles, the top of which is the ASP. NET standard Web role. If you are developing an MVC-type application, you can use the MVC 2 Web role. In addition, there is a WCF Service Web role. All of these roles, including the bottom CGI Web role, will run within the standard Windows Azure Web role. You can do this by clicking the arrows on the right (that is, the center of the screen) to add multiple such items to the same solution.

This section I describe Web roles, so I select the "ASP. NET Web Role" item and click the right arrow to move to the right, and optionally add other roles (such as worker roles) to this project if needed. Note that, in fact, you can also create multiple identical applications. For example, if you want to host two different ASP. NET Web sites within a Windows Azure solution, I can add this role again after I select the ASP. Now, I'll just select one and add the Web role to the solution.

Click the Edit button to the right of the item to rename "WebRole1" to "Helloazure_webrole". Hovering the mouse over the item will display the Edit button. Click OK.

After the wizard finishes running, after you create all the files, you should have a solution that contains the following two items:

    • Cloud Services Project
    • Web role as an ASP. NET Web Application

The Solution Explorer looks like the following:

We simply modify the Web page below, and as usual, open the default.aspx and switch to Design view. Open the Toolbox and double-click the Buttons tool to add a button to the page. Double-click the New button on the page to add an event handler. That's not going to be.

Modify some configurations of an azure application

As you can see, the Cloud service project has some configuration files, one is the Serviceconfiguration file and the other is the Servicedefinition file. For example, if you want to run this web role in two separate instances in order to extend the Web application.

In Solution Explorer, select a role under the Roles node, and then right-click and select Properties. This displays the properties page for the Web role. Use the property pages to edit each role-level element and attribute in the service definition file and service configuration file. Change the instance count from 1 to 2.

I make the changes in the user interface, and then save the changes. As you can see, this changes the following configuration file.

Debugging a cloud service project

Select Debug, Start Debugging (F5).

If an error dialog box appears, the Windows Azure tools:failed to initialize development Storage service is displayed. Unable to start development Storage. Failed to start development storage:the SQL Server instance ' localhost\sqlexpress ' could isn't be found. Please configure the SQL Server instance for development Storage using the ' dsinit ' utility in the Windows Azure SDK. " Error, you need to manually configure the database instance where the development is stored.

Open the Start menu Windows Azure SDK v1.2 directory for Windows Azure SDK Command Prompt. Type "dsinit/sqlinstance:." A database instance that is configured to develop storage.

If you are using the development store for the first time, the Development Storage Initialization dialog box is displayed:

When the initialization is complete, click OK to close the dialog box.

The browser will automatically start and point to your website. The full address will be similar to http://127.0.0.1:81/default.aspx.

When the button is clicked, a breakpoint set in the debugger is hit. I can debug as before. Hover over the actual text property of the label to see that the property value is set correctly. I can perform all the standard debugging tasks as before, for example, I can press F10 and F11 to step through and process code over and over, and the development experience is not different from the past.

Note that all of these are hosted on the local workstation's virtual Windows Azure cloud infrastructure and are in the form of a "Development fabric user Interface" and a "Development storage user Interface", which provides a Windows Azure icon in the system tray. You can use this icon to display the development fabric user interface and develop a storage user interface or to turn off these services. We can open these user interfaces and see how you run these services.

Of course, the storage infrastructure simulates the Windows Azure Storage service, and the development structure features represent the Web role features and worker role features that will run after the eventual deployment in the cloud.

Now that the development structure user interface is loaded, click on the "Show development fabric UI" and the development fabric utility will appear. You can use this utility to manage local development and view the log data for these developments.

As you can see, the left side is a preview of all Windows Azure development infrastructure or projects running in the workstation. There is only one item here, its ID is 4, and the right side is the details of this Web application and all other Web applications running in the service. As you can see, there is only one item. Also note that, as you can see from here, the final configuration will run from the default port of 80 when deployed to the cloud. However, for a local deployment, it has been mapped, where it is mapped to port 81, as shown in the previous browser window.

We then look at the details of each Web role and worker role deployed. We can see that there are two independent webrole consoles: one is "0" and the other is "1". This is because they are run as two separate instances on a local workstation. There is a small green circle next to each of the two instances, indicating that their operation and loading are successful. The detailed information that is displayed in each console is detailed and all components are closely connected to ensure that the actual role is running correctly on the computer. If there are problems that need to be addressed, you can use this information to troubleshoot. If you need to output trace information, you can also display this information here.

If you are using the development storage service, you can right-click the Windows Azure taskbar icon and select Show development Storage UI to display the following dialog box, which will enable you to control the running storage service and reset all data.

OK, everything works fine, we have a locally run Windows Azure cloud application. Next, you can continue to work on development or debugging, and the local development experience is quite complete. However, after the application runs, it is now necessary to actually deploy it to the Windows Azure cloud, so that you can share my application with users who have access to the actual cloud.

Publish a Cloud service project

Publish this application to the cloud by right-clicking the cloud Services project node and selecting Publish.

From the Publish Cloud Service dialog box, there are two options: You can deploy the service pack directly to Windows Azure. You can also choose to build a service pack and upload it yourself through the Developer portal site. Here, I choose to create only service packs and click the OK button.

This way, the application's application files are made into a package, and then a new Windows Explorer window is launched to display the created files.

As can be seen, the top is a "CS package" type of File "Hellocloud" This is the actual cloud service application, this file is a bit large. The second file is a configuration file for the entire application. Windows Azure is actually configured based on this file, such as the number of instances each role needs to run, how the roles need to be configured, and so on.

Uploading a cloud service project

Use your account to log in to the Windows Azure Developer Portal, http://windows.azure.com/, create a new project, and deploy the files.

Click on the project name in my project:

The Window Azure Overview page appears, and you can see that there are currently no services, and we click "New Service" to create a new Windows Azure service.

In the Create service page, I can choose to create a "Storage account" or "Hosted Services" (Managed service). We choose hosting services because we have an ASP. NET site that needs to be hosted.

Next, fill in the meaningful tags and descriptions for the new service so that you can differentiate later. Click "Next" to complete the creation of the service.

Then do some final setup work. First, you need to provide it with a public-managed URL to access the Web application. However, because this is a shared service, other people may have chosen a similar name. Therefore, you need to perform a "Check availablity" (check availability) to perform an availability check to make sure that the name is available. Next, you need to choose which data center or region you want to host your Windows Azure application in, and you can choose from the entire list, for example, I choose East Asia. If you have multiple applications, such as Windows Azure applications and SQL Azure databases that need to communicate data to each other, you can use the affinity groups at the bottom of this page to ensure that these applications are in the same datacenter. After you complete this set, the final step is to click the Create button to create the final infrastructure that you can deploy your application to.

The creation takes a few minutes, and you can see that the name of the service and the description you just entered are displayed, and in the "Hosted service" below, you can choose whether to deploy the application in "Production" (production) or "Staging" (segmented) environment. This two option is optional and I can easily switch between the two so that applications and deployments can be easily transferred between the production and staging environments. However, now I do not select a staging environment, but instead directly select the production environment in order to view the actual hosted application directly.

We start the deployment directly and click the Deploy button.

A new form appears in this form, uploading the actual application files and the entire application's configuration file. The operating system selects the default settings and fills in the Deployment tab. Click the Deloy (Deploy) button.

The system uploads the application files and configuration files and puts them into Windows Azure to determine the best way to deploy the application, which takes 5-10 minutes to continue.

After you complete this step, you can actually put the application into operation because it is now in a final phase similar to the "Paused state". If you stop running, you will also get this state, which performs other setup steps or upgrades an application that is already operational. However, now we click "Run".

As you can see, the application is already deployed in a virtual environment and is starting these virtual environments. At this point there is a small yellow status indicator stating that the Web role is initializing the state.

The screen is automatically refreshed, and you can see that the status from "Initializing" (initializing) becomes "Busy" (busy). It turns into a green state, and when the status icon turns green and the status changes to ready, the deployment is complete and running in Windows Azure.

We can access this cloud service through a URL.

Well, I've been through the Windows Azure Cloud app from beginning to end. With the VS tool for development, we can perform tasks such as local debugging, just like the localized development architecture environment used previously. Finally, when you're ready, deploy your application to Microsoft Windows Azure cloud Services in a simple step.

Copyright NOTICE: This article for Bo Master http://www.zuiniusn.com original article, without Bo Master permission not reproduced.

Windows Azure Platform Experience (1): Windows Azure

Related Article

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.