Azure / Azure/azure-functions-dotnet-worker
Binding metadata consumption breaks deferred binding
- Dominant language
- C#
- Stars
- 466
- Forks
- 215
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 7
Description
Trigger metadata (not payload data), if consumed in an output binding, for example, will cause consumption of the trigger payload.
This will not work:
```csharp
[Function(nameof(CreateThumbnail))]
[BlobOutput("thumbnails/{name}-thumbnail.jpg", Connection = "AzureWebJobsStorage")]
public async Task Run([BlobTrigger("images/{name}", Connection = "AzureWebJobsStorage")] Stream stream, string name)
```
`stream` will have already been consumed and have failed to be parsed by `JsonPocoConverter`. Here's the exception:
> Exception: Microsoft.Azure.Functions.Worker.FunctionInputConverterException: Error converting 1 input parameters for Function 'CreateThumbnail': Cannot convert input parameter 'stream' to type 'System.IO.Stream' from type 'System.ReadOnlyMemory`1[[System.Byte, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]'. Error:System.Text.Json.JsonException: '0x89' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
If you remove the binding data reference, it will work as expected, though:
```csharp
[Function(nameof(CreateThumbnail))]
[BlobOutput("thumbnails/no-binding-metadata-thumbnail.jpg", Connection = "AzureWebJobsStorage")]
public async Task Run([BlobTrigger("images/{name}", Connection = "AzureWebJobsStorage")] Stream stream, string name)
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.