Sunday 14 June 2015

How to Deploy to Azure Websites with TFS build 2013 and VS Release Management 2013

Deploying to azure websites while having multiple web projects in a single solution is challenging with TFS 2013 builds.
http://stackoverflow.com/questions/4832154/webdeploy-to-deploy-multiple-web-sites
http://stackoverflow.com/questions/6457108/how-to-tell-tfs-to-deploy-multiple-webapps-containing-in-one-solution
The new VSO build allows this to be done very easily.
http://geekswithblogs.net/jakob/archive/2015/04/29/deploying-an-azure-web-site-using-tfs-build-vnext.aspx
Inspired with below two articles, deploying to azure websites with TFS build 2013 and VS Release Management 2013, is explained in this post.
http://www.colinsalmcorner.com/post/webdeploy-and-release-management--the-proper-way
http://blogs.blackmarble.co.uk/blogs/rfennell/post/2014/09/18/Using-MSDEPLOY-from-Release-Management-to-deploy-Azure-web-sites.aspx
First requirement is getting the the build to package the website. For this right click on the Web Project and click on publish.
1
Click on Custom and provide a name to the publish profile.
2
3
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).
4
Set the configuration to Release.
4
Click publish and this will create package files in the project folder and add publish profile to the Project.
6
6.2
Publish profile contains site name value with prefix and suffix __  as DeployIisAppPath.
7

Published package in project folder contains required files to deploy the web site.
7.2
7.3
In SetParameters file the site name with __ available.
7.4
Setup a TFS Build  to package the solution. Use build arguments to package the web site with publish profile.
/p:CreatePackageOnPublish=true /p:DeployOnBuild=true;PublishProfile="TFSAzureRelease"
22
This will create the package and copy to build drop location.
25
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
10
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.
11
12
14
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.
16
17

Acceptance step set to Automated to trigger a release from the build.
18
Next create a new release template. Select the build created earlier.
19
For the release template add a new agent based component.
20
21

Provide the build drop location for the component (Web site package path in the build drop).
26
Select the tool created in the deployment tab.
27
In the configuration variables tab set the AzureWebAppName parameter for SetParameters file and click Save&Close.
27.2
Link the component to current template.
28
29

Add the component to template and set the parameters. The values should be obtained from the publish profile of the target Azure web site.
30
Using below steps Azure Web Site can be created in Azure Management portal and obtain the publish profile.
36
37
38
Parameter values for publishing available in publish profile.
39
It is possible to add more web projects to Visual Studio solution and add them with a publish profile with the same name.
35
46

It is possible to add components using the tool and create a template to deploy multiple azure websites like shown below.
47
Sites can be deployed with release template.
48
34
52

No comments:

Popular Posts