Share via

Creating runbook content with Bicep

bombbe 1,486 Reputation points
2026-02-16T14:21:10.1466667+00:00

Hello,

I have created automation account + runbooks with Bicep and next then would be to creating the content for the runbooks. I have created the script that is located in my repository.

The issue I'm facing is that every document and blog post that I can find, always publishing content is pointing to some "real" url.

 publishContentLink: {
      uri: 'https://github.com'
    }


I'm wondering do this support something like this:

var scriptContent = loadTextContent('powerhsell/myautomation.ps1')
or
scriptContent: loadTextContent('powershell/myautomation.ps1')

and then just

    publishContentLink: {
      uri: 'scriptContent'
    }

so it could pull the script from repo during the deployment.

Azure Automation
Azure Automation

An Azure service that is used to automate, configure, and install updates across hybrid environments.

{count} votes

Answer accepted by question author
  1. Q&A Assist
    2026-02-16T14:21:19.8733333+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    In Azure Bicep, when you want to publish runbook content, you typically need to provide a publicly accessible URL for the publishContentLink. Unfortunately, you cannot directly use the loadTextContent function to set the uri in the publishContentLink. The publishContentLink requires a URL that points to the actual content of the runbook, which must be accessible over the internet.

    If you want to include the script content from your repository, you would need to host the script in a location that provides a public URL, such as a GitHub raw file link or an Azure Blob Storage URL. You cannot use a variable like scriptContent to set the uri directly in publishContentLink as shown in your example.

    To summarize, you need to ensure that the script is hosted at a publicly accessible URL for the publishContentLink to work properly during deployment.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Siva shunmugam Nadessin 5,970 Reputation points Microsoft External Staff Moderator
    2026-02-16T16:40:16.91+00:00

    Hello bombbe

    Thank you for reaching out to the Microsoft Q&A forum.

    It looks like you're trying to load content from a local or repository-based script into the publishContentLink for your Azure Automation runbooks, but the publishContentLink typically expects a publicly accessible URL pointing to the script.

    Unfortunately, Azure Automation doesn't support referencing a script directly via a variable like scriptContent: loadTextContent('powershell/myautomation.ps1') for the publishContentLink. It requires the uri to point to a location that is publicly accessible, like a GitHub repository, or a storage account URL. Here's why:

    • The publishContentLink property expects a direct URI that points to where the script is hosted (such as a GitHub link, a storage account, or any other accessible location).
    • Azure Automation doesn't have built-in support for directly loading a script from a repository or internal resource without making it publicly accessible or hosting it on an Azure service like Blob Storage.

    However, you could automate the deployment of your scripts into Azure Storage and then use that storage URL in publishContentLink. Here's a general approach you can take:

    1. Upload your script to Azure Blob Storage: You can automate the upload using the Azure CLI or SDKs, then get the blob URL.
    2. Use that URL in your publishContentLink: For example:
    resource automationAccount 'Microsoft.Automation/automationAccounts@2019-06-01' = {
      name: 'myAutomationAccount'
      location: 'East US'
    }
    resource runbook 'Microsoft.Automation/automationAccounts/runbooks@2019-06-01' = {
      name: 'myRunbook'
      parent: automationAccount
      properties: {
        runbookType: 'PowerShell'
        publishContentLink: {
          uri: 'https://<yourstorageaccount>.blob.core.windows.net/scripts/myautomation.ps1'
        }
      }
    }
    
    

    This way, you're storing the script in Azure Blob Storage and pointing the publishContentLink to it. If you prefer a GitHub-based approach, you'd use the raw GitHub URL like so:

    publishContentLink:

    {   uri: 'https://<URL>/username/repository/branch/script.ps1' }

    Let me know if you need help with automating any part of that process!!


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.