Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.26k stars 3.86k forks source link

[Az 0.6.1] Start-AzAutomationRunbook ends with a JSON conversion error #7977

Open alexandair opened 5 years ago

alexandair commented 5 years ago

Every time I start a runbook using the Start-AzAutomationRunbook, job completes as expected, but I get an error:

Start-AzAutomationRunbook : Conversion from JSON failed with error: Unexpected character encountered while parsing value: S. Path '', line 0, position 0.
cormacpayne commented 5 years ago

@alexandair Hey Aleksandar, would you mind providing the following information:

alexandair commented 5 years ago
Start-AzAutomationRunbook : Conversion from JSON failed with error: Unexpected character encountered while parsing value: S. Path '', line 0, position 0.
At line:1 char:1
+ Start-AzAutomationRunbook @startParams -Wait -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : CloseError: (:) [Start-AzAutomationRunbook], CmdletInvocationException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Automation.Cmdlet.StartAzureAutomationRunbook

DEBUG: AzureQoSEvent: CommandName - Start-AzAutomationRunbook; IsSuccess - False; Duration - 00:01:00.6955491; Exception - System.Management.Automation.CmdletInvocationException: Conversion from JSON failed with error: Unexpected character encountered while parsing value: S. Path '', line 0, position 0. ---> System.ArgumentException: Conversion from JSON failed with error: Unexpected character encountered while parsing value: S. Path '', line 0, position 0. ---> Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: S. Path '', line 0, position 0.
   at Newtonsoft.Json.JsonTextReader.ParseValue()
   at Newtonsoft.Json.JsonTextReader.Read()
   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, JsonSerializerSettings settings)
   at Microsoft.PowerShell.Commands.JsonObject.ConvertFromJson(String input, Boolean returnHashtable, ErrorRecord& error)
   --- End of inner exception stack trace ---
   at Microsoft.PowerShell.Commands.JsonObject.ConvertFromJson(String input, Boolean returnHashtable, ErrorRecord& error)
   at Microsoft.PowerShell.Commands.ConvertFromJsonCommand.ConvertFromJsonHelper(String input)
   at Microsoft.PowerShell.Commands.ConvertFromJsonCommand.EndProcessing()
   at System.Management.Automation.Cmdlet.DoEndProcessing()
   at System.Management.Automation.CommandProcessorBase.Complete()
   --- End of inner exception stack trace ---
   at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
   at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
   at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
   at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
   at System.Management.Automation.PowerShell.CoreInvoke[TOutput](IEnumerable input, PSDataCollection`1 output, PSInvocationSettings settings)
   at System.Management.Automation.PowerShell.Invoke(IEnumerable input, PSInvocationSettings settings)
   at Microsoft.Azure.Commands.Automation.Common.PowerShellJsonConverter.InvokeScript(String scriptName, Hashtable parameters)
   at Microsoft.Azure.Commands.Automation.Common.PowerShellJsonConverter.Deserialize(String json)
   at Microsoft.Azure.Commands.Automation.Common.AutomationPSClient.GetJobStreamRecordAsPsObject(String resourceGroupName, String automationAccountName, Guid jobId, String jobStreamId)
   at Microsoft.Azure.Commands.Automation.Cmdlet.StartAzureAutomationRunbook.AutomationProcessRecord()
   at Microsoft.Azure.Commands.Automation.Cmdlet.AzureAutomationBaseCmdlet.ExecuteCmdlet()
   at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord();
DEBUG: Finish sending metric.
DEBUG: 6:08:55 PM - StartAzureAutomationRunbook end processing.
DEBUG: 6:08:55 PM - StartAzureAutomationRunbook end processing.
PS C:\> Resolve-AzError
DEBUG: 6:11:46 PM - ResolveError begin processing with ParameterSet 'AnyErrorParameterSet'.
DEBUG: 6:11:46 PM - using account id 'xxxx@xxxxxxx.onmicrosoft.com'...

   HistoryId: 6

Message        : Conversion from JSON failed with error: Unexpected character encountered while parsing value: S. Path '', line 0,
                 position 0.
StackTrace     :    at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
                    at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean
                 performSyncInvoke)
                    at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input,
                 PSDataCollection`1 output, PSInvocationSettings settings)
                    at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input,
                 PSDataCollection`1 output, PSInvocationSettings settings)
                    at System.Management.Automation.PowerShell.CoreInvoke[TOutput](IEnumerable input, PSDataCollection`1 output,
                 PSInvocationSettings settings)
                    at System.Management.Automation.PowerShell.Invoke(IEnumerable input, PSInvocationSettings settings)
                    at Microsoft.Azure.Commands.Automation.Common.PowerShellJsonConverter.InvokeScript(String scriptName, Hashtable
                 parameters)
                    at Microsoft.Azure.Commands.Automation.Common.PowerShellJsonConverter.Deserialize(String json)
                    at Microsoft.Azure.Commands.Automation.Common.AutomationPSClient.GetJobStreamRecordAsPsObject(String
                 resourceGroupName, String automationAccountName, Guid jobId, String jobStreamId)
                    at Microsoft.Azure.Commands.Automation.Cmdlet.StartAzureAutomationRunbook.AutomationProcessRecord()
                    at Microsoft.Azure.Commands.Automation.Cmdlet.AzureAutomationBaseCmdlet.ExecuteCmdlet()
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception      : System.Management.Automation.CmdletInvocationException
InvocationInfo : {Start-AzAutomationRunbook}
Line           : Start-AzAutomationRunbook @startParams -Wait -Verbose
Position       : At line:1 char:1
                 + Start-AzAutomationRunbook @startParams -Wait -Verbose
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 6

Message        : Conversion from JSON failed with error: Unexpected character encountered while parsing value: S. Path '', line 0,
                 position 0.
StackTrace     :    at Microsoft.PowerShell.Commands.JsonObject.ConvertFromJson(String input, Boolean returnHashtable, ErrorRecord&
                 error)
                    at Microsoft.PowerShell.Commands.ConvertFromJsonCommand.ConvertFromJsonHelper(String input)
                    at Microsoft.PowerShell.Commands.ConvertFromJsonCommand.EndProcessing()
                    at System.Management.Automation.Cmdlet.DoEndProcessing()
                    at System.Management.Automation.CommandProcessorBase.Complete()
Exception      : System.ArgumentException
InvocationInfo : {Start-AzAutomationRunbook}
Line           : Start-AzAutomationRunbook @startParams -Wait -Verbose
Position       : At line:1 char:1
                 + Start-AzAutomationRunbook @startParams -Wait -Verbose
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 6

Message        : Unexpected character encountered while parsing value: S. Path '', line 0, position 0.
StackTrace     :    at Newtonsoft.Json.JsonTextReader.ParseValue()
                    at Newtonsoft.Json.JsonTextReader.Read()
                    at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
                    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType,
                 Boolean checkAdditionalContent)
                    at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
                    at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
                    at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, JsonSerializerSettings settings)
                    at Microsoft.PowerShell.Commands.JsonObject.ConvertFromJson(String input, Boolean returnHashtable, ErrorRecord&
                 error)
Exception      : Newtonsoft.Json.JsonReaderException
InvocationInfo : {Start-AzAutomationRunbook}
Line           : Start-AzAutomationRunbook @startParams -Wait -Verbose
Position       : At line:1 char:1
                 + Start-AzAutomationRunbook @startParams -Wait -Verbose
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 6

DEBUG: AzureQoSEvent: CommandName - Resolve-AzError; IsSuccess - True; Duration - 00:00:00.1720459; Exception - ;
DEBUG: Finish sending metric.
DEBUG: 6:11:47 PM - ResolveError end processing.
DEBUG: 6:11:47 PM - ResolveError end processing.
safeermohammed commented 5 years ago

@thomasyip-msft, Can you please take a look?

alexandair commented 5 years ago

@safeermohammed @thomasyip-msft Any follow-up on this?

alexandair commented 5 years ago

@cormacpayne @markcowl I would really appreciate if someone could fix this annoying error.

lwajswaj commented 5 years ago

hey @alexandair, do you still see this issue with AZ 1.3.0? Particularly with Az.Automation 1.1.0? If so, do you have a example script of the runbook you're trying to run and full list of parameters for Start-AzAutomationRunbook?

alexandair commented 5 years ago

@lwajswaj The issue still exists in Az 1.3.0. And, I'm not the only one. Please, take a look at #8600

lwajswaj commented 5 years ago

Does it happen with any type of runbook or what is the output you are trying to read? (trying to repro, just that)

tobvil commented 5 years ago

I have exacly the same issue on pwsh 6.1.3. No issue on pwsh 5.1 Hope the PR will fix it.

alexandair commented 5 years ago

@lwajswaj @cormacpayne This bug is still present in Az 1.6.0.

leifyumel commented 5 years ago

Is there any update on this issue?

lwajswaj commented 5 years ago

I wasn't able to complete the previous PR given a business trip and vacation. I'm working to get it merged as soon as I can.

lwajswaj commented 5 years ago

@leifyumel, fix for this issue has been release with AZ 2.1.0 (https://github.com/Azure/azure-powershell/releases/tag/v2.1.0-May2019)

alexandair commented 5 years ago

@lwajswaj Thank you.

alexandair commented 5 years ago

Unfortunately, even with v2.1.0, I still see the same issue:

VERBOSE: "Job progress state : Id 72369ab0-7d6f-4c50-9a40-29226989b861, state New, time 5/28/2019 1:43:51 PM"
VERBOSE: "Job progress state : Id 72369ab0-7d6f-4c50-9a40-29226989b861, state New, time 5/28/2019 1:43:56 PM"
VERBOSE: "Job progress state : Id 72369ab0-7d6f-4c50-9a40-29226989b861, state Running, time 5/28/2019 1:44:02 PM"
VERBOSE: "Job progress state : Id 72369ab0-7d6f-4c50-9a40-29226989b861, state Running, time 5/28/2019 1:44:07 PM"
VERBOSE: "Job terminal state : Id 72369ab0-7d6f-4c50-9a40-29226989b861, state Completed, time 5/28/2019 1:44:21 PM"
Start-AzAutomationRunbook : Conversion from JSON failed with error: Unexpected character encountered while parsing value: S. Path '', line 0, position 0.
andyw248 commented 4 years ago

No repro. Tested with: Name Value


PSVersion 5.1.17763.771
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.771
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1