Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE REQ] Azure Storage Clients should support un-authenticated access and using a preexisting HttpPipeline #7986

Closed
2 tasks done
alexperovich opened this issue Oct 8, 2019 · 4 comments
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Storage Storage Service (Queues, Blobs, Files)

Comments

@alexperovich
Copy link

alexperovich commented Oct 8, 2019

Is your feature request related to a problem? Please describe.
I have a storage account container with public anonymous read/list access. I wanted to use the storage SDK to read and list blobs in the container. That isn't possible without abusing the protected constructor to create a sub class that creates the HttpPipeline manually.

Describe the solution you'd like
This should be completely valid csharp

var container = new BlobContainerClient("https://<account>.blob.core.windows.net/<container>"); // <-- anonymously accessible container, but this should also work with a SAS token in the url
container.GetBlobs(); // This should return successfully if the container has public read/list access enabled

Describe alternatives you've considered
I currently have the following functioning hack:

private class AnonContainerClient : BlobContainerClient
{
  public override Uri Uri { get; }
  protected override HttpPipeline Pipeline { get; }

  public AnonContainerClient(string uri)
  {
    Uri = new Uri(uri);
    Pipeline = HttpPipelineBuilder.Build(new BlobClientOptions());
  }
}

Unfortunately this causes GetBlobClient to return an invalid BlobClient instance because it passes a null HttpPipeline to it. I can't just override GetBlobClient because the constructor that accepts an HttpPipeline is internal.

Additional context
No additional context

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issue as an incomplete report

  • Description Added
  • Expected solution specified
@triage-new-issues triage-new-issues bot added the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Oct 8, 2019
@maggiepint maggiepint added Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Storage Storage Service (Queues, Blobs, Files) labels Oct 9, 2019
@triage-new-issues triage-new-issues bot removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Oct 9, 2019
@maggiepint
Copy link
Contributor

@tg-msft what do you think?

@tg-msft
Copy link
Member

tg-msft commented Oct 9, 2019

Thanks for filing this.

We've fixed the missing .ctor with #7836 and that'll show up in the next release. The other (maybe slightly less annoying) workaround in the meantime is:

private BlobContainerClient GetAnonymousContainerClient(Uri containerUri)
{
    BlobUriBuilder builder = new BlobUriBuilder(containerUri);
    string containerName = builder.ContainerName;
    builder.ContainerName = null;
    return new BlobServiceClient(builder.Uri).GetBlobContainerClient(containerName);
}  

We've also made the Pipeline internal with #7843, per feedback from @KrzysztofCwalina. We're planning to keep these hidden until we've collected more customer feedback and scenarios to make sure we've got the API right.

@amnguye
Copy link
Member

amnguye commented Feb 19, 2020

Hi,

Is this still an issue for you, or does the release with the fix resolve this issue?

@amnguye amnguye self-assigned this Feb 19, 2020
@alexperovich
Copy link
Author

This issue is fixed. Thanks.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

No branches or pull requests

4 participants