Deploying to azure websites while having multiple web projects in a single solution is challenging with TFS 2013 builds.
The new VSO build allows this to be done very easily.
Inspired with below two articles, deploying to azure websites with TFS build 2013 and VS Release Management 2013, is explained in this post.
First requirement is getting the the build to package the website. For this right click on the Web Project and click on publish.
Click on Custom and provide a name to the publish profile.
Select webDeployPackage as publish method. Package name should be ProjectName.Zip.
Set site name with __ as prefix and suffix for RM server to understand it as a token (parameter).
Set the configuration to Release.
Click publish and this will create package files in the project folder and add publish profile to the Project.
Publish profile contains site name value with prefix and suffix __ as DeployIisAppPath.
Published package in project folder contains required files to deploy the web site.
In SetParameters file the site name with __ available.
Setup a TFS Build to package the solution. Use build arguments to package the web site with publish profile.
This will create the package and copy to build drop location.
Next step required is to setup a Release Management tool to deploy the package created. Collin’s ALM Corner post here shared the irmsdeploy.exe required to create the tool.
__WebAppName__.deploy.cmd /y /m:"https://__PublishUrl__/MsDeploy.axd" -allowUntrusted /u:"__PublishUser__" /p:"__PublishPassword__" /a:Basic
Create environment to deploy from is the next requirement. For this setup RM Agent in a machine with VS 2013 is available. Setting up RM Agent explained here.
Register the RM Agent machine with the RM server create environment and a release path.
In the environment add the server and allow for all stages. All stages allow here since deployments to all azure environments in all stages can be done via same agent machine.
Acceptance step set to Automated to trigger a release from the build.
Next create a new release template. Select the build created earlier.
For the release template add a new agent based component.
Provide the build drop location for the component (Web site package path in the build drop).
Select the tool created in the deployment tab.
In the configuration variables tab set the AzureWebAppName parameter for SetParameters file and click Save&Close.
Link the component to current template.
Add the component to template and set the parameters. The values should be obtained from the publish profile of the target Azure web site.
Using below steps Azure Web Site can be created in Azure Management portal and obtain the publish profile.
Parameter values for publishing available in publish profile.
It is possible to add more web projects to Visual Studio solution and add them with a publish profile with the same name.
It is possible to add components using the tool and create a template to deploy multiple azure websites like shown below.
Sites can be deployed with release template.