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

ServiceBus output binding does not serialize correctly #40

Closed
lindydonna opened this Issue May 11, 2017 · 15 comments

Comments

Projects
None yet
6 participants
@lindydonna
Copy link

lindydonna commented May 11, 2017

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

@ahmelsayed

This comment has been minimized.

Copy link
Contributor

ahmelsayed commented May 11, 2017

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

@ahmelsayed

This comment has been minimized.

Copy link
Contributor

ahmelsayed commented May 11, 2017

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

@lindydonna

This comment has been minimized.

Copy link
Author

lindydonna commented May 11, 2017

@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.

@ahmelsayed

This comment has been minimized.

Copy link
Contributor

ahmelsayed commented May 11, 2017

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.

@ahmelsayed

This comment has been minimized.

Copy link
Contributor

ahmelsayed commented May 11, 2017

I'll investigate schema validation for the output.

@lindydonna

This comment has been minimized.

Copy link
Author

lindydonna commented May 11, 2017

@ahmelsayed Agreed; getting the fix out quickly is best

@garthmason

This comment has been minimized.

Copy link

garthmason commented May 12, 2017

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).

@ahmelsayed

This comment has been minimized.

Copy link
Contributor

ahmelsayed commented May 12, 2017

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.

@mzipfel

This comment has been minimized.

Copy link

mzipfel commented May 27, 2017

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?

@ahmelsayed

This comment has been minimized.

Copy link
Contributor

ahmelsayed commented May 27, 2017

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

@mzipfel

This comment has been minimized.

Copy link

mzipfel commented May 28, 2017

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) { ... }

@rcabr

This comment has been minimized.

Copy link

rcabr commented Jun 14, 2017

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"
}
@ahmelsayed

This comment has been minimized.

Copy link
Contributor

ahmelsayed commented Jun 14, 2017

@rcabr what was your method signature?

@mtorkamani

This comment has been minimized.

Copy link

mtorkamani commented Jul 26, 2017

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?

@lindydonna

This comment has been minimized.

Copy link
Author

lindydonna commented Jul 26, 2017

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment