'How to show the path of the script of the Azure runbook in Bicep?

I am want to deploy an Azure Automation Account runbook with Bicep with below code:

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 want to use a runbook which is on my Azure Repos. Can I use a relative path such as ../scripts/runbook.ps1 as I do in Powershell? I see that there isn't any property for that but I am asking if I miss anything.



Solution 1:[1]

As explained here, you may leverage 'uri' property.

To use a relative path, you may leverage parameter section and variable section. Something like:

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
}]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 KrishnaG-MSFT