;

Enabling WebDeploy in an Auto-Deployed Azure Cloud Service

Posted : Monday, 31 March 2014 21:49:00

I’ve just started a fantastic new job at truRating – it’s a really cool startup and 5 weeks in I am loving it. Its a really great team, great product and loads and loads of cool Tech. A large number of the components which comprise out application ecosystem are C# projects of one type or another and for the most part they’re hosted in Windows Azure. After establishing the environments we will initially support and an effective naming strategy for the various components (essentially based around a <brand>-<environment>-<product> pattern), we’re currently finalising our deployment/release pipeline.

My colleague Toby Reid did an excellent job of setting up TeamCity to build and deploy each of the components that comprise an environment and while this is very effective and well managed, there is a significant lead time (>10minutes) between the build being triggered and the code being available for any of the team to test/review/enjoy etc. This is principally down to the Azure resource commissioning system and the Blue-Green deployment process. While this is exactly what we want for most environments, one of the things we really need is a CD (Continuous Delivery) environment where, on every commit, the code is automatically compiled, unit tested and deployed to the CD environment as soon as possible.

One of the things I’ve become a massive fan of over the last couple of year is the WebDeploy deployment tool, there are tons of resources out there and I have blogged about how great it is before. Its a free install and easy to add via the Web Platform Installer. The principle attraction of the tool to me is just how fast it is – I previously worked in a team where we needed to deploy a platform consisting of 12 separate components and by moving from using MSBuild to build and deploy each step to a single initial step which built all the packages and then subsequent WebDeploy steps to actually install them the build time was cut by 60%.

NB this should not be implemented in a production environment for numerous obvious reasons. Also using WebDeploy in Azure requires the following (all reasonable) conditions to be met:

For development and testing purposes only

Only web roles can be updated

Can only support a single instance of a web role

You must enable remote desktop connections

I began a quest to see if we could use WebDeploy in our Azure cloud services...

After a few days struggling I have managed to discover, digest and harness the beauty that is WebDeploy in Microsoft Azure cloud services. This can be thought of as two distinct challenges. The first challenge is to create a cloud service capable of hosting a  WebDeploy service, the second (and far more simple) challenge is to WebDeploy into the cloud service. Incidentally publishing from Visual Studio gives different results than publishing from command-line/TeamCity and given that what we want is fully automated deployment (why would you ever want anything but?) – the goal of this exercise was to support WebDeploy on a newly created Azure cloud service with no manual intervention.

I have covered the important parts of each step below:

1) Create the Microsoft Azure cloud service

The Visual Studio publish wizard gives a lovely helpful dialogue which is pretty clear about how to go about this:

image

Indeed hitting publish after completing the wizard creates a new cloud service with three endpoints (browsing port 80, Remote Desktop port 3343 and WebDeploy port 8172). Lovely. Save the publish settings and we’re good to go right? Wrong!

I run publish from Visual Studio and can WebDeploy and Remote Desktop to the cloud service fine...

image

...but when I executed the build from the command-line the WebDeploy endpoint disappeared...

image

This drove me mad for about a day and a half!

So, Googling gave me nothing, Bing gave me nothing and DuckDuckGo DuckDuckWent! There were some helpful posts from guys a few years back but nothing since – I had to figure this one out myself. The heart of the problem was that Visual Studio MUST be doing something extra/different than plain old MSBuild from the command line. I ran the Visual Studio publish, verified the Cloud service was deployed with WebDeploy enabled and saved the contents of the Azure cloud project bin directory. Then I ran the build from the command line, verified that WebDeploy was not enabled and compared the service definition (.csdef) files from the two deployments.

The contents of the non-WebDeployable (non-working) ServiceDefinition.csdef file are shown below:

<ServiceDefinition name="ContinuousDelivery" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion=" Post a comment Sharespacer Tagged: ASP.NET, VisualStudio, Productivity
  • (This will not appear on the site)