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:
- Upload your script to Azure Blob Storage: You can automate the upload using the Azure CLI or SDKs, then get the blob URL.
- 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!!