azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Az.Automation - Runbookname pattern

Open plovegro opened this issue 3 years ago • 34 comments

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

plovegro avatar Jan 11 '23 00:01 plovegro

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

plovegro avatar Jan 11 '23 02:01 plovegro

Thank you for your feedback. This has been routed to the support team for assistance.

ghost avatar Jan 11 '23 09:01 ghost

@plovegro , could you share debug log when you try to create that runbook? You can turn on debug via $DebugPreference = "Continue".

dingmeng-xue avatar Jan 11 '23 09:01 dingmeng-xue

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 avatar Jan 11 '23 10:01 plovegro

@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.

navba-MSFT avatar Jan 12 '23 03:01 navba-MSFT

`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 avatar Jan 12 '23 04:01 plovegro

@plovegro Thanks for sharing the details. We are looking into this. We will get back to you once we have an update.

navba-MSFT avatar Jan 12 '23 06:01 navba-MSFT

@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:

image

navba-MSFT avatar Jan 12 '23 07:01 navba-MSFT

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.

plovegro avatar Jan 12 '23 08:01 plovegro

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.

novatelli avatar Jan 12 '23 08:01 novatelli

@plovegro @novatelli Thanks for your reply. I am looking into this.

navba-MSFT avatar Jan 12 '23 08:01 navba-MSFT

@navba-MSFT Hey, is there any update on this?

novatelli avatar Jan 13 '23 09:01 novatelli

@novatelli @plovegro I have reached out to the Automation Product Group team and awaiting their reply now.

navba-MSFT avatar Jan 13 '23 10:01 navba-MSFT

I also get this error with Start-AzAutomationRunbook for runbooks that contain only letters and underscores (allowed in Azure Portal).

obesser avatar Jan 16 '23 10:01 obesser

@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.

navba-MSFT avatar Jan 16 '23 10:01 navba-MSFT

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.

MainDBA avatar Jan 17 '23 08:01 MainDBA

@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.

navba-MSFT avatar Jan 18 '23 06:01 navba-MSFT

@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.

navba-MSFT avatar Jan 23 '23 03:01 navba-MSFT

Hi, I am also impacted by this change, applied the workfix and would like to be informed when the fix is available.

peruzzof avatar Jan 26 '23 12:01 peruzzof

Hi, we I am also impacted by this change. Please keep us informed.

thgauchet avatar Jan 26 '23 15:01 thgauchet