Azure-webjobs-sdk: QueueTrigger appears to be broke with Microsoft.NET.Sdk.Functions 1.0.19

Created on 7 Sep 2018  路  18Comments  路  Source: Azure/azure-webjobs-sdk

below is my Azure Function that worked with 1.0.14

        [FunctionName("LaunchTenantListener")]
        public static async Task Run([QueueTrigger(Constants.Queue, Connection = Constants.StorageConnection)]string tenantID, [Inject] PollQueuesForTenant pollQueuesForTenant)
        {
            await pollQueuesForTenant.Execute(tenantID);
        }

I'm currently getting this error.

Newtonsoft.Json.JsonReaderException
  HResult=0x80131500
  Message=Input string '5c61b624-567e-433e-a28c-8b044430f087' is not a valid number. Path '', line 1, position 36.
  Source=Newtonsoft.Json
  StackTrace:
   at Newtonsoft.Json.JsonTextReader.ParseReadNumber(ReadType readType, Char firstChar, Int32 initialPosition)
   at Newtonsoft.Json.JsonTextReader.ParseNumber(ReadType readType)
   at Newtonsoft.Json.JsonTextReader.ParseValue()
   at Newtonsoft.Json.JsonTextReader.Read()
   at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader, JsonLoadSettings settings)
   at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader)
   at Microsoft.Azure.WebJobs.Host.Protocols.JsonSerialization.ParseJObject(String json) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Protocols\JsonSerialization.cs:line 102
   at Microsoft.Azure.WebJobs.Host.Queues.QueueCausalityManager.GetOwner(CloudQueueMessage msg) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Extensions.Storage\Queues\QueueCausalityManager.cs:line 55

Since our code wasn't anywhere in the stack trace I changed the message that was being posted to the queue to a number and now I get

Newtonsoft.Json.JsonReaderException
  HResult=0x80131500
  Message=Error reading JObject from JsonReader. Current JsonReader item is not an object: Integer. Path '', line 1, position 3.
  Source=Newtonsoft.Json
  StackTrace:
   at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader, JsonLoadSettings settings)
   at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader)
   at Microsoft.Azure.WebJobs.Host.Protocols.JsonSerialization.ParseJObject(String json) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Protocols\JsonSerialization.cs:line 102
   at Microsoft.Azure.WebJobs.Host.Queues.QueueCausalityManager.GetOwner(CloudQueueMessage msg) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Extensions.Storage\Queues\QueueCausalityManager.cs:line 55

Also, can you please point me to the proper place for me to post that my local storage no longer appears in Cloud Explorer?

Thank you for an amazing product that in continuously getting more awesome.

Most helpful comment

Just ran into this issue too. Posting a json formatted string into the queue removes the exception and If I use a Type as the message, its also serialized correctly. Still sees it as a pain that the exception is thrown

All 18 comments

I created an object with a single string property and posted it to the storage queue and the QueueTrigger works with that. This is a work around that one shouldn't need to do. Please make it better.

We have also run into this today; even though you declare the queue trigger object as a string, the webjobs sdk is trying to json parse it, and it throws a Newtonsoft.Json.JsonReaderException on this line:
https://github.com/Azure/azure-webjobs-sdk/blob/b798412ad74ba97cf2d85487ae8479f277bdd85c/src/Microsoft.Azure.WebJobs.Protocols/JsonSerialization.cs#L102

I ran into similar issue. Here're the screenshots:
screenshot1

screenshot2

Hi guys! I'm dealing with the same on v 1.0.21 , and the main problem is that if you're using the QueueTrigguerto get the PartitionKeyor RowKeyfor a Table /Storage/ binding everything gets broken.

        [FunctionName("DeployTeamsConfiguration" )]
        public static void Run(
            [QueueTrigger(TEAMS_TASK_QUEUE)]
            string teamTask,
            [Table(TEAM_TASK_TABLE, "TeamsTask", "{queueTrigger}")]
            TeamsConfiguration teamsConfig)

Guys - I believe you're just seeing first chance exceptions in the debugger. The queue trigger does do a try/parse generating exceptions, but we handle those. Can you guys confirm that if you F5 past this error the function actually works as intended? If so, then you just need to change your VS exception settings to ignore these.

Yes I hit this sometimes too. Will keep on eye on what this could be but for mitigation if you unclick this it will stop bothering you.

workaround

Should it even try parse if the object type is set to string?

Guys - I believe you're just seeing first chance exceptions in the debugger. The queue trigger does do a try/parse generating exceptions, but we handle those. Can you guys confirm that if you F5 past this error the function actually works as intended? If so, then you just need to change your VS exception settings to ignore these.

yes I've used that as mitigation.

Should it even try parse if the object type is set to string?

Yes, the exceptions are jumping everytime the queued message doesn't match a json object.

Just ran into this issue too. Posting a json formatted string into the queue removes the exception and If I use a Type as the message, its also serialized correctly. Still sees it as a pain that the exception is thrown

@paulbatum this seems to be picking up steam. Not sure if something reverted in latest VS bits? I see this on both my machines that have VS 2017 15.9.0 Preview 2.0

Also noticed it with SDK 3.0 while it was not the case with 2.x. I understood that the underlying exception was indeed handled by the SDK but still annoying and confusing to get such errors while debugging.

Would be great if this was not surfacing at all and as @nzthiago said, should it even try to deserialize and handle exception if the type is string. Might not be that easy to detect though...

The PR is now merged. For users to get this fix we'll need to release an updated build of the Microsoft.Azure.WebJobs.Extensions.Storage NuGet package and then users will have to grab the update. The package should be published by mid October.

Closing because this has been fixed.

Hi @paulbatum, do you by any chance, have a release date for this package?

@ksoakellho should be within the next two weeks.

Work with latest v3.0.1 Microsoft.Azure.WebJobs.Extensions.Storage, no exception is thrown.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kamranayub picture kamranayub  路  4Comments

mslugx picture mslugx  路  3Comments

sergey-netdev picture sergey-netdev  路  5Comments

scramsby picture scramsby  路  3Comments

techniq picture techniq  路  3Comments