Raymond A.
Raymond A.

Reputation: 637

Setting Azure Automation PowerShell Runtime version

I have set up a Azure Automation, connected to Github for source control.
Coding in vs.code, pushing script to github and then to Azure Automation.

However, all new scripts is set to Runtime version 5.1, with no option to change this setting.

In short, what are my options for setting runtime version for the Runbook?

Upvotes: 2

Views: 3835

Answers (3)

Øyvind
Øyvind

Reputation: 123

From the docs: https://learn.microsoft.com/en-us/azure/automation/automation-runbook-types

Source control integration doesn't support PowerShell 7.1. Also, PowerShell 7.1 runbooks in source control gets created in Automation account as Runtime 5.1.

Please vote on the feature request https://feedback.azure.com/d365community/idea/0f5b99f9-b5f6-ec11-a81b-6045bd796569

Upvotes: 0

fullmetalcache
fullmetalcache

Reputation: 11

I posted an answer on the following GitHub issue but will post it here for convenience:

https://github.com/Azure/azure-powershell/issues/16399

The runbook has to be initialized and populated using REST API calls (the first two calls). It can be published using the intended Azure cmdlet call for doing so (the third call). This is just a work-around until they officially support creating the a PowerShell 7.1 runbook with Azure cmdlets.

Invoke-AzRestMethod -Method "PUT" -ResourceGroupName $ResourceGroupName -ResourceProviderName "Microsoft.Automation" `
    -ResourceType "automationAccounts" -Name "${AutomationAccountName}/runbooks/${RunbookName}" -ApiVersion "2017-05-15-preview" `
    -Payload "{`"properties`":{`"runbookType`":`"PowerShell7`", `"logProgress`":false, `"logVerbose`":false, `"draft`":{}}, `"location`":`"${Location}`"}"

Invoke-AzRestMethod -Method "PUT" -ResourceGroupName $ResourceGroupName -ResourceProviderName "Microsoft.Automation" `
    -ResourceType automationAccounts -Name "${AutomationAccountName}/runbooks/${RunbookName}/draft/content" -ApiVersion 2015-10-31 `
    -Payload "$scriptContent"

Publish-AzAutomationRunbook -Name $RunbookName -AutomationAccountName $AutomationAccountName -ResourceGroupName $ResourceGroupName

Upvotes: 1

KrishnaG
KrishnaG

Reputation: 3484

Setting runtime version via API changes are not yet implemented. This is part of the GA backlog and the tentative ETA is Q2 CY22.

Source of the above information: https://learn.microsoft.com/en-us/answers/questions/637711/index.html

Upvotes: 0

Related Questions