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.17k stars 4.53k forks source link

[Storage] Mismatch in docs and code behaviour #44150

Open WynieCronje opened 1 month ago

WynieCronje commented 1 month ago

Hi @orhanmaden

I believe I found the issue:

  var credential = new DefaultAzureCredential();
  var containerUri = new Uri($"https://{accountName}.blob.core.windows.net/{containerName}/");
  var blobServiceClient = new BlobServiceClient(containerUri, credential);
  var containerClient = blobServiceClient.GetBlobContainerClient(containerName);

It looks like you are trying to use the containerUri as the Uri for the Blob Service.

I'd recommend trying this instead:

  var credential = new DefaultAzureCredential();
  var serviceUri = new Uri($"https://{accountName}.blob.core.windows.net");
  var blobServiceClient = new BlobServiceClient(serviceUri, credential);
  var containerClient = blobServiceClient.GetBlobContainerClient(containerName);

-Sean

Originally posted by @seanmcc-msft in https://github.com/Azure/azure-sdk-for-net/issues/13411#issuecomment-657707295

github-actions[bot] commented 1 month ago

Thank you for your feedback. Tagging and routing to the team member best able to assist.

WynieCronje commented 1 month ago

From the above comment in another issue.

There is a mismatch between the code behavior and documentation.

The documentation states that any reference to a container or blob will be ignored: image

But the code throws an exception: InvalidUri -> The requested URI does not represent any resource on the server

github-actions[bot] commented 1 month ago

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