Azure-functions-vs-build-sdk: ServiceBus output binding does not serialize correctly

Created on 11 May 2017  路  15Comments  路  Source: Azure/azure-functions-vs-build-sdk

Input

        [FunctionName("HttpTriggerCSharp")]
        public static async Task<HttpResponseMessage> Run(
            [HttpTrigger] HttpRequestMessage req,
            [ServiceBus("myqueue", AccessRights.Manage, Connection = "ServiceBusConnection")] IAsyncCollector<BrokeredMessage> notificationMessages,
            TraceWriter log)

function.json:

    {
      "type": "serviceBus",
      "queue": "myqueue",
      "connection": "ServiceBusConnection",
      "entityType": "queue",
      "access": "manage",
      "direction": "out",
      "name": "notificationMessages"
    },

queue should be queueName
access should be accessRights

P0 bug

Most helpful comment

alpha4 is on nuget. https://www.nuget.org/packages/Microsoft.NET.Sdk.Functions/1.0.0-alpha4
It should have the fix for ServiceBus and EventHub. I'll take a look at documentDb.

All 15 comments

@lindydonna let me know when I can make another release of the build task.

and thanks @slideep for reporting the issue. It led me to find a different service bus issue as well :)

@ahmelsayed it's up to us, so if you think we have enough fixes for it to be worthwhile, we can go ahead and do it. We'll just have to have a conversation with Mike and Andrew about when to rev the VSIX so that the project template uses the new version. Until then, customers can just update the NuGet package.

Ahmed, I wonder if maybe we can have some tests that use the JSON schema to validate the generated output? Afaik this needs a license for a feature of JSON.NET, but I think it would be worth it. That way, we don't need e2e tests.

Okay, I'll prepare alpha4 then. I just worry that this type of bugs will be very annoying for users as they are not doing anything wrong. Also the error would be a bit confusing and might lead them on a wild goose hunt to figure out what's wrong, so it's better to get the fixes out quickly.

I'll investigate schema validation for the output.

@ahmelsayed Agreed; getting the fix out quickly is best

Thanks @lindydonna and @ahmelsayed - I've just started migrating some functions and have hit this error, so it's a blocker til the updated NuGet package is available.
Have a few more functions to go with different bindings, so I'll report any other mismatches (if any).

alpha4 is on nuget. https://www.nuget.org/packages/Microsoft.NET.Sdk.Functions/1.0.0-alpha4
It should have the fix for ServiceBus and EventHub. I'll take a look at documentDb.

Still present for the Service Bus binding (queue instead of queueName and access instead of accessRight), no matter if 1.0.0-alpha4 or -alpha5 is used of the Microsoft.NET.Sdk.Functions.
Or do I need to update some other packages as well?

@mzipfel can you share your method signature with the attributes you're using?

The issue was that the clean up doesn't clean everything. After manually deleting the debug files, the output is now correct. (I try to make a new sample, and the issue is vanished, and after removing the debug files the function.json of the old one is now also fine.)
I used the ServiceBusTrigger attribute with an in queue, and one with an out queue, for some inline pipelining.

So the signature is similar to this:
public static void TestFun(
[ServiceBusTrigger("queueIn", AccessRights.Listen, Connection = "inConn"]BrokeredMessage inputMessage,
[ServiceBus("queueOut", AccessRights.Send, Connection = "outConn"]BrokeredMessage outputMessage, TraceWriter log) { ... }

EDIT: This issue persisted through manual deletion of bin folder, cleaning, restarting Visual Studio, etc. But this issue went away after changing the method signature.

This issue persists in 1.0.0-alpha6.

Reference from project file:

<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.0-alpha6" />

Partial build output:

Microsoft.NET.Sdk.Functions 1.0.0-alpha6 depends on Microsoft.Build.Framework (>= 15.1.298-preview5) but Microsoft.Build.Framework 15.1.298-preview5 was not found. An approximate best match of Microsoft.Build.Framework 15.1.548 was resolved.
Microsoft.NET.Sdk.Functions 1.0.0-alpha6 depends on Microsoft.Build.Utilities.Core (>= 15.1.298-preview5) but Microsoft.Build.Utilities.Core 15.1.298-preview5 was not found. An approximate best match of Microsoft.Build.Utilities.Core 15.1.548 was resolved.

Method signature:

[FunctionName("Users")]
public static HttpResponseMessage Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post")] HttpRequestMessage request,
            TraceWriter log,
            [ServiceBus("register-user", AccessRights.Send)] out string outputQueueObject)

Resulting function.json:

{
  "bindings": [
    {
      "type": "httpTrigger",
      "methods": [
        "post"
      ],
      "authLevel": "anonymous",
      "direction": "in",
      "name": "request"
    },
    {
      "type": "serviceBus",
      "queueName": "register-user",
      "entityType": "queue",
      "accessRights": "send",
      "direction": "out",
      "name": "outputQueueObject"
    },
    {
      "name": "$return",
      "type": "http",
      "direction": "out"
    }
  ],
  "disabled": false,
  "scriptFile": "..\\UserRegistrationService.dll",
  "entryPoint": "UserRegistrationService.Register.Run"
}

@rcabr what was your method signature?

Hey @lindydonna, I'm getting the same error ": Can't figure out which ctor to call." and I checked the function.json. I fixed it (queue to queueName) in bin. But every time I start debugging it, it overrides the file, anywhere around this?

@mtorkamani Make sure you're using the latest version of the NuGet package https://www.nuget.org/packages/Microsoft.NET.Sdk.Functions. Current latest is alpha6.

Was this page helpful?
0 / 5 - 0 ratings