Turn: Windows Azure Platform Experience (1): Windows Azure

Windows Azure Platform have Windows Azure, SQL Azure, Azure AppFabric three parts.

Windows Azure has provided a compute, storage, hosting and management capabilities scalable environment. It is through a secure connection, messaging and identity management applications linked to internal deployment.

This section of our experience Windows Azure, the necessary software:

Microsoft Visual Studio 2010

This experience are the following steps, namely:

Create a cloud service project to create a cloud services

First, understand the role of Web hosting features, take advantage of this feature, we create a new site, then it will be hosted in Windows Azure.

An administrator start Visual Studio 2010, create a new Azure cloud service project. Select the "cloud" template type "Windows Azure cloud services" project template. After this new project named "HelloAzure", click "OK", immediately pop up a new wizard.

c966fcfb10aa6ac59f514672.jpg

In this guide, you can create several different types of roles for the cloud applications, so that I can install and configure these roles in real-life applications. You can see, there are a number of different ASP.NET Web Role, the top is the standard ASP.NET Web role. If you want to develop MVC types of applications, you can use MVC 2 Web role. In addition, there's a WCF Web service roles. All these roles (including the bottom of the CGI Web role) will run in a standard Windows Azure Web role. By clicking on the right side (ie, the center of the screen) arrow can accomplish the above tasks, and then add more such projects in the same solution.

This section describes the Web my role, so I select "ASP.NET Web Role" item and click the right arrow to the right, if necessary, you can also choose other roles (such as worker role) to add to this project. Please note that, in fact, you can also create multiple identical applications. After example, if you want to host two different sites within the Windows Azure ASP.NET solutions that I can select ASP.NET Web Role to add the role again. Now, I only choose one, add a Web role to the solution.

Click the Edit button to the right of the project, "WebRole1" rename "HelloAzure_WebRole". Hover your mouse over items will be displayed on the Edit button. Click "OK."

fbacb28866361eff0e244472.jpg

After the wizard completes, all files are created, you should have a solution that contains the following two items:

Cloud Services

Solution Explorer look as shown below:

8330c6b2f54353ebd8335a72.jpg

Our simple modification of Web pages, and as usual, open Default.aspx and switch to Design view. Open the toolbox, and double-click "Button" tool to add a button to the page. Double-click the new button on the page to add an event handler. This is not a screenshot.

Some configuration changes Azure applications

You can see, there are a number of cloud services configuration file, a file is ServiceConfiguration other is ServiceDefinition file. For example, if you want to run the Web role in two separate instances, in order to extend the Web application.

Under Select a role in the "Solution Explorer" in the "role" node, then right-click and select "Properties." This will show the role of Web properties page. Property page can be edited using the service elements and characteristics of each role service level definition files and configuration files. Examples of the counter changed from 1 to 2.

c45201942f24bc07d0135e72.jpg

I make changes in the user interface, and then save the changes. We can see, so that the following changes to the configuration file.

ae7d4e0086e3969a267fb573.jpg

Debugging Cloud Services

Select the "Debug" -> "Start Debugging" (F5).

如果出现一个错误对话框,显示“Windows Azure Tools: Failed to initialize Development Storage service. Unable to start Development Storage. Failed to start Development Storage: the SQL Server instance ‘localhost\SQLExpress’ could not be found.Please configure the SQL Server instance for Development Storage using the ‘DSInit’ utility in the Windows Azure SDK.”错误,则需要手动配置开发存储的数据库实例。

cc22644ad17b62bc83025c72.jpg

打开开始菜单Windows Azure SDK v1.2目录的Windows Azure SDK Command Prompt。键入“DSInit /sqlinstance:.”即配置开发存储的数据库实例。

9f6393aea0675ab7faed5072.jpg

如果是第一次使用开发存储,则将显示开发存储初始化对话框:

b96e82fafd85ba28024f5672.jpg

初始化完成之后,单击“确定”关闭对话框。

浏览器将自动启动并指向您的网站。完整地址将类似于 http://127.0.0.1:81/default.aspx。

当单击按钮时,这时会命中在调试器中设置的断点。我可以像以前一样调试。将鼠标悬停在标签的实际文本属性上,可以看到,属性值的设置正确无误。 我可以像以前一样执行所有的标准调试任务,例如,我可以按F10和F11来单步执行和逐过程执行代码,开发体验和以往并无不同。

e68c62650b2769bcf6365472.jpg

ea5766c275591b19b219a873.jpg

请注意,所有的这些都托管在本地工作站的虚拟Windows Azure云基础结构中,并且采用了称为“开发结构用户界面”和“开发存储用户界面”的形式,系统任务栏中提供一个Windows Azure图标,您可以通过此图标显示Development Fabric用户界面和开发存储用户界面或者关闭这些服务。我们可以打开这些用户界面,看看你这些服务时如何运行的。

当然,存储基础结构模拟的是Windows Azure存储服务,开发结构功能则代表最终在云中部署后要运行的Web角色功能和工作者角色功能。

6450c354bd71fa88b645ae73.jpg

现在加载开发结构用户界面,单击“Show Development Fabric UI”,Development Fabric实用工具将出现。您可以使用此实用工具来管理本地开发并查看这些开发的日志数据。

ae7822c5a72d52e58326ac73.jpg

可以看到,左侧是工作站中运行所有的Windows Azure开发基础结构或项目的预览。 在这里只有一个项目,它的ID是4,右侧是这个Web应用程序以及在这个服务中运行的所有其他Web应用程序的详细信息。可以看到,这里只有一项。另外请 注意,从这里可以看出,部署到云中后,最终配置将从默认端口80运行。 不过,为了进行本地部署,已对它进行映射,在这里是映射至端口81,和之前浏览器窗口中显示的一样。

然后,我们看部署的每个Web角色和工作者角色的详细信息。我们可以看到有两个独立的WebRole控制台:一个是“0”,一个是“1”。这是因为 他们被当做两个独立的实例在本地工作站中运行。 两个实例的旁边都有一个绿色小圆圈,说明他们的运行和加载都是成功的。 每个控制台内显示的具体详细信息,这些信息十分详尽,所有组成部分都紧密相连,保证了实际角色在计算机中的正确运行。如果出现需要解决的问题,可以利用这 些信息来排除故障。如果需要输出跟踪信息,也可以在这里显示这些信息。

9f4706fd0a7f9bceb801a073.jpg

如果您正在使用开发存储服务,则可以右击 Windows Azure 任务栏图标并选择“Show Development Storage UI”以显示下面的对话框,该对话框将使您能够控制正在运行的存储服务并重置所有数据。

a4608391ee6b62c1a877a473.jpg

好,一切运行正常,我们有了一个本地运行的Windows Azure云应用程序。接下来,可以继续进行开发或调试等等工作,本地开发体验相当完善。不过,在应用程序运行之后,现在需要将它实际部署到 Windows Azure云中, 这样,就可以与能够访问实际云的用户共享我的应用程序。

发布云服务项目

右击“云服务”项目节点并选择“发布”,将这个应用程序发布到云中。

eb62ba8cb31f285eb21bba73.jpg

从“发布云服务”对话框中,这里有两个选项:可以将服务包直接部署到 Windows Azure中。也可以选择生成服务包并通过开发人员门户网站自己上载它。在这里,我选择仅创建服务包,单击“确定”按钮。

ae7a7950e6719754377abe73.jpg

这样,应用程序的应用程序文件便打成了包,然后会启动一个新的Windows资源管理器窗口,显示创建的文件。

可以看到,最上面的是一个“CS Package”类型的文件“HelloCloud”这就是实际的云服务应用程序,这个文件有点大。第二个文件是整个应用程序的配置文件。Windows Azure根据这个文件进行实际配置,如每个角色需要运行的实例数、角色需要的配置方式等等。

e5784f191612cbf84bedbc73.jpg

上传云服务项目

这时使用账号登录Windows Azure开发人员门户网站,网址为http://windows.azure.com/,创建一个新项目,然后部署这些文件。

点击我的项目中的项目名称:

2b1b13b568853f3f8ad4b273.jpg

出现Window Azure概况页,可以看到当前没有任何服务,我们点击“New Service”创建一个新的Windows Azure服务。

578ce772afbca2508601b073.jpg

在创建服务页面中,我可以选择创建“Storage Account”(存储账户)还是“Hosted Services”(托管服务)。我们选择托管服务,这是因为我们有一个需要托管的ASP.NET网站。

96b57a1da169b0c786d6b673.jpg

接下来,为新服务填写有意义的标签和描述,以便以后区分。点击“Next”(下一步)完成服务的创建。

9a60688aafbe36339f2fb473.jpg

然后进行最后的一些设置工作。首先,需要为它提供一个公共托管的URL,用来访问这个Web应用程序。不过,因为这是一个共享服务,其他人可能选用 过类似的名称。 因此,需要执行“check availablity”(检查可用性)执行可用性检查,确保名称可用。接下来,需要选择将Windows Azure应用程序托管在哪个数据中心或地区,可以在整个清单中选择,比如说,我选择“东亚”。如果有多个应用程序,例如需要相互交流数据信息的 Windows Azure应用程序与SQL Azure数据库,就可以使用本页面底部的相关性组,确保这些应用程序位于同一个数据中心内。完成这一段设置之后,最后一个步骤是单击“Create” (创建)按钮,创建可以部署应用程序的最终基础结构。

9ab7ee7eb447164429388a73.jpg

创建需要几分钟的时间,可以看到,这个服务的名称以及刚才输入的描述都显示出来了,在下面的“Hosted Service”(托管服务)中,可以选择是将应用程序部署在“Production”(生产)还是“Staging”(分段)环境中。这个两个选项都可 以选择,我也可以在两者之间方便的切换,因此可以在生产环境和分段环境之间轻松转移应用程序和部署。不过,现在我不选择分段环境,而是直接选择生产环境, 以便直接查看实际托管的应用程序。

我们直接开始部署,单击“Deploy...”(部署)按钮。

834ece0904500e7ce8248873.jpg

这时会出现一个新窗体,在这个窗体中,上传实际的应用程序文件和整个应用程序的配置文件。操作系统选择默认设置,填写部署标签。单击“Deloy”(部署)按钮。

3559d631c74ca9d5a8018e73.jpg

Upload application files and system configuration files, these files into Windows Azure in order to determine the best way to deploy applications, a process that requires continuous 5-10 minutes.

Upon completion of this step, the application can be put into actual operation, because now it is in the final stages of a similar "on hold". If you stop the run, there will be this state, this state is set to perform other steps or upgrade an already operational applications. However, now we click "Run" (run).

f445719899695d446f068c73.jpg

You can see, the application has been deployed to the virtual environment, is launching these virtual environments. Then there is a small yellow status indicator, indicating the role of Web initializing state.

b46085095c6e0cd90b7b8273.jpg

Automatic screen refresh, you can see from "Initializing" (initializing) state into a "Busy" (busy). Eventually it turned into a green state, only when the status icon turns green, the state becomes the "Ready" (Ready), indicating that the deployment has been completed and put into operation in Windows Azure.

7367d4943e1313447af48073.jpg

We can access the cloud service through the URL.

171acb094d9c1b9d63d98673.jpg

Well, I experience a bit from start to finish Windows Azure cloud applications. Use VS tools for development, structure and localization development environment used in the past, we can perform tasks such as local debugging. Finally, after everything is ready, through simple steps to deploy the application to the Microsoft Windows Azure cloud services.

Reproduced in: https: //www.cnblogs.com/Tim_Liu/archive/2011/01/25/1944390.html

Guess you like

Origin blog.csdn.net/weixin_34268169/article/details/94724542