Azure / Azure/azure-powershell
Get-AzAutomationJob does not return the exception or startedBy
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 51
Description
### Description
When using Get-AzAutomationJob, output objects contain the property 'Exception' however, this is always empty, even if the job failed with an exception message.
Get-AzAutomationJobOutput also does not contain any method to retrieve exceptions, only messages from the stream such as output, errors, warnings etc.
### Issue script & Debug output
```PowerShell
PS C:\Temp\> $JobSplat = @{
Status = "Failed"
ResourceGroupName = ""
AutomationAccountName = ""
StartTime = get-date "00:00:00"
}
$FailedJobs = Get-AzAutomationJob @JobSplat
DEBUG: 23:57:17 - GetAzureAutomationJob begin processing with ParameterSet 'ByAll'.
DEBUG: 23:57:17 - using account id ''...
DEBUG: 23:57:17 - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: [Common.Authentication]: Authenticating using Account: '', environment: 'AzureCloud', tenant: ''
DEBUG: 23:57:17 - [ConfigManager] Got nothing from [EnableLoginByWam], Module = [], Cmdlet = []. Returning default value [False].
DEBUG: 23:57:17 - [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.NetCore .NET 7.0.5 Microsoft Windows 10.0.22621 [2023-06-23 22:57:17Z - ] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.5 Microsoft Windows 10.0.22621 [2023-06-23 22:57:17Z - ] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.5 Microsoft Windows 10.0.22621 [2023-06-23 22:57:17Z - ] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.5 Microsoft Windows 10.0.22621 [2023-06-23 22:57:17Z - ] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.5 Microsoft Windows 10.0.22621 [2023-06-23 22:57:17Z - ] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.5 Microsoft Windows 10.0.22621 [2023-06-23 22:57:17Z - ] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.5 Microsoft Windows 10.0.22621 [2023-06-23 22:57:17Z] Found 2 cache accounts and 0 broker accounts
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.5 Microsoft Windows 10.0.22621 [2023-06-23 22:57:17Z] Returning 2 accounts
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.5 Microsoft Windows 10.0.22621 [2023-06-23 22:57:17Z - ] MSAL MSAL.NetCore with assembly version '4.49.1.0'. CorrelationId()
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.5 Microsoft Windows 10.0.22621 [2023-06-23 22:57:17Z - ] === AcquireTokenSilent Parameters ===
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.5 Microsoft Windows 10.0.22621 [2023-06-23 22:57:17Z - ] LoginHint provided: False
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.5 Microsoft Windows 10.0.22621 [2023-06-23 22:57:17Z - ] Account provided: True
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.5 Microsoft Windows 10.0.22621 [2023-06-23 22:57:17Z - ] ForceRefresh: False
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.5 Microsoft Windows 10.0.22621 [2023-06-23 22:57:17Z - ]
=== 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 -
UserAssertion set: False
LongRunningOboCacheKey set: False
Region configured:
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.5 Microsoft Windows 10.0.22621 [2023-06-23 22:57:17Z - ] === 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 7.0.5 Microsoft Windows 10.0.22621 [2023-06-23 22:57:17Z - ] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.5 Microsoft Windows 10.0.22621 [2023-06-23 22:57:17Z - ] Access token is not expired. Returning the found cache entry. [Current time (06/23/2023 22:57:17) - Expiration Time (06/24/2023 00:07:17 +00:00) - Extended Expiration Time (06/24/2023 00:07:17 +00:00)]
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.5 Microsoft Windows 10.0.22621 [2023-06-23 22:57:17Z - ] Returning access token found in cache. RefreshOn exists ? False
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.5 Microsoft Windows 10.0.22621 [2023-06-23 22:57:17Z - ] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.5 Microsoft Windows 10.0.22621 [2023-06-23 22:57:17Z - ]
=== Token Acquisition finished successfully:
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.5 Microsoft Windows 10.0.22621 [2023-06-23 22:57:17Z - ] AT expiration time: 24/06/2023 00:07:17 +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-06-24T00:07:17.0000000+00:00
DEBUG: [Common.Authentication]: Received token with LoginType 'User', Tenant: '', UserId: ''
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
GET
Absolute Uri:
https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts//jobs?$filter=properties/startTime ge 2023-06-22T23:00:00.0000000Z and properties/status eq 'Failed'&api-version=2022-08-08
Headers:
Accept-Language : en-US
x-ms-client-request-id :
Body:
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
OK
Headers:
Cache-Control : no-cache
Pragma : no-cache
x-ms-request-id :
Server : Microsoft-HTTPAPI/2.0
x-ms-ratelimit-remaining-subscription-resource-requests: 599
x-ms-correlation-request-id :
x-ms-routing-request-id : UKSOUTH:20230623T225717Z:
Strict-Transport-Security : max-age=31536000; includeSubDomains
X-Content-Type-Options : nosniff
Date : Fri, 23 Jun 2023 22:57:17 GMT
Body:
{
"value": [
{
"id": "/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts//jobs/4de7fc9e-9d46-42b6-8a55-d5ff861010db",
"name": "4de7fc9e-9d46-42b6-8a55-d5ff861010db",
"type": "Microsoft.Automation/AutomationAccounts/Jobs",
"properties": {
"jobId": "37696a20-c6aa-4b5a-bdde-9fb755fe40a3",
"runbook": {
"name": "Prod-AlertTesting"
},
"provisioningState": "Failed",
"status": "Failed",
"creationTime": "2023-06-23T13:02:58.8944227+01:00",
"startTime": "2023-06-23T13:03:07.7420376+01:00",
"lastModifiedTime": "2023-06-23T13:03:07.7420376+01:00",
"endTime": "2023-06-23T13:03:07.7420376+01:00",
"runOn": ""
}
},
{
"id": "/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts//jobs/98cc716a-63b2-4060-a15f-c1207d5402d7",
"name": "98cc716a-63b2-4060-a15f-c1207d5402d7",
"type": "Microsoft.Automation/AutomationAccounts/Jobs",
"properties": {
"jobId": "b5d9fb6c-91f8-43d0-90b5-3c5a7d51a9e7",
"runbook": {
"name": "Prod-AlertTesting"
},
"provisioningState": "Failed",
"status": "Failed",
"creationTime": "2023-06-23T12:56:54.3780152+01:00",
"startTime": "2023-06-23T12:57:08.1214442+01:00",
"lastModifiedTime": "2023-06-23T12:57:08.1214442+01:00",
"endTime": "2023-06-23T12:57:08.1214442+01:00",
"runOn": ""
}
},
{
"id": "/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts//jobs/f1bb5994-9964-4a9f-96f4-5cc560fc4e02",
"name": "f1bb5994-9964-4a9f-96f4-5cc560fc4e02",
"type": "Microsoft.Automation/AutomationAccounts/Jobs",
"properties": {
"jobId": "fb026aa8-cd19-4e32-95fd-711c17c8bd7b",
"runbook": {
"name": "Prod-AlertTesting"
},
"provisioningState": "Failed",
"status": "Failed",
"creationTime": "2023-06-23T12:56:33.0572392+01:00",
"startTime": "2023-06-23T12:56:37.9767694+01:00",
"lastModifiedTime": "2023-06-23T12:56:37.9767694+01:00",
"endTime": "2023-06-23T12:56:37.9767694+01:00",
"runOn": ""
}
},
{
"id": "/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts//jobs/e1c10106-96d7-4555-863f-8bc58cdb541f",
"name": "e1c10106-96d7-4555-863f-8bc58cdb541f",
"type": "Microsoft.Automation/AutomationAccounts/Jobs",
"properties": {
"jobId": "2ad2d311-35f2-485c-aa36-52fa08cc377e",
"runbook": {
"name": "Prod-AlertTesting"
},
"provisioningState": "Failed",
"status": "Failed",
"creationTime": "2023-06-23T12:16:15.6012333+01:00",
"startTime": "2023-06-23T12:16:35.8269301+01:00",
"lastModifiedTime": "2023-06-23T12:16:35.8269301+01:00",
"endTime": "2023-06-23T12:16:35.8269301+01:00",
"runOn": ""
}
},
{
"id": "/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts//jobs/d493f94f-ea03-48c4-b5e2-c8418a27c39a",
"name": "d493f94f-ea03-48c4-b5e2-c8418a27c39a",
"type": "Microsoft.Automation/AutomationAccounts/Jobs",
"properties": {
"jobId": "5ba3153d-24d8-4f4c-87c7-623c037383d0",
"runbook": {
"name": "Prod-AlertTesting"
},
"provisioningState": "Failed",
"status": "Failed",
"creationTime": "2023-06-23T12:11:50.2673378+01:00",
"startTime": "2023-06-23T12:12:08.0731818+01:00",
"lastModifiedTime": "2023-06-23T12:12:08.0731818+01:00",
"endTime": "2023-06-23T12:12:08.0731818+01:00",
"runOn": ""
}
}
]
}
DEBUG: 23:57:17 - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: AzureQoSEvent: Module: Az.Automation:1.9.1; CommandName: Get-AzAutomationJob; PSVersion: 7.3.4; IsSuccess: True; Duration: 00:00:00.2061146
DEBUG: 23:57:17 - [ConfigManager] Got nothing from [EnableDataCollection], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 23:57:17 - GetAzureAutomationJob end processing.
PS C:\Temp\> $FailedJobs[0]
ResourceGroupName :
AutomationAccountName :
JobId : 37696a20-c6aa-4b5a-bdde-9fb755fe40a3
CreationTime : 23/06/2023 13:02:58 +01:00
Status : Failed
StatusDetails :
StartTime : 23/06/2023 13:03:07 +01:00
EndTime : 23/06/2023 13:03:07 +01:00
Exception :
LastModifiedTime : 23/06/2023 13:03:07 +01:00
LastStatusModifiedTime : 01/01/0001 00:00:00 +00:00
JobParameters : {}
RunbookName : Prod-AlertTesting
HybridWorker :
StartedBy :
```
### Environment data
```PowerShell
Name Value
---- -----
PSVersion 7.3.4
PSEdition Core
GitCommitId 7.3.4
OS Microsoft Windows 10.0.22621
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Also tested on linux ubuntu with 7.3.1 core
```
### Module versions
```PowerShell
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 1.9.1 Az.Automation {Export-AzAutomationDscConfiguration, Export-AzAutomationDscNodeReportContent, Export-AzAutomationRunbook, Get-AzAutomationAccount…}
```
### Error output
```PowerShell
None returned.
```
Contributor guide
Assessment
This issue has not been assessed yet.