GetPropertiesAsync on BlobBaseClient does not return from the server

Viewed 394

I'm trying to create a seekable blob read stream for reading zip entry from my blob storage and for that I want to know what is the length of the content, and for that I need to call

BlobContainerClient client = blobServiceClient.GetBlobContainerClient("my-container");    
BlobProperties properties = client.GetProperties() 
long Length = properties.ContentLength;
        

At the initialization of the my seekable blob stream but the get properties is stuck and not returning back from the client

I tried this too

BlobContainerClient client = blobServiceClient.GetBlobContainerClient("my-container");    
BlobProperties properties = client.GetPropertiesAsync().GetAwaiter().GetResult().Value; 
long Length = properties.ContentLength;

The Nugets that I used there:

  1. Azure.Storage.Blobs Version="12.10.0"
  2. Microsoft.Azure.Management.Storage Version="23.0.0"

Thanks

1 Answers

I'm not sure what is the client in your client.GetProperties(). But you can get the length of the blob's content with the BlobProperties.ContentLength, as shown below example.

BlobServiceClient blobServiceClient = new BlobServiceClient("connectionString");
BlobContainerClient container = blobServiceClient.GetBlobContainerClient("containerName");
BlobClient blob = container.GetBlobClient("blobName");
var properties = blob.GetProperties();
Console.WriteLine(properties.Value.ContentLength);

Instead of printing the length as shown in the above example you can store it.

Related