• [微软云计算]Quick Lap around the Windows Azure Tools for Microsoft Visual Studio


    Windows Azure Tools for Microsoft Visual Studio extend Visual Studio to enable the creation, building, debugging, running and packaging of scalable services on Windows Azure.

    Creating a new Cloud Service

    Start Visual Studio 2008 or Visual Studio 2010 Beta 1 as an administrator.

    Create a new project.  (File | New | Project)

    In the C# and VB project templates notice a new group called “Cloud Services” and select the “Cloud Service” template

    Give the project a name and hit Ok

    Add a Web Role to the solution by selecting the “ASP.NET Web Role” item and clicking the right arrow.

    ProjectCreation.jpg

    Note that you can easily add multiple Web and Worker roles to your Cloud Service solution.

    Rename “WebRole1” to “MyWebRole” by clicking on the edit button on the right side of the item (will appear on mouse over) and click “OK”.

    You should have a solution with two projects

    • A Cloud Service project
    • A Web Role which is an ASP.NET Web Application

    Solution explorer will look like this:

    solutionexplorer.jpg

    Modify the web role project

    Go to Default.aspx and switch to design view.

    aspxdesignview.jpg

    Add a heading.

    Add a button with an event handler.

    addbuttonandevent.jpg

    Double click the button to add an event handler when the Button is clicked.

    In the Event Handler, write a trace message.  In order to use the RoleManager API, you will need to add a using to the Microsoft.ServiceHosting.ServiceRuntime namespace.

    using Microsoft.ServiceHosting.ServiceRuntime;

    C#
    protected void Button1_Click(object sender, EventArgs e)
    {
        RoleManager.WriteToLog("Information", "Doing my lap around the tools and clicking the button");
    }

    Add a breakpoint to the line of code you just added in the Button Click Event Handler.

    Building and Debugging the Cloud Service

    Build the project or right click the Cloud Service project and select “Build”.

    Interested in the build output? Right click the Cloud Service project and select “Open Folder in Windows Explorer”. Drill into the bin"debug directory to see the build output (this is produced by the Windows Azure SDK tool - cspack.exe).

    openfolder.jpg

    Modify the number of instances to run.

    Select a Role under the Roles node in the Solution Explorer, right click and select “Properties”.

    In the Properties Window, set the instance count property to “2”.

    properties.jpg

    Note that the current limitation for the number of instances of each Role on Windows Azure in the Cloud is 2 per Role.

    The ServiceConfiguration.cscfg file should look like this:

    <?xml version="1.0"?>

    <ServiceConfiguration serviceName="CloudService9" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration">

      <Role name="MyWebRole">

        <Instances count="2"/>

        <ConfigurationSettings/>

      </Role>

    </ServiceConfiguration>

    Debug the project

    Select Debug -> Start Debugging (F5).

    Note that a Development Fabric icon is added to the system tray that allows you to bring up the Development Fabric UI or to shutdown the Development Fabric altogether.

    devfabrictray.jpg

    If you click “Show Development Fabric UI” the following window will be brought up that will give you additional control over your running Deployments and a view of their logging.

    The trace message you log in the button push will show up in the log window for the instance that services the request.

    devfabric.jpg

    If this is your first time using Development Storage, the Development Storage initialization dialog will come up:

    DevStorageInit.jpg

    Hit “OK” to dismiss.

    Note that a Development Storage icon is added to the system tray that allows you to bring up the UI to control the Development Storage services.

    devstoragetray.jpg

    Clicking on “Show Development Storage UI” brings up the following dialog:

    storage.jpg

    IE will start up automatically pointing to your web site. The full address will be similar to http://127.0.0.1:8080/default.aspx .

    When you click the button, you will hit the breakpoint that you set in the debugger.

    Look at the Development Fabric UI to see your message in the trace log.

    Note that any one of the instances could process the request.

    log.jpg

    Publishing the Cloud Service

    Create the Service Package (cspkg) by right clicking on the Cloud Service project node and selecting “Publish”.

    publish.jpg

    Explorer will open to the folder containing the Service Configuration file and Service Package (.cspkg).  This file along with the Service Configuration file (cscfg) are the files you upload via the Azure Services Developer Portal to run your application on Windows Azure.

    A browser window will open to the Azure Services Developer Portal where you can upload and deploy your service. (See Deploying a Service on Windows Azure for more information)

    devportal2.jpg

    This completes the Quick Lap around the Windows Azure Tools for Microsoft Visual Studio.

  • 相关阅读:
    图片延迟加载
    JS 数组操作
    XML转成dataset
    Android的layout_weight使用方法
    Android五大布局学习笔记【转 有改动】
    JSONP
    Android中dip、dp、sp、pt和px的区别和使用
    捕鱼和分鱼
    Android中可能导致ActivityNotFoundException的一些问题总结
    一张图片引发的思考——Android图片加载
  • 原文地址:https://www.cnblogs.com/kellen/p/1568684.html
Copyright © 2020-2023  润新知