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,313 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,822 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Deepanshu katara 14,085 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


  2. Naveena Patlolla 400 Reputation points Microsoft Vendor
    2025-02-19T13:29:52.3733333+00:00

    Hi @André Lindqvist

    In your script you have selected "Type" as PowerShell, so by default it is taking PowerShell 5.1.

    User's image To avoid this please select Type as "PowerShell72" as per Microsoft documentation. Below is the screenshot

    User's image

    Please refer the below MS document https://learn.microsoft.com/en-us/powershell/module/az.automation/import-azautomationrunbook?view=azps-13.1.0#-type

    Feel free to reach out if you have any further questions or need additional information—I’m happy to assist!

    Please provide your valuable comments User's image

    Please do not forget to "Accept the answer” and “upvote it” wherever the information provided helps you, this can be beneficial to other community members.it would be greatly appreciated and helpful to others.


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.