Problem
I’d like to use Bicep to deploy an Azure Automation Account runbook that looks like this:
resource automationAccount 'Microsoft.Automation/automationAccounts@2019-06-01' = {
name: 'name'
}
resource automationRunbook 'Microsoft.Automation/automationAccounts/runbooks@2019-06-01' = {
parent: automationAccount
name: 'name'
location: 'westeurope'
properties: {
logVerbose: true
logProgress: true
runbookType: 'Script'
publishContentLink: {
uri: 'uri'
version: '1.0.0.0'
}
description: 'description'
}
}
I’d like to use a runbook from my Azure Repos. Is it possible to utilize a relative path like../scripts/runbook.ps1 like I do with Powershell? I see that there isn’t a property for that, but I’m curious if there is anything I’m missing.
Asked by MoonHorse
Solution #1
As explained here, you may leverage ‘uri’ property.
You can utilize the parameter and variable sections to create a relative path. Something along these lines:
param runbooksUri string = 'https://xxxxxxxxxxxxxxxx/xxxxx/xxxxx/'
var testScripts = {
testrunbooks: [
{
name: 'XXXXXXX'
url: uri(runbooksUri, 'xxxxxxx.ps1')
}
{
name: 'YYYYYYY'
url: uri(runbooksUri, 'yyyyyyy.ps1')
}
]
}
resource automationRunbook 'Microsoft.Automation/automationAccounts/runbooks@2019-06-01' = [for i in range(0, length(testScripts.testrunbooks)): {
xxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx
properties: {
publishContentLink: {
uri: testScripts.testrunbooks[i].url
xxxxxxxxxxxxxxxxxxxxxxxxx
}
}
xxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx
}]
Answered by KrishnaG-MSFT
Post is based on https://stackoverflow.com/questions/70835046/how-to-show-the-path-of-the-script-of-the-azure-runbook-in-bicep