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

Cannot bind POCO to return value of function #869

Open
ZainRizvi opened this Issue Nov 3, 2016 · 3 comments

Comments

Projects
None yet
5 participants
@ZainRizvi

ZainRizvi commented Nov 3, 2016

Binding the return value of a function to an output causes the error:

Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.ReturnOutputTest'. Microsoft.Azure.WebJobs.Host: Can't bind Blob to type 'Submission#0+Poco&'.

Repro steps

Create a function with an output bound to a blob. I triggered my function using a manual trigger. Here's the code:

using System;

public static Poco Run(string input, TraceWriter log)
{
    log.Info($"C# manually triggered function called with input: {input}");
    return new Poco {
        MyString = "input",
        myDateTime = DateTime.Now
    };
}
 
public class Poco {
    public string MyString {get; set; }
    public DateTime myDateTime {get; set;}
}

Bindings:

{
  "bindings": [
    {
      "type": "blob",
      "name": "$return",
      "path": "testoutput/{rand-guid}",
      "connection": "AzureWebJobsDashboard",
      "direction": "out"
    },
    {
      "type": "manualTrigger",
      "name": "input",
      "direction": "in"
    }
  ],
  "disabled": false
}

Expected behavior

Binding works and outputs value to blob

Actual behavior

The binding fails.

Compiling the function gives the error:
Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.ReturnOutputTest'. Microsoft.Azure.WebJobs.Host: Can't bind Blob to type 'Submission#0+Poco&'.

You see this error when switching to the Develop tab in the portal:

Error:

Function ($ReturnOutputTest) Error: Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.ReturnOutputTest'. Microsoft.Azure.WebJobs.Host: Can't bind Blob to type 'Submission#0+Poco&'.
Session Id: 2d0750255192418fb22ae96f623db8df

Timestamp: 2016-11-03T18:23:09.194Z
@mathewc

This comment has been minimized.

Contributor

mathewc commented Nov 7, 2016

@fabiocav Perhaps this issue was resolved by your commit 20f6b20?

@fabiocav

This comment has been minimized.

Member

fabiocav commented Nov 8, 2016

Not this issue. Need to repro this to see what is going on. Was focused on other items and #870 today.

@lindydonna lindydonna modified the milestone: rc Nov 8, 2016

@mathewc mathewc assigned mathewc and unassigned fabiocav Nov 8, 2016

@mathewc

This comment has been minimized.

Contributor

mathewc commented Nov 9, 2016

Ok, I dug into this. It turns out that this isn't supported by default in the core WebJobs SDK, which is why it doesn't work in functions. I logged a core SDK bug here to track this. Once we add that to core SDK, it will unblock this scenario for Functions.

I'll leave this issue open to track this - once the core SDK supports this, we'll add a test for it.

As a workaround, you can use a non POCO type, etc. a string.

@lindydonna lindydonna added this to the Next - Triaged milestone Nov 14, 2016

@paulbatum paulbatum added the blocked label Nov 14, 2016

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