Question

I am working on a ASP.net MVC4 project where a same project needs to be deployed to many clients on daily basis, each client will have its own domain / sub domain and a separate app pool and db (MSSSQL).

Doing each deployment manually could take at least 1-2 hours if everything goes well. Is there anyway using which I can do this in some automated way?

Moreover, we also need to update all of the apps when a new version is released.. may be one by one or all of them at same time. However, doing this manually could take weeks and once we have more clients then it will not possible doing this update manually.

The update involves, suspending app for some time, taking a full backup of files and db, update application code/ files in app folder, upgrade db with a script and then start app, doing some diagnosis script to check if update was successful or not, if not we need to check what went wrong?

How can we automate this updates? Any idea would be great on how to approach this issue.

Was it helpful?

Solution

As a developer for BuildMaster, I can say that this scenario, known as the "Core Version" pattern, is a common one. If you're OK with a paid solution, you can setup your deployment plans within the tool that do exactly what you described.

As a more concrete example, we experience this exact situation in a slightly different way. BuildMaster has a set of 60+ extensions that rely on a specific SDK version. In our recent 4.0 release, we had to re-deploy every extension because of breaking API changes within the SDK. This is essentially equivalent to having a bunch of customers and deploying to them all at once. We have set up our deployment plans such that any time we create a new release of the SDK application, we have the option to set a variable that says to build every extension that relies on the SDK:

BuildMaster 4.0 SDK

In BuildMaster, the idea is to promote a build (i.e. an immutable object that travels through various environments like Dev, Test, Staging, Prod) to its final environment (where it becomes the deployed build for the release). In your case, this would be pushing your MVC application to its final environment, and that would then trigger the deployments of all dependent applications (i.e. your customers' instances of your application). For our SDK, the plan looks like this:

BuildMaster SDK Release Plan

For your scenario, you would only need the single action, "Promote Build". As I mentioned before, any dependents would then be promoted to their final environments, so all your customer deployments would kick off once that action is run during deployment. As an example, our Azure extension's deployment plan for its final environment looks like this (internal URLs redacted):

Azure Extensions Release Plan

You may have noticed that these plans are marked "Shared", which means every extension we have has the exact same deployment plan, but utilizes different variables to handle the minor differences like names, paths, etc.

Since this is such an enormous topic I could go on for ages, but I think that should be sufficient for your use-case if you wanted to try it out.

OTHER TIPS

There are others but you could setup Team Server Foundation to deploy automated builds.

http://msdn.microsoft.com/en-us/library/ff650529.aspx

I find the easiest way to do this from an MVC project is to create a publish profile. This is done by right-clicking your project selecting publish and then configuring it to your needs.

Then from TFS you create a new build definition, this kicks of a wizard which takes you through it. There are quite a few options which would be too long to go into for every scenario.

The main change I usually find the most important is to set an MSBuild Argument to deploy with the publish profile. This can be found at Process > Advanced > MSBuild Arguments.

MsBuild args

Once this is configured correctly it's a simple case of right-clicking and queue new build to build and deploy. You wil need different PublishProfile/Build configuration per deployment environment.

For backups I use a powershell script which can be called manually or from TFS. You also have a drop folder in TFS which keeps a backup of x many releases.

The datbases are automatically configured via Sql server to backup, TBH I didn't set that up it was a DB admin guy who is also involved with releases.

From a dev testing side I use jMeter (http://jmeter.apache.org/) to run some automated scripts that check that users can login and view certain screens, just to confirm nothing major has gone wrong. However there is usually a testing team to run more detailed tests, again not setup by me.

All of the above will probably take you sometime to setup but in the long run it will literally save you weeks of time over a year.

A free alternative to TFS is http://www.cruisecontrolnet.org/, I have used this in the past too and is pretty good.

You can automate your .Net deployments with Beanstalk, which will give you a way to trigger deployments with a single click, watch progress, manage permissions and see history of deployments. Check out this guide on the topic:

http://guides.beanstalkapp.com/deployments/deploy-dotnet.html

I hope you will find it useful.

P.S. - I work at Beanstalk.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top