I have a DevOps pipeline for setting up various resources within a resource group in Azure.
As part of the pipeline I would like to import a runbook to the resource group, and set up a schedule for it to run within the portal (not set up a DevOps schedule).
The docs explain how to create a runbook from the azure cli:
az automation runbook create --automation-account-name "myAutomationAccount" --resource-group "rg" --name "myRunbook" --type "PowerShell" --location "East US 2"
but do not explain how import the runbook from a DevOps repo.
How do I import the runbook from a DevOps pipeline using the cli.
Also how can I create a schedule in the portal (using the cli within the DevOps pipeline) on which to run the runbook?
I import runbooks regularly. But I go a little different way. In Azure DevOps, I call a webhook with parameters and then start a runbook that imports the runbooks from Azure DevOps. In addition, I no longer use the PowerShell modules for the import but do everything via the API, which is much faster.
https://docs.microsoft.com/en-us/rest/api/automation/runbook/create-or-update
First, I create the runbook as a draft, adding the content and publishing the runbook.
It can also be done the other way, directly from Azure DevOps, but Azure Automation is my main tool, so I did it there. Of course, there is still source control in Azure Automation, where you can also have the code imported automatically. But I can do everything the same way with the runbook, and I'm very flexible with the webhook!
Stefan
Figured out how to do it using the following commands with the appropriate arguments passed through --automation-account-name --name --resource-group --type Powershell --location
for the first call etc:
az automation runbook create
az automation runbook replace-content --content @./Repo_name/runbook_name.ps1
az automation runbook publish
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.