Managing Roles in the Windows Azure Project with Visual Studio
Updated: February 5, 2014
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. Use 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>