Az.Automation - Runbookname pattern
Description
On the latest version 1.9.0 i am attempting to use Register-AzAutomationScheduledRunbook, which is now throwing an error on my Runbook Name, which previously worked in 1.8.0
My runbook name is "Rebuild Nightly Jobs" but the error i am receiving is this -
Register-AzAutomationScheduledRunbook: /home/azureuser/myagent/_work/
Line |
10 | Register-AzAutomationScheduledRunbook -AutomationAccountName "Test-de …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| 'runbookName' does not match expected pattern
| '^[a-zA-Z]*-*[a-zA-Z0-9]*$'.
##[error]PowerShell exited with code '1'.
I can't see any documentation about this being a breaking change.
Issue script & Debug output
Register-AzAutomationScheduledRunbook: /home/azureuser/myagent/_work/
Line |
10 | Register-AzAutomationScheduledRunbook -AutomationAccountName "test-de …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| 'runbookName' does not match expected pattern
| '^[a-zA-Z]*-*[a-zA-Z0-9]*$'.
##[error]PowerShell exited with code '1'.
Environment data
Task : Azure PowerShell
Description : Run a PowerShell script within an Azure environment
Version : 5.209.0
Module versions
Az.Automation 1.9.0
Error output
No response
Further details - the Azure frontend now enforces runbook names to only have dashes, underscores and letters. BUT the az.automation package enforces the runbook name pattern to be ^[a-zA-Z]-[a-zA-Z0-9]*$ eg. Test-Runbook
Thank you for your feedback. This has been routed to the support team for assistance.
@plovegro , could you share debug log when you try to create that runbook? You can turn on debug via $DebugPreference = "Continue".
Well the runbook execution was created fine, and it was actually created via a Bicep. Its the scheduling call that is throwing the error - Register-AzAutomationScheduledRunbook
@plovegro Thanks for reaching out to us and reporting this issue. Could you please run $DebugPreference = "Continue" and then run your above PS cmdlet and share the debug output here ? Awaiting your reply.
`DEBUG: 2:54:28 PM - RegisterAzureAutomationScheduledRunbook begin processing with ParameterSet 'ByRunbookNameAndScheduleName'. DEBUG: 2:54:28 PM - using account id ''... DEBUG: 2:54:28 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True]. DEBUG: [Common.Authentication]: Authenticating using Account: '', environment: 'AzureCloud', tenant: '' DEBUG: 2:54:28 PM - [SilentAuthenticator] Calling SharedTokenCacheCredential.GetTokenAsync - TenantId:'', Scopes:'https://management.core.windows.net//.default', AuthorityHost:'https://login.microsoftonline.com/', UserId:'' DEBUG: SharedTokenCacheCredential.GetToken invoked. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId: DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-12 03:54:28Z -] IsLegacyAdalCacheEnabled: yes DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-12 03:54:28Z -] [Region discovery] Not using a regional authority. DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-12 03:54:28Z -] [Region discovery] Not using a regional authority. DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-12 03:54:28Z -] [Region discovery] Not using a regional authority. DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-12 03:54:28Z - ] IsLegacyAdalCacheEnabled: yes DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-12 03:54:28Z -] IsLegacyAdalCacheEnabled: yes DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-12 03:54:28Z] [WamBroker] WAM supported OS. DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-12 03:54:28Z] [WamBroker] ListWindowsWorkAndSchoolAccounts option was not enabled. DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-12 03:54:28Z - ] [Region discovery] Not using a regional authority. DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-12 03:54:28Z] Found 2 cache accounts and 0 broker accounts DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-12 03:54:28Z] Returning 2 accounts DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-12 03:54:28Z - ] MSAL MSAL.Desktop with assembly version '4.49.1.0'. CorrelationId() DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-12 03:54:28Z - ] === AcquireTokenSilent Parameters === DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-12 03:54:28Z -] LoginHint provided: False DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-12 03:54:28Z - ] Account provided: True DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-12 03:54:28Z -] ForceRefresh: False DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-12 03:54:28Z - === Request Data === Authority Provided? - True Scopes - https://management.core.windows.net//.default Extra Query Params Keys (space separated) - ApiId - AcquireTokenSilent IsConfidentialClient - False SendX5C - False LoginHint ? False IsBrokerConfigured - True HomeAccountId - False CorrelationId - UserAssertion set: False LongRunningOboCacheKey set: False Region configured: DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-12 03:54:28Z -] === Token Acquisition (SilentRequest) started: Scopes: https://management.core.windows.net//.default Authority Host: login.microsoftonline.com DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-12 03:54:28Z - 2] [Region discovery] Not using a regional authority. DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-12 03:54:28Z - ] Access token is not expired. Returning the found cache entry. [Current time (01/12/2023 03:54:28) - Expiration Time (01/12/2023 05:03:06 +00:00) - Extended Expiration Time (01/12/2023 05:03:06 +00:00)] DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-12 03:54:28Z - ] Returning access token found in cache. RefreshOn exists ? False DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-12 03:54:28Z -] [Region discovery] Not using a regional authority. DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-12 03:54:28Z - ] === Token Acquisition finished successfully: DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-01-12 03:54:28Z - ] AT expiration time: 12/01/2023 5:03:06 AM +00:00, scopes: https://management.core.windows.net//user_impersonation https://management.core.windows.net//.default. source: Cache DEBUG: SharedTokenCacheCredential.GetToken succeeded. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId: ExpiresOn: 2023-01-12T05:03:06.0000000+00:00 DEBUG: [Common.Authentication]: Received token with LoginType 'User', Tenant: '', UserId: '' DEBUG: 2:54:28 PM - [ConfigManager] Got nothing from [EnableDataCollection], Module = [], Cmdlet = []. Returning default value [True]. Register-AzAutomationScheduledRunbook : 'runbookName' does not match expected pattern '^[a-zA-Z]-[a-zA-Z0-9]*$'. At line:1 char:1
- Register-AzAutomationScheduledRunbook -AutomationAccountName "bt-de ...
-
+ CategoryInfo : CloseError: (:) [Register-AzAutomationScheduledRunbook], ValidationException + FullyQualifiedErrorId : Microsoft.Azure.Commands.Automation.Cmdlet.RegisterAzureAutomationScheduledRunbook
DEBUG: 2:54:30 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True]. DEBUG: AzureQoSEvent: Module: Az.Automation:1.9.0; CommandName: Register-AzAutomationScheduledRunbook; PSVersion: 5.1.19041.2364; IsSuccess: False; Duration: 00:00:01.3425099; Exception: 'runbookName' does not match expected pattern '^[a-zA-Z]-[a-zA-Z0-9]*$'.; DEBUG: 2:54:30 PM - RegisterAzureAutomationScheduledRunbook end processing.`
@plovegro Thanks for sharing the details. We are looking into this. We will get back to you once we have an update.
@plovegro This issue is by design and not specific to this cmdlet Register-AzAutomationScheduledRunbook only.
See this documentation. which mentions that A runbook name can contain only letters, numbers, underscores and dashes, and must begin with a letter. The same behavior is observed in portal too, see below:

Thank you - although that is not quite right. The portal requires only letters, numbers, underscores and dashes. So in theory i could have this - "This-is-my-runbook".
The cmdlet Register-AzAutomationScheduledRunbook requires the specific pattern of - "My-Runbook". 2 words, separated by a hyphen. This is different behaviour to the portal and very confusing.
Hey all,
@navba-MSFT Got similar issue with az.automation. I'm receiving same error on execution of Start-AzAutomationRunbook
runbookName' does not match expected pattern
| '^[a-zA-Z]*-*[a-zA-Z0-9]*$'.
##[error]PowerShell exited with code '1'.
but name of my runbook is start-my-runbook wich is not match the regex in Az.automation v. 1.9.0, but in version 1.8.0 all is working. I could find any info about that change.
@plovegro @novatelli Thanks for your reply. I am looking into this.
@navba-MSFT Hey, is there any update on this?
@novatelli @plovegro I have reached out to the Automation Product Group team and awaiting their reply now.
I also get this error with Start-AzAutomationRunbook for runbooks that contain only letters and underscores (allowed in Azure Portal).
@plovegro @novatelli @obesser I haven't heard back from the automation Product Group team yet. I am following up on this with them. I will keep you posted.
MyAZ.Automation module was updated on 16/01/2023 to version 1.9.0 and I have started to get this error using Start-AzAutomationRunbook to call runbooks whose names contain only letters and underscores. I have also tested and am able to create a new runbook using letters and underscores.
@plovegro @novatelli @obesser @MainDBA We appreciate your patience on this. I have heard back from the Product Owners. The Automation Dev team is aware of this issue now and they are releasing a fix soon. Until then the workaround is to use the older version (1.8 and below) of the Az.Automation module. I will keep you posted about the progress. We sincerely apologize for the inconvenience caused.
@plovegro @novatelli @obesser @MainDBA I am yet to hear back from the Automation Product Owners on the fix release. You could also send an email to me on (navba [@] microsoft .(dot)com ) to stay connected about the updates and fix.
Hi, I am also impacted by this change, applied the workfix and would like to be informed when the fix is available.
Hi, we I am also impacted by this change. Please keep us informed.