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.25k stars 4.59k forks source link

[QUERY] AddQueueServiceClient with configuration section and supporting QueueTrigger #45695

Open MathieuMarchant opened 2 weeks ago

MathieuMarchant commented 2 weeks ago

Library name and version

Azure.Storage.Queues 12.19.0.0

Query/Question

I'm able to add a Queue Service Client, by passing the URI as follows:

clientBuilder.AddQueueServiceClient(new Uri($"https://{azureStorageSettings.StorageAccountName}.queue.core.windows.net"));

In the same way I'm also able to configure a Blob Service Client:

clientBuilder.AddBlobServiceClient(new Uri($"https://{azureStorageSettings.StorageAccountName}.blob.core.windows.net"));

But I would like to put all the URI's in a single configuration section. Doing some reverse engineering of the TryGetServiceUri in the StorageClientProvider I tried to set the following configuration:

  "Storage": {
      "ServiceUri": "https://***.blob.core.windows.net",
      "QueueServiceUri": "https://***.queue.core.windows.net"
  }

This works for the blob service client, but the queue service client gets created with the "ServiceUri" and fails. When I update "ServiceUri" to "BlobServiceUri", I get the following exception

image

What I also find strange, is that the QueueTrigger works, if I only provide the "Storage:ServiceUri". When I omit this configuration, I get an exception that I need to provide an AzureWebStorage connection string...

So, how am I able to configure the service URI's that the queue service client and blob service client are taking the correct URI and QueueTrigger is also using the service URI's instead of needing to provide an additional AzureWebStorage connection string?

Environment

Windows 10 .NET 8.0

github-actions[bot] commented 2 weeks ago

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