Azure / Azure/azure-functions-dotnet-worker

Azure Function Dapr Extension Input and Output Binding Doesn't Work with `Microsoft.Azure.Functions.Worker.Sdk` Version >= 1.16.0

Open
#2,678 1 comment 0 reactions 0 assignees View on GitHub
needs-investigation potential-bug
Dominant language
C#
Stars
466
Forks
215
Avg merge
3d 10h
Merged PRs (30d)
7

Description

### Description

# Azure Function Dapr Extension Input and Output Binding Doesn't Work with `Microsoft.Azure.Functions.Worker.Sdk` Version >= 1.16.0

**Issue:** The Dapr Input and Output bindings do not work as expected.

## Investigation Details:

- It was observed that the `IAsyncConverter.ConvertAsync` method is not called by the worker library when using `Microsoft.Azure.Functions.Worker.Sdk` version >= 1.16.0.

## Actual Behavior:

- The Dapr Input and Output bindings fail to work with `Microsoft.Azure.Functions.Worker.Sdk` NuGet package version >= 1.16.0.

## Expected Behavior:

- The Dapr Input and Output bindings should function correctly with all versions of the `Microsoft.Azure.Functions.Worker.Sdk` NuGet package. However, they only work when downgrading the package to version 1.15.1.

## Attempted Fixes:

Tried upgrading the following packages in the Azure Functions Dapr extension, but the issue persists:

- `Microsoft.Azure.Functions.Worker.Extensions.Abstractions` from version 1.1.1 to 1.3.0 in the WebJobs library.
- `Microsoft.Azure.WebJobs` from version 3.0.36 to 3.0.41.

### Steps to reproduce

## Prerequisites
This sample requires you to have the following installed on your machine:
- Setup Dapr: Follow instructions to [download and install the Dapr CLI](https://docs.dapr.io/getting-started/install-dapr-cli/) and [initialize Dapr](https://docs.dapr.io/getting-started/install-dapr-selfhost/).
- [Install Azure Functions Core Tool](https://github.com/Azure/azure-functions-core-tools/blob/master/README.md#windows)

Either you can download [this repo](https://github.com/ASHIQUEMD/dotnet-isolated-azfunc-dapr-ext) or create a new azure function as mentioned below.

1. Create a .NET isolated Azure Function.
2. Add the Dapr extension to the project.
```bash
dotnet add package Microsoft.Azure.Functions.Worker.Extensions.Dapr --version 1.0.0
```
4. Upon creation, the `Microsoft.Azure.Functions.Worker.Sdk` is set to version 1.17.0.
5. Add an Azure function with Dapr Output binding
```csharp
[Function("StateOutputBinding")]
[DaprStateOutput("statestore", Key = "{key}")]
public static async Task Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "state/{key}")] HttpRequestData req,
FunctionContext functionContext)
{
var log = functionContext.GetLogger("StateOutputBinding");
log.LogInformation("C# HTTP trigger function processed a request.");

JsonDocument doc = await JsonDocument.ParseAsync(req.Body);
return doc.RootElement;
}
```
7. Execute the Azure Function.
```bash
dapr run --app-id functionapp --app-port 3001 --dapr-http-port 3501 --resources-path C:\Users\\.dapr\components -- func host start
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the linked dotnet-isolated-azfunc-dapr-ext reproduction and compare Microsoft.Azure.Functions.Worker.Sdk 1.15.1 with 1.17.0. Trace the Dapr input and output binding path around IAsyncConverter.ConvertAsync, then run the Azure Function and confirm that both bindings work with SDK versions >= 1.16.0.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.