Reputation: 9583
I would like to get the URL for a BlobItem
.
In the Azure Portal, I can see the URL in the properties section, but when I get the BlobItemProperties
object from the BlobItem
, I cannot find the URL
property.
Here is what I have so far:
var blobContainerClient = new BlobContainerClient(connectionString, containerName);
await foreach (var blob in blobContainerClient.GetBlobsAsync())
{
blob.Properties.???
}
Upvotes: 14
Views: 6869
Reputation: 229
You can do that :
var blobContainerClient = new BlobContainerClient(connectionString, containerName);
await foreach (var blob in blobContainerClient.GetBlobsAsync())
{
BlobClient blobClient = blobContainerClient.GetBlobClient(blob.Name);
var uri = blobClient.Uri;
}
Upvotes: 15
Reputation: 222582
There is no AbsoluteUri or Uri property available with the latest SDK , what you need to actually do is to generate a url based on the Container Uri.
You can get the Container Uri as,
var containerUri = blobContainerClient.Uri.AbsoluteUri;
and then you can generate as
List<string> results = new List<string>();
await foreach (BlobItem blobItem in containerClient.GetBlobsAsync())
{
results.Add(
Flurl.Url.Combine(
containerClient.Uri.AbsoluteUri,
blobItem.Name
)
);
}
Also make sure to import,
using Flurl;
Upvotes: 6