Setting up an Umbraco Baseline-ish flow with Azure Devops
Tags: umbraco, devops, azure
Published: 2020-12-08 21:39:23

In my previous post I outlined [my experiences with Umbraco Cloud](https://dev.to/timgeyssens/is-umbraco-cloud-a-good-fit-for-your-umbraco-project-34dh). It boils down to the fact that if you are a team of devs and follow a gitflow or similar release management workflow Cloud just isn't an option. 

So I was investigating alternatives that allow a release management workflow... but I still want a baseline and auto upgrades.

#Azure devops
> DevOps is the union of people, process, and products to enable continuous delivery of value to our end users.

Devops consists of a lot more but in this post I'll outline how I'll use CI 
> Continuous Integration (CI) is the process of automating the build and testing of code every time a team member commits changes to version control.

and CD

> Continuous Delivery (CD) is the process to build, test, configure and deploy from a build to a production environment.

Of course when developing Umbraco sites you keep your code in sourcecontrol adding CI into the mix we can make sure the code "builds" when new changes are commited. 

## Staging site
For simplicity I'll keep everyting in [Azure devops](https://azure.microsoft.com/en-us/services/devops/). But you can also have this in for example github.

Say I have a Umbraco project with a Core + Web + Test project.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/bqsahj7yslyw5n5agzq0.png)

You can then first setup a pipeline that builds and deploys the test version (from the release branch). So new features get developed on feature branches, when they need to go to the client for review you create a pull request or merge the feature branch with release. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/p4h2mer1cxctl5wn5vhm.png)

Setting this up is pretty simple..just add a new pipeline (and I tend to pick the classic visual editor)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/cf2398apuumxtktu4pqz.png)

Next you need to select the source... when picking azure you just need to select from dropdowns (which project/repo/branch), easy!

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/x4m6mrlq1ukkhte4pn5h.png)

After that you can select a pipeline template (I pick the azure web app for asp.net, since Umbraco is a asp.net web app and I want to deploy to azure)..

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/yyazpwnzz78dfd0cr46m.png)

Picking that template most stuff is already in place.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/tgw97y3tjzojqfdcmlhm.png)

The only step that needs attention is selecting the azure subscription and App service you want to deploy to... (so of course you need an  azure subscription with an existing app service).

Once all that is selected you now have a working CI, CD process for a test environment. So codes get's pushed to the release branch... that triggers a build and deploy...

One small side note, best is to enable xml transformation on the Azure App Service deploy task, that way you can have  *.Release.config  file transforms (like for settings that are different between your dev env and the actual test env). Stuff like conn strings can be also set that way but also on devops or in azure... (depending on how you want it configured). Plus of not having it in sourcecontrol is that there is an extra level of security (sensitive settings shouldn't go in source control).

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ufld7ec1q72eo5ygp1iu.png)

##Live sites
Of course now we have a staging version of the baseline site... but I also want child websites using that base...

So adding a new pipeline that will build an artifact (webdeploy package) from the main branch. Following the same steps as before but removing some tasks and adding 1 new one

This will now run when new code is commited to the main branch... each time a new artifact will be generated.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/juiwybfcju5t8vm2dpux.png)

Important here is the Artifact name (we need this name later) and also the File or directory path, for this I used an available variable $(System.DefaultWorkingDirectory)\ (not sure if that is the correct way but it works!)

Next is setting up the release pipeline, so in the releases part of pipelines just add a new one (this should get you started with an artifact and stage)


![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/p880b1wx7yqvh47psq00.png)

The artifact then points to the latest pipeline (where we create the artifact), we also need to specify the artifact name here. (needs to match with what is on the pipeline)

Finaly a task per child is setup... this just uses a Azure App Service deploy task that points to the correct app service (again you need to have the app service created on your portal)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/qclz04g06dzc3uuyr5fo.png)

Again stuff like conn string shoudln't be set in the web.config in source control but you can set these in devops or in the azure portal.

So now when the build of the artifact is finished the deploy will happen to my 2 child sites using the same base...

#Basics
Of course this outlines the basics... I also have [uSync](https://github.com/KevinJump/uSync8) in the mix that handles the version control of a lot of umbraco stuff (like doctypes,datatypes,...) and auto imports these on the child sites...
Then with [silent upgrade](https://our.umbraco.com/packages/website-utilities/ourumbracosilentupgrade/) also a amazing free addon to Umbraco from [Kevin Jump](https://jumoo.co.uk/) added we can first test an upgrade localy and if that succeeds roll it out as part of a release ... just add the nuget package and set <add key="SilentUpgrade" value="true" /> (possible with a config transform)

#Further
Now I have 1 codebase for all the sites... with a [theme picker](https://dev.to/timgeyssens/setting-up-an-umbraco-site-theme-picker-including-a-context-aware-approved-color-picker-for-multisite-environments-4ila) this could work in having a different look and feel for each child site... so a content defined theme... if you do want a different code base that is also possible. New git repo, add the base as an origin and you can pull/push from the base... of course you then need to setup a new build/release pipeline for that case...

You could also have staging sites for all the child one... just create a release artifact and add a new release pipeline...deploying to staging locations...

Of course blog storage is also possible, again, each child would have it's own config...

Key is to develop with the concept of a base site in mind, so make everything as flexible as possible, might even introduce some interfaces so you can switch different bits depending on config. For example an applicant tracking system, child a might be using umbraco content, child b an external api... making that swappable still allows a single code base...

If you want to fetch content from live to develop/test against you can add [uSync complete](https://jumoo.co.uk/usync/complete/) that contains [uSync publisher](https://jumoo.co.uk/usync/publisher/). Or just download the db and run on that locally...


#Pros
* Plug and play in your existing dev flow (doesn't matter where you have your sourcecode, github, bitbucket,...)
* Superbe logging of each step, if something goes wrong you have detailed logs available in devops... you can see them as the build/deploy is in progress
* Possible to run unit tests and don't deploy if these fail
* Not a single point of failure, say the hosting goes down you can setup a deploy to a new endpoint... devops goes down, use a publish profile directly from vs
* No sudden price increase when you hit certain usage limits (pageviews/node/domain/bandwidth/media) it just scales depending on what you use.
* You can take advantage of the already existing task in devops to further finetune the CI CD , like a [site warmup step](https://marketplace.visualstudio.com/items?itemName=luuksommers.website-warmup), thanks [Sjors](https://twitter.com/sjorspa)!
* Forum support included ;) 
* Kevin provides stellar support (even for his free addons)

#Cons
* You need some devops/azure knowledge (but plenty of documentation out there, since it is all coupled to your microsoft account it's super easy to select the correct stuff...)
* Setting up a new child takes some manual work (about 30 mins) create app service, db, update the release pipeline...(you could look into automating this if you have the knowledge/time)

#Overall
Unless Umbraco Cloud introduces a significant price drop and would allow for a release management workflow I wouldn't look back twice. Azure Devops is a really mature product that makes the whole continuous Integration/delivery a breeze...

From what I hear other folks are also using [Octopus Deploy](https://octopus.com/) and [Github actions](https://github.com/features/actions) to get a similar workflow.