Skip to content
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

C#: Can't use CloudBlockBlob as input parameter #89

Closed
lindydonna opened this issue Mar 12, 2016 · 11 comments · Fixed by #299
Closed

C#: Can't use CloudBlockBlob as input parameter #89

lindydonna opened this issue Mar 12, 2016 · 11 comments · Fixed by #299

Comments

@lindydonna
Copy link
Contributor

I want to use a CloudBlockBlob as a binding parameter, but I get an exception from the function script host when I try to do this.

C# function:

public static void Run(CloudBlockBlob blobInput, TraceWriter log)

Binding:

{
    "bindings": [
        {
            "type": "queueTrigger",
            "direction": "in",
            "queueName": "resizerequest"
        },
        {
            "type": "blob",
            "name": "blobInput",
            "direction": "in",
            "path": "{BlobNameLG}/{FileName}"
        }
    ]
}

Then, in the log stream, I see this:

System.InvalidOperationException: Cannot bind blob to CloudBlockBlob using access Read.
at Microsoft.Azure.WebJobs.Host.Blobs.ConverterArgumentBindingProvider`1.TryCreate(ParameterInfo parameter, Nullable`1 access)
...

I see the same issue if I try to do an output binding with CloudBlockBlob. A Stream binding seems to work fine, however.

@christopheranderson christopheranderson added this to the backlog milestone Mar 12, 2016
@mathewc
Copy link
Member

mathewc commented Mar 12, 2016

Supported bindings are detailed here: http://go.microsoft.com/fwlink/?LinkID=524028&clcid=0x409

Likely the issue is we're only binding BlobAttribute using FileAccess.Read (the default), not taking the binding direction into account. If CloudBlockBlob only supports RW as the PDF indicates, we probably need to have direction=inout, and when we bind, we interpret that as FileAccess.ReadWrite

@fabiocav
Copy link
Member

fabiocav commented Apr 5, 2016

Changing this from bug to feature for accuracy, as the issue is due to a limitation on the current supported binding access/directions.

@mathewc
Copy link
Member

mathewc commented Apr 5, 2016

Can you elaborate on that? We have some other issues related to in/out support - wondering if this is related.

@fabiocav
Copy link
Member

fabiocav commented Apr 5, 2016

We don't currently support Read/Write access, which is what the Blob binding requires in order to work with ICloudBlob,CloudBlockBlob and CloudPageBlob. Right now, the supported binding direction is either In or Out. We'd either need to support InOut, or when appropriate, use ReadWrite for the binding based on the argument type (e.g. use ReadWrite for the blob binding if the type is ICloudBlob,CloudBlockBlob and CloudPageBlob).
You're more familiar with that process; any concerns about trying automatically treat the binding as RW in those cases?

@fabiocav
Copy link
Member

fabiocav commented Apr 6, 2016

@mathewc any feedback on the approach described in my last message? This is something we can do pretty easily if there are no objections to that approach.

@mathewc
Copy link
Member

mathewc commented Apr 6, 2016

There is a BindingDirection.InOut, it's just not plumbed everywhere correctly. What is your proposal? Note we have another issue tracking that work across the languages/bindings.

@fabiocav
Copy link
Member

fabiocav commented Apr 6, 2016

Somehow, I missed that InOut was there. My proposal was to treat the RW types (as, unless I'm mistaken, they seem to support RW only) as InOut/RW. That would be easy to do when building the custom attribute, but it would only apply to C# at the moment. I would rather wait for proper InOut support if that's in the plans.

@mathewc
Copy link
Member

mathewc commented Apr 6, 2016

#49

@fabiocav
Copy link
Member

fabiocav commented Apr 6, 2016

I know we want to have consistency across the different languages, but for C#, we could easily enable this scenario in an "advanced" mode by manually modifying the function.json to use InOut when applicable and properly handle that when generating the custom attributes.
Thoughts?

@fabiocav
Copy link
Member

This has been resolved by:
#299

@lindydonna
Copy link
Contributor Author

Awesome! Could you let me know when the fix is in staging or prod?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants