-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
azauto schedule json conversion #3744
Comments
Update: Here are my repro steps that unfortunately do not error out: $ReproRGName = "ReproRG"
$ReproAzAutoAccountName = "ReproAcct"
$ReproRunbookName = "ReproRunbook"
$ReproSchedule = "ReproSchedule"
$ReproLocation = "southcentralus"
$StartTime = (Get-Date).AddMinutes(6)
#download a simple repro powershell script that simply accepts a parameter and outputs it
$LocalPath = "$env:userprofile\repro.ps1"
$RemotePath = "https://gist.githubusercontent.com/jonsabo/a392b54e5ae538865b14c8d8036b7285/raw/459132bf1c697c20515e7a2311737eecd7c69a24/azautorepro.ps1"
Invoke-WebRequest -Uri $RemotePath -OutFile $LocalPath
New-AzureRmResourceGroup -Name $ReproRGName -Location $ReproLocation
New-AzureRmAutomationAccount -ResourceGroupName $ReproRGName -Name $ReproAzAutoAccountName -Location $ReproLocation -Plan Free
Import-AzureRMAutomationRunbook -Name $ReproRunbookName -ResourceGroupName $ReproRGName -AutomationAccountName $ReproAzAutoAccountName -Type PowerShell -Path $LocalPath
Publish-AzureRmAutomationRunbook -Name $ReproRunbookName -ResourceGroupName $ReproRGName -AutomationAccountName $ReproAzAutoAccountName
New-AzureRmAutomationSchedule -Name $ReproSchedule -ResourceGroupName $ReproRGName -AutomationAccountName $ReproAzAutoAccountName -StartTime $StartTime -DayInterval 1
$Params = @{
"TestValue" = "04:00:00"
}
$LinkedSchedule = Register-AzureRmAutomationScheduledRunbook -ResourceGroupName $ReproRGName -AutomationAccountName $ReproAzAutoAccountName -RunbookName $ReproRunbookName -ScheduleName $ReproSchedule -Parameters $Params -Debug
$runbook = Get-AzureRmAutomationScheduledRunbook -ResourceGroupName $ReproRGName -AutomationAccountName $ReproAzAutoAccountName -JobScheduleId $LinkedSchedule.JobScheduleId -Debug And here's what it actually sends when it links the schedule to the runbook
|
Also verified that if you schedule a runbook in the portal, when you retrieve it via the api it comes as a nested string
So at this point I am not sure if it is a bug in the SDK, or a bug with the service. It seemed at first like a bug with the SDK, since the JSON the service was returning was valid. But maybe the service specifies that parameter values need to be nested strings, and is just not verifying this when schedules are created by other Microsoft services (in this case OMS)? |
@safeermohammed Hey Safeer, would you mind taking a look at this issue? |
REST API expects the Parameter values to be json serialized object. The reason for this is the parameter value can be a PSObject which can be deserialized in runbook. The first case the cmdlet failed with error "Invalid JSON primitive:" because it tried to deserialize primitive string expecting the value to be json. Ideally the return value from Service for this case should have been json and the cmdlet would have worked, for some reason it is not in that form from the service. |
Closing as it appears from the third post from the OP that the behavior is consistent between different Automation cmdlets. |
Cmdlet(s)
Get-AzureRmAutomationScheduledRunbook
PowerShell Version
5.1.14393.693
Module Version
AzureRM 3.8.0, or rather AzureRM.Automation 2.8.0
OS Version
10.0.14393.693
Description
When retrieving a specific azure automation runbook schedule, it appears the cmdlet sometimes has difficulty parsing the returned JSON. The json looks to be valid, so seems to be an issue with the cmdlet rather than the service.
Getting the specific schedule returns more info, such as the parameters, than what is returned when you query for all of the schedules on an automation account, and it is here that the parsing error happens. In this case, a parameter has a value of
"04:00:00"
which appears to be making the json parser error out. From what I can see, this is valid JSON though.This cmdlet is used to re-register existing schedules after updating modules in an automation account, so a fix here would be greatly appreciated.
Note that this particular runbook/schedule is one that is created by OMS for its update deployments feature, but I am not sure if that is relevant here.
Debug Output
Instructions: to get Debug Output, set
$DebugPreference="Continue"
and then execute the cmdlet or script causing the issue.Script/Steps for Reproduction
Create a runbook that accepts a parameter. Create a schedule that passes a parameter value of "04:00:00". Run
Get-AzureRmAutomationScheduledRunbook
against this schedule.The text was updated successfully, but these errors were encountered: