Give the most tedioust jobs to your laziest employee and they will automate it.
My boss

That’s right. I am lazy. I hate repetitive tasks. And as a developer you probably feel the same way.

One of those repetitive tasks is deployment

There are numerous ways and frameworks to set up automated builds and deployments. Some of them can do just about anything almost up to the point where they will make you coffee while you wait for your builds.

Recently while working on a small ASP.NET Core website I found out that Microsoft Azure has a very simple deployment tool for building and deploying from your favourite code repository to an Azure web application. I was especially happy to find that it supports BitBucket even though it seems anything not-on-Github is not cool.

Well, I am too old to be cool and I like Bitbucket so bear with me.

Setup

Setup is a breeze. Got to the new Azure portal and create your new web application.

After the web app has been created, go to your web app and choose “Deployment Options”.

azure-deployment-options

The next steps allow you to log in to your source code provider (i.e. Bitbucket) and choose project and branch (typically the master branch). The beauty here is that Azure supports pulling code from all kinds of sources like Dropbox, Onedrive, Github, and of course Bitbucket.

azure-deployment-options-configure

After you save your settings, Azure will fetch your last commit and start building it. You can se the progress by clicking “Deployment options” again.

azure-deployment-progress

Build Errors?

It looks like Microsoft has just recently upgraded the compiler but I have previously run into problems with building newer C# features such as inline declaration of variables like so.

var salaries = new Dictionary<string, decimal>()
{
    { "Jakob", 10000000000 },
    { "Some other guy", 42 },
};

// Inlining variable declaration
if (salaries.TryGetValue("Jakob", out var salary))
{
    // Do something with salary.
}

If you run into this problem, all you need to do is add the Nuget package Microsoft.Net.Compilers to your project. This will make sure that your project is compiled with the latest C# compiler.

Conclusion

This kind of deployment is extremely simple and easy, which is a good thing. On the other hand it will not run any unit tests in your project and it will deploy straight to production without any testing or staging. You might consider this solution for smaller, non-mission-critical sites.

Leave a comment

Your email address will not be published. Required fields are marked *