Using Azure DevOps Pipelines with Azure Automation
Azure Automation is a robust, cross platform and powerful automation engine for script based process-automation. If you are unfamiliar with Azure Automation, have a look at the official docs here.
Azure Automation has native support for GitHub and Azure DevOps (vsoGit) repositories used as source control for runbooks. The basic setup of source control integration is a quite simple and easy step. However, the concept behind this out of the box functionality might not fit a CI/CD concept. Azure Automation source control sync jobs are built to sync code changes either automatically or manually into the runbooks container. To learn about the basic steps to activate source control see the docs here.
While this might fit basic requirements, I recently had a project where the customer had the requirement to integrate runbook code changes into a CI/CD pipeline. As he is already using Azure DevOps pipelines the way to the new solution was pretty easy.
So, let’s see how this is built.
Step by Step Procedure
De-activate auto sync (we don’t want to sync the runbooks automatically on code change commits)
Create a new script runbook (Start-DevOpsSourceControlSync), which initiates the manual synchronization. We will call the runbook at a later stage from the CD pipeline
Create Service Connection
Create Build Pipeline
Create Release Pipeline
As you can see, we now have a fully integrated CI/CD pipeline, everytime someone pushes code changes to our master branch. Needless to note that in production environments you’d have multiple stages for the deployments and branch policy for master branch, preventing direct pushes. But for the purpose of this demo I wanted to keep the steps as simple as possible.