Azure / Azure/azure-powershell

GetAzureAutomationScheduledRunbook fails when schedule has credential parameters

Open
#3,776 9 comments 0 reactions 2 assignees Claimed by @Bpoe View on GitHub
act-codegen-extensibility-squad Automation automation-leads customer-reported Service Attention
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
2d 17h
Merged PRs (30d)
51

Description

### 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](https://github.com/azureautomation/runbooks/issues/14) 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-AzureRmAutomationScheduledRunbook` using the overload that takes as paramaters `AutomationAccount`, `ResourceGroup`, `JobScheduleId`
* Profit.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.