Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

URL from BlobItem

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.???
}
like image 618
rhughes Avatar asked May 23 '20 16:05

rhughes


People also ask

How do I get blob storage URL?

One way to find the URL of the blob is by using the Azure portal by going to Home > Storage Account > Container > Blob > Properties. However, probably the easiest way is to find the blob in the Storage Explorer, right-click, then select 'Copy URL'. This will copy the resource URL directly to the clipboard.

What is blob container URL?

By default, the URL for accessing the Blob service in a storage account is https://<your account name>. blob.core.windows.net.

What is blob URI in Azure?

Definition. The BlobUriBuilder class provides a convenient way to modify the contents of a Uri instance to point to different Azure Storage resources like an account, container, or blob. For more information, see Naming and Referencing Containers, Blobs, and Metadata.

How to get blob object from some stream URL?

Function that code blob object from some stream URL works one-way. Blobs are created and are valid only during browser is open and are stored in browser memory. The only possible solution is to check what javascript is executed on page load and find something like ` = new Blob () `

How do I create a client from a blob url?

In order to create a client given the full URI to the blob, use the from_blob_url classmethod. The container name for the blob. The name of the blob with which to interact. If specified, this value will override a blob value specified in the blob URL.

What is the timeout parameter of blobclient?

The timeout parameter is expressed in seconds. Create BlobClient from a blob url. This doesn't support customized blob url with '/' in blob name. The full endpoint URL to the Blob, including SAS token and snapshot if used. This could be either the primary endpoint, or the secondary endpoint depending on the current location_mode.

How do I write a Blob using commit block list?

The Commit Block List operation writes a blob by specifying the list of block IDs that make up the blob. Creates a new Append Blob. Creates a new Page Blob of the specified size. Creates a snapshot of the blob. A snapshot is a read-only version of a blob that's taken at a point in time. It can be read, copied, or deleted, but not modified.


2 Answers

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;
like image 182
Sajeetharan Avatar answered Nov 14 '22 22:11

Sajeetharan


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;
}
like image 34
pdouelle Avatar answered Nov 14 '22 23:11

pdouelle