Continuous deploy of multiple Azure Cloud Services within a single solution using TFS Online

Team Foundation Server is a fantastic configuration management system that integrates with the full Microsoft development stack.

With Windows Azure and its TFS online integration, continuous deploy can easily be set up and customized. However, one frustration I came across, is that I have a solution that has a worker role and a web role. I want these deployed to separate Cloud Services within my Azure Subscription, but the AzureContinuousDeployment build process only supports targeting the first project to be deployed.

In order to get around this, we can modify the AzureContinuousDeployment process to allow the developer to dictate which Cloud Service project to deploy. The first step to do this is to duplicate the AzureContinuousDeployment.11.xaml workflow. You can do this by opening the Source Control Explorer in Visual Studio, and navigating to the BuildProcessTemplates folder.

You will see, in the right hand pane, a list of the Build Process Templates that are available to you.

Build Process Templates

You can copy AzureContinuousDeployment.11.xaml and use the copied Build Process Template to create the alternate template that will allow you to dictate which Cloud Service is deployed.

When you open the copied xaml file you will see the, hopefully familiar, Windows Workflow designer. What we are going to do is modify the process flow to allow the definition of the Cloud Service to deploy.

When you open the xaml file, find the block that defines the Cloud Service to deploy, it will look like this:

Find the Azure Project

You’ll notice that the action that finds the Azure Project in the solution has no inputs to it, this is because it simply looks for the first Azure Project in the solution. In order to look for others, we need to define the MSBuild target name of the Azure Project.

To do this we first need to add an argument to the build process template that can then be configured in the build definition.

Open the argument editor by clicking “Arguments” at the bottom of the content pane and add a new argument.

Next, we can change the block that defines the Azure Project to check if the Alternate MS Build Target has been set and if it is, set ccProjName, the variable that captures the Azure project name, to that value.

We can now save this build process template, and select it in the build definition.

Finally, we need to choose the project that we want to deploy from the build definition.

We do this by setting the AlternateMSBuildTarget argument to the target name that we want to deploy. This is usually the name of the project with _ (underscore) replacing . (period). So, for example, if your project name was “Ebenezer.Web.Azure”, you would use “Ebenezer_Web_Azure”.

3 Comments to “Continuous deploy of multiple Azure Cloud Services within a single solution using TFS Online”

  1. Thanks! This is exactly what I was looking for. Here is the code that was generated in case anyone wants to copy and paste this in..

    <If Condition="[Not String.IsNullOrEmpty(AlternateMSBuildTarget)]" DisplayName="If Alternate MSBuild Target Is Available">
    <If.Then>
    <Assign x:TypeArguments="x:String" DisplayName="Set ccProjName to AlternateMSBuild" To="[ccprojName]" Value="[AlternateMSBuildTarget]" sap2010:WorkflowViewState.IdRef="Assign`1_22" />
    </If.Then>
    <If.Else>
    <mtdwa:FindCCProjInSln DisplayName="Find the Azure Project in the Solution" sap2010:WorkflowViewState.IdRef="FindCCProjInSln_1" mtbwt:BuildTrackingParticipant.Importance="Low" Result="[ccprojName]" SolutionPath="[localProject]" />
    </If.Else>
    <sap2010:WorkflowViewState.IdRef>If_49</sap2010:WorkflowViewState.IdRef>
    </If>

  2. Thank you so much for posting this. The solution worked perfectly.

Leave a reply to Anthony Cancel reply