共用方式為


Working with Multiple Web and Worker Roles

After you install the July 2009 CTP and create a new project via File | New Project | Cloud Service, you now have a single template “Cloud Service” instead of the 4 you had in the past.

Clicking on that brings up our new project creation dialog. 

image

There are a couple of reasons we have this dialog:

  1. In the past, we only allowed you to have 0 or 1 Web Roles and 0 or 1 Worker roles in your Cloud Service.  Now you can have 0 to N of either type.  We want to help you create the Service Model you want to have.
  2. We want to expose multiple templates for you to use for each of the Roles.  For example, we’re working to one day have an MVC Web Role, Dynamic Data Web Role and more.  We not only want you to create the Service Model you want to have but also using a selection of different templates for each Role.

You can add Web and Worker Roles to the Cloud Service solution, rename the projects and hit OK to create the Cloud Service.  Try adding 2 Web Roles and 2 Worker Roles.

image

You’ll have a solution that matches:

image

Note that you’ll want to setup the port numbers for your input endpoints in the ServiceDefinition.csdef. 

We auto-generate what we hope to be safe numbers but don’t know what your intention is for each of the Web Roles – at this point in time, a second or third Web Role cannot be assigned to a sub domain, they can only be differentiated by port.

When you hit F5, we’ll bring up a web browser instance for each of the Web Roles. 

If you don’t want us to bring up a Web Browser instance for a given web role, right click on the associated Role under the Roles node and deselect “Launch Browser”.

image

Also note that when you close one web browser, your debugging session will end.

Comments

  • Anonymous
    July 23, 2009
    So how does this work when you migrate to the cloud? From memory you can only use ports 80 and 443 in Azure. Does this not render multiple roles useless in this case then? If so, how can one have multiple sites in the current CTP offering?

  • Anonymous
    July 24, 2009
    The restriction of only using port 80 and 443 is gone away.  We mistakenly shipped a comment in the Service Definition which indicates otherwise and will be removed in our next release. That said, because only one web role can get port 80, the other web role will need to be accessed by appending the port to the domain.  This would be interesting if you want to have an admin console web role.

  • Anonymous
    July 26, 2009
    Great, thanks for that info. An admin section is what I am after so a different port number will be fine. I take it adding another project with a web role will not be available until launch?

  • Anonymous
    July 27, 2009
    I'm not sure I'm understanding your last question -- "adding another project with a web role will not be available until launch?". The way I read that, you can do that today, you would go to Solution Explorer, right click on the Roles node | Add | New Web Role project... Perhaps I'm misreading your question?

  • Anonymous
    July 27, 2009
    Sorry Jim. I mean create another web project that can be launched under port 80. IE. A complete new Azure project.

  • Anonymous
    July 28, 2009
    I see, yes, there are requests to support this, especially if those web apps could be hosted on the same VM to lower the cost.  It is on our list, and we're working out the how and when.