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

GetAzureAutomationScheduledRunbook fails when schedule has credential parameters

Open silverl opened this issue 9 years ago • 9 comments

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-AzureRmAutomationScheduledRunbook using the overload that takes as paramaters AutomationAccount, ResourceGroup, JobScheduleId
  • Profit.

silverl avatar Apr 14 '17 16:04 silverl

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.

anyasabo avatar Apr 14 '17 16:04 anyasabo

Hi, @jonsabo. Thanks. Looks like we're both hitting the same issue.

silverl avatar Apr 14 '17 16:04 silverl

@safeermohammed Hey Safeer, would you mind taking a look at this issue?

cormacpayne avatar Apr 14 '17 17:04 cormacpayne

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

safeermohammed avatar Apr 15 '17 04:04 safeermohammed

This is still an issue today with what I encountered.

hintbw avatar Oct 10 '17 19:10 hintbw

@safeermohammed Any update on this issue?

maddieclayton avatar Mar 10 '18 00:03 maddieclayton

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?

jefffanjoy avatar Apr 15 '18 05:04 jefffanjoy

I am still running into this issue. Any idea if/when this will be fixed?

PaulBoelen avatar Aug 20 '18 10:08 PaulBoelen

:bell: Routing this issue to @act-codegen-extensibility-squad.