How to publish a Runbook to latest runtime version using blob storage?

André Lindqvist 20 Reputation points
2025-02-12T12:46:12.4666667+00:00

Hi, so i have written a Powershell script that publish a files to my blob storage, and i got it to upload the file(s) to Process Automation/Runbooks.

But i cant seem to get the Runtime version to the latest, how can i do that?

Right now a part of the code looks like this.

Update om text.

Its needed that everything is done automaticly, i want to avoid needed to go into the portal and change version myself. Then i might aswell upload that way and get latest version.

Publish runbook to Azure Automation

Write-Output "Publishing runbook '$RunbookName' to Azure Automation..."

try {

if (-not (Get-AzAutomationRunbook -ResourceGroupName $ResourceGroupName -AutomationAccountName $AutomationAccountName -Name $RunbookName -ErrorAction SilentlyContinue)) {

    Write-Output "Creating new runbook '$RunbookName'..."

    New-AzAutomationRunbook -ResourceGroupName $ResourceGroupName `

        -AutomationAccountName $AutomationAccountName `

        -Name $RunbookName `

        -Type PowerShell

} else {

    Write-Output "Runbook '$RunbookName' already exists. Updating content..."

}

######

Write-Output "Uploading content to runbook '$RunbookName'..."

Import-AzAutomationRunbook -ResourceGroupName $ResourceGroupName `

    -AutomationAccountName $AutomationAccountName `

    -Name $RunbookName `

    -Path $RunbookPath `

    -Type PowerShell `

    -Force
```########

```powershell
Set-AzAutomationRunbook -ResourceGroupName $ResourceGroupName `

    -AutomationAccountName $AutomationAccountName `

    -Name $RunbookName `

    -LogProgress $true `

    -LogVerbose $true

Write-Output "Runbook '$RunbookName' published successfully."
```} catch {

```yaml
Write-Error "ERROR: Failed to publish runbook '$RunbookName': $_"

continue
```}
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,307 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,810 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Deepanshu katara 13,760 Reputation points MVP
    2025-02-12T12:58:07.1566667+00:00

    Hello Andre, Welcome to MS Q&A

    To update the Runtime version for Azure Process Automation/Runbooks using PowerShell, you can follow these steps:

    Create a Runtime Environment:

    • Sign in to the Azure portal and select your Automation account.
      • Under Process Automation, select Runtime Environments (preview).
        • Select Create to create a new PowerShell Runtime environment (e.g., PowerShell 7.2).
          • Fill in the required details and select Create.
          Update the Runbook:
          - In the Automation account, navigate to the Runbooks page and select the runbook linked to the old Runtime environment.
          
             - Select Edit in the portal.
          
                - From the dropdown, select the new Runtime environment you created.
          
                   - Make necessary changes to the runbook code to ensure compatibility with the new Runtime version.
          
                      - Test the upgraded runbook using the Test pane.
          
                         - Once confirmed, publish the runbook to production.
          

    By following these steps, you can successfully update the Runtime version of your Azure Automation runbooks.

    References:

    Please let us know if any ques

    Kindly accept answer if it helps

    Thanks
    Deepanshu


Your answer

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