GetAzureAutomationScheduledRunbook fails when schedule has credential parameters
Cmdlet(s)
Get-AzureRmAutomationScheduledRunbook
PowerShell Version
Name Value
---- -----
PSVersion 5.1.15063.138
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.15063.138
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Module Version
Get-Module reports version of AzureRM.Automation is 2.7
OS Version
10.0.15063.138
Description
I logged this because the Automation Team's script was failing on Get-AzureRmAutomationScheduledRunbook when the schedule had a Credential object associated with it.
The exception:
Get-AzureRmAutomationScheduledRunbook : Invalid JSON primitive: SqlJobRunner.
At .\ReRegisterAutomationSchedule-MS-Mgmt.ps1:74 char:14
+ ... $sItem = Get-AzureRmAutomationScheduledRunbook -AutomationAccount ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzureRmAutomationScheduledRunbook], CmdletInvocationException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Automation.Cmdlet.GetAzureAutomationScheduledRunbook
Debug Output
The relevant section of the debug output is the JSON body response from the API call:
Body:
{
"id": "/subscriptions/xxx/resourceGroups/ta-automation-rg/providers/Microsoft.Automation/automationAccounts/ta-automation/jobSchedules/xxxx",
"properties": {
"jobScheduleId": "xxx",
"runbook": {
"name": "SQLServerIndexMaintenance"
},
"schedule": {
"name": "ClientTest - Reindexing"
},
"runOn": null,
"parameters": {
"Credential": "SqlJobRunner",
"SqlServerName": "\"dbname.database.windows.net\""
}
}
}
Script/Steps for Reproduction
- Create a runbook that requires a Credential object.
- Set up a schedule for that runbook specifying valid credential parameters.
- Attempt to call
Get-AzureRmAutomationScheduledRunbookusing the overload that takes as paramatersAutomationAccount,ResourceGroup,JobScheduleId - Profit.
I ran into the same issue recently as well in https://github.com/Azure/azure-powershell/issues/3744
In both cases it looks like the the sdk is expecting nested strings for the values.
Hi, @jonsabo. Thanks. Looks like we're both hitting the same issue.
@safeermohammed Hey Safeer, would you mind taking a look at this issue?
Yes, looks like the cmdlet was expecting json value and was trying to deserialize the value (Convert-FromJson) hence the error "Invalid JSON primitive"
Will take a look
This is still an issue today with what I encountered.
@safeermohammed Any update on this issue?
This still seems to be an issue but doesn't necessarily require a credential parameter to generate an issue. I see the same problem if I try to use the cmdlet to get the ScheduledRunbook object from an Update Management schedule.
There seems to be no traction to this issue at all in a year. Any plans to address this?
I am still running into this issue. Any idea if/when this will be fixed?
:bell: Routing this issue to @act-codegen-extensibility-squad.