Saturday, 27 June 2015

Access TFS Deployed in an Azure VM

A TFS server setup in a Azure VM, in a virtual network and a domain, can be exposed to public access by following below steps.
The TFS server should be up and running and it should be accessible other virtual machines in the domain. DNS in setup in domain controller to resolve the TFS server internal static IP.
image
 2.2
It is required to identify the public IP of the TFS server. Public IP can be found by clicking on Azure VM and then going to dashboard of the VM.
1 
In a local machine which have internet access, this public IP can be added to the host file to allow to resolve name.
3
When try to access TFS server in azure VM in local machine it fails.
2
Attempt with IP address does not work.
4
This is due to TFS port 8080 in Azure VM is not accessible publicly (form local machine).
Fist allow 8080 port for public access in TFS Server.
image
To enable access add an endpoint allowing 8080 publicly as shown below for the TFS VM.
5
6

Specify TCP port 8080 for Public and Private ports.
7
8
Once end point is successfully configured TFS hosted in cloud can be accessed with local machine.
9
10

Sunday, 21 June 2015

Resolve ERROR_FILE_IN_USE When Deploying Azure Web Site with RM Server

ERROR_FILE_IN_USE error might occur if the Azure website is online while the deployment is taking place using the RM server Component. The full error message in log is below.
*******************************************************************************************************
Error Code: ERROR_FILE_IN_USE
More Information: Web Deploy cannot modify the file 'webapp-log.txt' on the dest
ination because it is locked by an external process.  In order to allow the publ
ish operation to succeed, you may need to either restart your application to rel
ease the lock, or use the AppOffline rule handler for .Net applications on your
next publish attempt.
  Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FILE_IN_USE
.
Error: I/O error occurred.
Error count: 1.
*******************************************************************************************************
As the link in the error suggests solution is making the app offline while the deployment happens. Set the –enableRule:AppOffline in RM tool will allow the RM tool based deployments to azure to avoid above error.
image

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