Azure / Azure/azure-functions-dotnet-worker

Upgrade Assistant incorrectly handles input binding to writeable client

Open
#2,016 0 comments 0 reactions 1 assignee Claimed by @aishwaryabh View on GitHub
area: dotnet-upgrade-assistant bug team-issue
Dominant language
C#
Stars
466
Forks
215
Avg merge
3d 10h
Merged PRs (30d)
7

Description

Upgrade Assistant seems to treat a Blob input binding given `FileAccess.Write` as an output binding. In this scenario, it's an input binding to a BlobContainerClient so that blobs can be written through that client (so accomplishing an output scenario, but still an input binding). However, this is moved to a return type output binding attribute, which is doubly strange in this scenario since there already is an implicit return type through the `Task` from the HTTP trigger.

Here's the original, which was a V4 in-process function:

```csharp
public static async Task Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "cases/{caseID}/attach/{fileName}")] HttpRequest req,
[Blob(..., FileAccess.Write, Connection = ...)] BlobContainerClient imageContainer,
[Table(..., Connection = ...)] TableClient table
)
```

And here's the output from an upgrade to .NET 8:

```csharp
[BlobOutput(..., Connection = ...)]
public async Task Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "cases/{caseID}/attach/{fileName}")] HttpRequest req,
[TableInput(..., Connection = ...)] TableClient table
)
```

A build error is generated for the missing parameter:

>Error CS0103 The name 'imageContainer' does not exist in the current context

My expectation is that this blob binding should be treated as an input binding, and that I would end up with::

```csharp
public async Task Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "cases/{caseID}/attach/{fileName}")] HttpRequest req,
[BlobInput(..., Connection = ...)] BlobContainerClient imageContainer,
[TableInput(..., Connection = ...)] TableClient table
)
```
There would in theory be no build errors for this function after this change, as the contracts used by the function body all remain the same.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.