My GitHub repo shows how to set up an Azure DevOps Continuous Deployment (CD) pipeline for deploying an Azure Automation account & associated Runbooks.

Deployment
- Clone the repo & upload into your own Azure DevOps instance.
- Modify the
/ado/env&/infra/envfiles to match your Azure & Azure DevOps environment. - Select the
Pipelinesblade in Azure DevOps and click onNew pipeline - Select where your have stored your source code, select
Existing Azure Pipelines YAML file, select the Branch (likelymain) and set the Path to/ado/deploy-automation.yml. Savethe pipeline.- In the upper right-hand corner of the screen, select the
User Settingsbutton and selectPersonal Access Tokens. This PAT will be used by the Azure Automation account to pull the runbooks from source control. - Click
New Token, give it a name that reminds you what it will be for (example:AzureAutomation). Set the Expiration. Add the following scopes (click on theCustom definedradio button to see them all).- Code – Read
- Identity – Read
- Project and Team – Read
- Service Connections – Read, query, & manage
- User Profile – Read
- Work Items – Read
- Copy the PAT to Notepad.
- Navigate back to the pipeline and click on
Edit. - Click
Variablesand thenNew variable. - Name the variable
AdoPat, paste in the PAT string you copied earlier & check theKeep this value secretcheckbox. ClickOkto save. - Click
Run pipelineto execute. You may need toauthorizethe pipeline to use the service connection. This initial run will create all of the required Azure resources & set up the sync, but it will fail the first time becuase you need to grant the Managed Identity that the Automation Account usesContributoraccess to the Resource Group so it can createRunbookresources (https://docs.microsoft.com/en-us/azure/automation/source-control-integration#prerequisites). - In the Azure portal, navigate to your Resource Group. Click on the
Access controlblade. Click onAdd->Add Role assignment.- Select the
Contributorrole. ClickNext. - Select the
Managed identityradio button. ClickSelect members. - Select the managed identity that was created in your resource groups. Click `Select.
- Click
Review + assign.
- Select the
- Run the pipeline again to see the sync occur.
You can now see the Azure Automation Source Control link & Runbook sync job complete in the Azure portal.

