Azure / Azure/azure-powershell
Get-AzAutomationAccount has inconsistent/unreliable output
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 3d 14h
- Merged PRs (30d)
- 54
Description
### Description
Get-AzAutomationAccount has inconsistent/unreliable output. It's a bit the same as is experienced with the get-AzResource cmdlet.
Out of running Get-AzAutomationAccount 10 times I get 4 times my automation account back, 6 times not.
### Issue script & Debug output
```PowerShell
DEBUG: 10:39:37 - GetAzureAutomationAccount begin processing with ParameterSet 'ByAll'.
DEBUG: 10:39:37 - using account id 'bart.xxxx.net'...
DEBUG: 10:39:37 - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: [Common.Authentication]: Authenticating using Account: 'bart.xxrxxxxt', environment: 'AzureCloud', tenant: 'xxxxx-5e0a-412a-9d4b-43b358f76f90'
DEBUG: 10:39:37 - [ConfigManager] Got nothing from [EnableLoginByWam], Module = [], Cmdlet = []. Returning default value [False].
DEBUG: 10:39:37 - [SilentAuthenticator] Calling SharedTokenCacheCredential.GetTokenAsync - TenantId:'c4873b90-5e0a-412a-9d4b-43b358f76f90', Scopes:'https://management.core.windows.net//.default', AuthorityHost:'https://login.microsoftonline.com/', UserId:'bart.xxxx.net'
DEBUG: SharedTokenCacheCredential.GetToken invoked. Scopes: [ https://management.core.windows.net//.default
] ParentRequestId:
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.20 Microsoft Windows 10.0.19045 [2023-08-28 08:39:37Z - 1a6f3997-d771-4bbf-9b88-9420766bff38] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.20 Microsoft Windows 10.0.19045 [2023-08-28 08:39:37Z - 1a6f3997-d771-4bbf-9b88-9420766bff38] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.20 Microsoft Windows 10.0.19045 [2023-08-28 08:39:37Z - 1a6f3997-d771-4bbf-9b88-9420766bff38] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.20 Microsoft Windows 10.0.19045 [2023-08-28 08:39:37Z - 1a6f3997-d771-4bbf-9b88-9420766bff38] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.20 Microsoft Windows 10.0.19045 [2023-08-28 08:39:37Z - 1a6f3997-d771-4bbf-9b88-9420766bff38] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.20 Microsoft Windows 10.0.19045 [2023-08-28 08:39:37Z - 1a6f3997-d771-4bbf-9b88-9420766bff38] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.20 Microsoft Windows 10.0.19045 [2023-08-28 08:39:37Z - 1a6f3997-d771-4bbf-9b88-9420766bff38] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.20 Microsoft Windows 10.0.19045 [2023-08-28 08:39:37Z] Found 3 cache accounts and 0 broker accounts
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.20 Microsoft Windows 10.0.19045 [2023-08-28 08:39:37Z] Returning 3 accounts
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.20 Microsoft Windows 10.0.19045 [2023-08-28 08:39:37Z - 63e7c70d-a4e8-45cf-97a6-c8bb01087948] MSAL MSAL.NetCore with assembly version '4.49.1.0'. CorrelationId(63e7c70d-a4e8-45cf-97a6-c8bb01087948)
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.20 Microsoft Windows 10.0.19045 [2023-08-28 08:39:37Z - 63e7c70d-a4e8-45cf-97a6-c8bb01087948] === AcquireTokenSilent Parameters ===
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.20 Microsoft Windows 10.0.19045 [2023-08-28 08:39:37Z - 63e7c70d-a4e8-45cf-97a6-c8bb01087948] LoginHint provided: False
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.20 Microsoft Windows 10.0.19045 [2023-08-28 08:39:37Z - 63e7c70d-a4e8-45cf-97a6-c8bb01087948] Account provided: True
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.20 Microsoft Windows 10.0.19045 [2023-08-28 08:39:37Z - 63e7c70d-a4e8-45cf-97a6-c8bb01087948] ForceRefresh: False
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.20 Microsoft Windows 10.0.19045 [2023-08-28 08:39:37Z - 63e7c70d-a4e8-45cf-97a6-c8bb01087948]
=== 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 - False
HomeAccountId - False
CorrelationId - 63e7c70d-a4e8-45cf-97a6-c8bb01087948
UserAssertion set: False
LongRunningOboCacheKey set: False
Region configured:
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.20 Microsoft Windows 10.0.19045 [2023-08-28 08:39:37Z - 63e7c70d-a4e8-45cf-97a6-c8bb01087948] === Token Acquisition (SilentRequest) started:
Scopes: https://management.core.windows.net//.default
Authority Host: login.microsoftonline.com
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.20 Microsoft Windows 10.0.19045 [2023-08-28 08:39:37Z - 63e7c70d-a4e8-45cf-97a6-c8bb01087948] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.20 Microsoft Windows 10.0.19045 [2023-08-28 08:39:37Z - 63e7c70d-a4e8-45cf-97a6-c8bb01087948] Access token is not expired. Returning the found cache entry. [Current time (08/28/2023 08:39:37) - Expiration Time (08/28/2023 12:04:00 +00:00) - Extended Expiration Time (08/28/2023 12:04:00 +00:00)]
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.20 Microsoft Windows 10.0.19045 [2023-08-28 08:39:37Z - 63e7c70d-a4e8-45cf-97a6-c8bb01087948] Returning access token found in cache. RefreshOn exists ? True
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.20 Microsoft Windows 10.0.19045 [2023-08-28 08:39:37Z - 63e7c70d-a4e8-45cf-97a6-c8bb01087948] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.20 Microsoft Windows 10.0.19045 [2023-08-28 08:39:37Z - 63e7c70d-a4e8-45cf-97a6-c8bb01087948]
=== Token Acquisition finished successfully:
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 6.0.20 Microsoft Windows 10.0.19045 [2023-08-28 08:39:37Z - 63e7c70d-a4e8-45cf-97a6-c8bb01087948] AT expiration time: 28/08/2023 12:04:00 +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-08-28T12:04:00.0000000+00:00
DEBUG: [Common.Authentication]: Received token with LoginType 'User', Tenant: 'xxxxx-5e0a-412a-9d4b-43b358f76f90', UserId: 'bart.xxxx.net'
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
GET
Absolute Uri:
https://management.azure.com/subscriptions/xxxxx/providers/Microsoft.Automation/automationAccounts?api-version=2022-08-08
Headers:
x-ms-client-request-id : dxxxa74b-fb42-4b7b-bf56-9738bcd169cf
Accept-Language : en-US
Body:
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
OK
Headers:
Cache-Control : no-cache
Pragma : no-cache
x-ms-ratelimit-remaining-subscription-reads: 11999
x-ms-request-id : xxa-73e8-4e82-bf0d-a8faca2df662
x-ms-correlation-request-id : xxa21a-73e8-4e82-bf0d-a8faca2df662
x-ms-routing-request-id : NORTHEUROPE:20230828T083937Z:5d84a21a-73e8-4e82-bf0d-a8faca2df662
Strict-Transport-Security : max-age=31536000; includeSubDomains
X-Content-Type-Options : nosniff
X-Cache : CONFIG_NOCACHE
X-MSEdge-Ref : Ref A: 24CFFEC0B496452F8D9BE00EE473396C Ref B: AMS231022012051 Ref C: 2023-08-28T08:39:37Z
Date : Mon, 28 Aug 2023 08:39:37 GMT
Body:
{
"value": []
}
DEBUG: 10:39:37 - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: AzureQoSEvent: Module: Az.Automation:1.9.1; CommandName: Get-AzAutomationAccount; PSVersion: 7.2.13; IsSuccess: True; Duration: 00:00:00.1837151
DEBUG: 10:39:37 - [ConfigManager] Got [True] from [EnableDataCollection], Module = [], Cmdlet = [].
DEBUG: 10:39:37 - GetAzureAutomationAccount end processing.
```
### Environment data
```PowerShell
Name Value
---- -----
PSVersion 7.2.13
PSEdition Core
GitCommitId 7.2.13
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
```
### Module versions
```PowerShell
Script 2.12.3 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, C…
Script 1.9.1 Az.Automation {Export-AzAutomationDscConfiguration,…
Script 1.5.0 Az.LogicApp {Get-AzIntegrationAccount, Get-AzInte…
Script 6.2.0 Az.Resources {Export-AzResourceGroup, Export-AzTem…
Manifest 2.1.0 AzTable {Add-
```
### Error output
```PowerShell
No error, just no output +- 60% of the time.
```
Contributor guide
Research direction
Reproduce the issue by running Get-AzAutomationAccount repeatedly and compare the results with the successful and empty responses shown. Start at the GetAzureAutomationAccount entry point and inspect the request to the Microsoft.Automation automationAccounts endpoint. Done means the cmdlet reliably returns the automation account instead of silently producing no output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, powershell
- Domain
- api, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100