Azure / azure-functions-vs-build-sdk

MSBuild task for Azure Functions
MIT License
96 stars 62 forks source link

Publish to Function (v4) fails with Deserialization Exception #555

Closed jonganej closed 2 years ago

jonganej commented 2 years ago

I'm trying to publish to a Linux-based Azure Function v4 but it fails with an apparent exception thrown by the deserialization of the response as seen in the log dump below. Apparently the error message is the same regardless of whether I'm signed in to VS or not. I looked up the code and it seems that a try catch on deserialization / dumping the raw response body if deserialization fails could be useful for debugging failed deployments on VS.

Details to my build env: dotnet 6.0.300 Visual Studio 2022 17.2.0 Microsoft.NET.Sdk.Functions v4.1.0

Publishing with func azure functionapp publish my-function-name on Powershell for example works fine so it shouldn't be an app configuration issue.

5>The "ZipDeployTask" task failed unexpectedly.
5>System.AggregateException: One or more errors occurred. ---> Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: {. Path 'build_summary', line 1, position 506.
5>   at Newtonsoft.Json.JsonTextReader.ReadStringValue(ReadType readType)
5>   at Newtonsoft.Json.JsonTextReader.ReadAsString()
5>   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
5>   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateDictionary(IDictionary dictionary, JsonReader reader, JsonDictionaryContract contract, JsonProperty containerProperty, String id)
5>   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
5>   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
5>   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
5>   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
5>   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
5>   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
5>   at Microsoft.NET.Sdk.Functions.MSBuild.Tasks.ZipDeploymentStatus.<InvokeGetRequestWithRetryAsync>d__11`1.MoveNext() in /_/src/Microsoft.NET.Sdk.Functions.MSBuild/Tasks/ZipDeploymentStatus.cs:line 100
5>--- End of stack trace from previous location where exception was thrown ---
5>   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
5>   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
5>   at Microsoft.NET.Sdk.Functions.MSBuild.Tasks.ZipDeploymentStatus.<GetDeploymentStatusAsync>d__10.MoveNext() in /_/src/Microsoft.NET.Sdk.Functions.MSBuild/Tasks/ZipDeploymentStatus.cs:line 68
5>--- End of stack trace from previous location where exception was thrown ---
5>   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
5>   at Microsoft.NET.Sdk.Functions.MSBuild.Tasks.ZipDeploymentStatus.<PollDeploymentStatusAsync>d__9.MoveNext() in /_/src/Microsoft.NET.Sdk.Functions.MSBuild/Tasks/ZipDeploymentStatus.cs:line 49
5>--- End of stack trace from previous location where exception was thrown ---
5>   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
5>   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
5>   at Microsoft.NET.Sdk.Functions.Tasks.ZipDeployTask.<ZipDeployAsync>d__26.MoveNext() in /_/src/Microsoft.NET.Sdk.Functions.MSBuild/Tasks/ZipDeployTask.cs:line 111
5>   --- End of inner exception stack trace ---
5>   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
5>   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
5>   at Microsoft.NET.Sdk.Functions.Tasks.ZipDeployTask.Execute() in /_/src/Microsoft.NET.Sdk.Functions.MSBuild/Tasks/ZipDeployTask.cs:line 42
5>   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
5>   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
5>---> (Inner Exception #0) Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: {. Path 'build_summary', line 1, position 506.
5>   at Newtonsoft.Json.JsonTextReader.ReadStringValue(ReadType readType)
5>   at Newtonsoft.Json.JsonTextReader.ReadAsString()
5>   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
5>   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateDictionary(IDictionary dictionary, JsonReader reader, JsonDictionaryContract contract, JsonProperty containerProperty, String id)
5>   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
5>   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
5>   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
5>   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
5>   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
5>   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
5>   at Microsoft.NET.Sdk.Functions.MSBuild.Tasks.ZipDeploymentStatus.<InvokeGetRequestWithRetryAsync>d__11`1.MoveNext() in /_/src/Microsoft.NET.Sdk.Functions.MSBuild/Tasks/ZipDeploymentStatus.cs:line 100
5>--- End of stack trace from previous location where exception was thrown ---
5>   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
5>   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
5>   at Microsoft.NET.Sdk.Functions.MSBuild.Tasks.ZipDeploymentStatus.<GetDeploymentStatusAsync>d__10.MoveNext() in /_/src/Microsoft.NET.Sdk.Functions.MSBuild/Tasks/ZipDeploymentStatus.cs:line 68
5>--- End of stack trace from previous location where exception was thrown ---
5>   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
5>   at Microsoft.NET.Sdk.Functions.MSBuild.Tasks.ZipDeploymentStatus.<PollDeploymentStatusAsync>d__9.MoveNext() in /_/src/Microsoft.NET.Sdk.Functions.MSBuild/Tasks/ZipDeploymentStatus.cs:line 49
5>--- End of stack trace from previous location where exception was thrown ---
5>   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
5>   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
5>   at Microsoft.NET.Sdk.Functions.Tasks.ZipDeployTask.<ZipDeployAsync>d__26.MoveNext() in /_/src/Microsoft.NET.Sdk.Functions.MSBuild/Tasks/ZipDeployTask.cs:line 111<---
fabiocav commented 2 years ago

Duplicate of #556

@jonganej thank you for reporting this. We are tracking this in the linked issue and will continue to provide updates there, so I'm closing this one. Please subscribe to #556 for updates. Thanks!