Managing Roles in the Windows Azure Project with Visual Studio
After you have created your Windows Azure project, you can add new roles to it or remove existing roles from it. Additionally, you can import an existing project and convert it to a role. For example, you can import an ASP.NET web application and designate it as a web role.
Adding or Removing Roles
To add a role, open the shortcut menu for the Roles node and choose Add. You can select a web role or worker role from the current solution or create a new web or worker role project. Or you can select an appropriate project, such as an ASP.NET web application project, and associate it with a role project.
To remove a role association, open the shortcut menu for the Roles node in the Windows Azure project and choose Remove.
Removing and Adding Roles Back Into Your Solution
If you remove a role and later you need to add that existing role back into the current solution, only the role declaration and basic attributes are added. For example, endpoints and diagnostics information are added. Any additional resources and references are not added into the ServiceDefinition.csdef file or into the ServiceConfiguration.cscfg file. You must manually add this information back into these files.
For example, you might remove a Web service role and later you decide to add this role back into your solution. If you do this, an error will occur. To prevent this error, you must add the <LocalResources> element shown in the following XML back into the ServiceDefinition.csdef file. Us the name of the Web service role that you added back into the solution as part of the name attribute for the <LocalStorage> element. In this example the name of the Web service role is WCFServiceWebRole1:
<WebRole name="WCFServiceWebRole1"> <Sites> <Site name="Web"> <Bindings> <Binding name="Endpoint1" endpointName="Endpoint1" /> </Bindings> </Site> </Sites> <Endpoints> <InputEndpoint name="Endpoint1" protocol="http" port="80" /> </Endpoints> <Imports> <Import moduleName="Diagnostics" /> </Imports> <LocalResources> <LocalStorage name="WCFServiceWebRole1.svclog" sizeInMB="1000" cleanOnRoleRecycle="false" /> </LocalResources> </WebRole>
Changing a Project that is Associated with a Role
You can change the project that is associated with a specific role in your Windows Azure Project. You have two options:
Associate a role with a new project
Associate a role with an existing project
Associate a Web or Worker Role with a New Project
Open the Roles node in Solution Explorer.
Open the shortcut menu for the existing node for which you want to change the project association and choose Associate with, New <Type of Role> Project (the menu selection changes to reflect the role type). The Add New Role Project dialog box is displayed with the appropriate project template for the role type you selected.
Name the project and click OK.
A new project is created in the solution, and the Roles node is updated to show the association to the newly created project. The previous project associated with the role remains in the solution.
Associate an Existing Project with an Existing Web or Worker Role
In the solution that contains your Windows Azure project, load or create the existing role project that you want to associate with a specific role.
Open the shortcut menu for the existing node for which you want to change the project association and select Associate with, <Type of Role> Project in solution (the menu selection changes to reflect the role type). The Associate with Role Project dialog box displays a list of the projects in the current solution that have the same role type as the role you are changing.
Choose the project with which you want to associate the role, and click OK.
The Roles node is updated to display the project association and the previous project associated with the role remains in the solution.