Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.46k stars 4.8k forks source link

[BUG] Azure Function Blob and Queue output binding inconsistent behaviour #34876

Open milkyware opened 1 year ago

milkyware commented 1 year ago

Library name and version

Microsoft.Azure.WebJobs.Extensions.Storage.Blobs 5.1.0

Describe the bug

When using the Blob output binding with capital letters in the path such as [Blob("Test")] BlobContainerClient containerClient the error Microsoft.Azure.WebJobs.Host: Validation failed for property 'BlobPath', value 'Test'. The field BlobPath is invalid. occurs. I know that Azure storage only supports lowercase for blob containers. However, when doing the equivalent with queue storage using Microsoft.Azure.WebJobs.Extensions.Storage.Queues 5.1.0 e.g. [Queue("Test")] IAsyncCollector<string> collector there is no error and the binding auto resolves to a lowercase queue name like below.

image

This seems like inconsistent behaviour. I often use nameof when working with queues to avoid magic strings and constants. It would be great to do the same with blob containers.

Expected behavior

Capitalised Blob container names are auto-resolved to be lowercase like when using Queue output bindings and creates the container

Actual behavior

Exception is thrown

The 'TestFunction' function is in error: Microsoft.Azure.WebJobs.Host: Error indexing method 'TestFunction'. Microsoft.Azure.WebJobs.Host: Validation failed for property 'BlobPath', value 'Test'. The field BlobPath is invalid.

Reproduction Steps

  1. Create a new Azure Function project
  2. Create a new class
  3. Paste in the below and run project
public class TestFunction
    {
        [FunctionName(nameof(TestFunction))]
        public async Task<IActionResult> RunAsync([HttpTrigger] HttpRequest httpRequest,
            [Blob("Test")] BlobContainerClient containerClient)
        {
            return new OkResult();
        }
    }

Environment

.NET SDK: Version: 7.0.201 Commit: 68f2d7e7a3

Runtime Environment: OS Name: Windows OS Version: 10.0.22621 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\7.0.201\

Host: Version: 7.0.3 Architecture: x64 Commit: 0a2bda10e8

.NET SDKs installed: 7.0.201 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Azure Functions: Azure Functions Core Tools Core Tools Version: 4.0.5030 Commit hash: N/A (64-bit) Function Runtime Version: 4.15.2.20177

ghost commented 1 year ago

Thank you for your feedback. This has been routed to the support team for assistance.

github-actions[bot] commented 1 year ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @ahmedelnably @fabiocav @xgithubtriage.

navba-MSFT commented 1 year ago

Adding Service team to look into this.

@ahmedelnably @fabiocav @xgithubtriage Could you please look into this once you get a chance ? Thanks in advance.