How to automatically deploy a Team Foundation Service + Git Project on Azure (Step by Step)
Two weeks ago, Me and my partners, we decided to start a new project using Team Foundation Service with Git and host it on Azure. As usual, we start developing a full happy path from project creation until deployment, to test all the infrastructure involved. The TFS Account creation was OK, the Git repository was also OK, but when we tried to setup the build configuration to automatically publish our project after an automated build, we start to have some issues. We found this declaration on MSDN.
Deploying from TFS’s git repository to Windows Azure is not yet supported. It is on our radar tentatively mid of this year.
- Microsoft Employee
We can’t (until today) configure our Azure Website to deploy from a Git repository through Azure’s Portal. We end up, through the help of others blogs , configuring a trigger on team foundation service to publish our project after an successful commit. Community is all about share what we learn, so I decided to write a step by step tutorial that maybe can help someone with the same difficulties that we had or maybe we can receive more feedback and we improve even more our solution.
1. Creating a Team Foundation Service + Git project.
1.1 – Logged in your TFS Account. Click in “New Team Project + Git” button.
1.2 – Fill up the form. Remember that you can’t rename this project in the future.
1.3 – Click on “Navigate to project” and you will see your project info.
2. Creating a WebApp
2.1 – Click on “Open new instance of Visual Studio” to open an Visual Studio instance linked to your project.
2.2 – Clone your git repository and choose your repository folder, remember the folder’s name cause after you will create your Web Application in this same folder.
2.3 – Create a MVC 4 Web Application in your repository folder.
2.4 – Commit it. Now we have a deployable project. The next step is to create our Azure WebSite.
3 – Creating the Azure WebSite
3.1 – Logged in your Azure Portal, create a new azure website.
3.2 – Download the publish profile.
4 – Configuring the automated deploy
4.1 – Import the publish profile that we downloaded. It will create a publish profile folder in our MVC project.
4.2 – Configure a new build definition.
Go to Team Explorer -> Builds -> New Build Definition and create a new build definition.
On Trigger Tab, set the “Continuous Integration” radio, so the build will occur after each check in.
On Source Settings Tab, select the managed branch.
On Process Tab, fill the solution to build field with ‘MyApp.sln’.
Also fill the MsBuild arguments field with the following value:
/p:DeployOnBuild=true /p:PublishProfile=”pauloortinsblog – Web Deploy” /p:AllowUntrustedCertificate=true /p:UserName=$pauloortinsblog /p:Password=Re7ACb3g6By9idLoi6gsWGbdc8AK49HxqaEFNzxxxxxxxxxxxxxxx /p:VisualStudioVersion=11.0
You should get the UserName and the Password from the Publish Profile file.
4.3 – Enable Build Services.
On your TFS Account -> Build Section, you need to add the build services to your account in the following section.
5 – Testing the happy path
5.1 – Let’s make a change in one of our files, Index.cshtml.
5.2 – Committing the change and pushing it to the repository.
5.3 – A new build was queued on Team Foundation Service
5.4 – After the build the finished, the WebApp was deployed automatically.
This is it. I hope this post might help someone. You can also feel free to suggest an improvement in this process!