Get URL for container or blob with JavaScript

You can get a container or blob URL by using the url property of the client object:

  • ContainerClient.url
  • BlobClient.url
  • BlockBlobClient.url

The sample code snippets are available in GitHub as runnable Node.js files.


The examples in this article assume that you've created a BlobServiceClient object by using the guidance in the Get started with Azure Blob Storage and JavaScript article.

Get URL for container and blob

The following example gets a container URL and a blob URL by accessing the client's url property:

// create container
const containerName = `con1-${}`;
const { containerClient } = await blobServiceClient.createContainer(containerName, {access: 'container'});

// Display container name and its URL
console.log(`created container:\n\tname=${containerClient.containerName}\n\turl=${containerClient.url}`);

// create blob from string
const blobName = `${containerName}-from-string.txt`;
const blobContent = `Hello from a string`;
const blockBlobClient = await containerClient.getBlockBlobClient(blobName);
await blockBlobClient.upload(blobContent, blobContent.length);

// Display Blob name and its URL 
console.log(`created blob:\n\tname=${blobName}\n\turl=${blockBlobClient.url}`);

// In loops, blob is BlobItem
// Use to get BlobClient or BlockBlobClient
// The get `url` property
for await (const blob of containerClient.listBlobsFlat()) {
    // blob 

    // Get Blob Client from name, to get the URL
    const tempBlockBlobClient = containerClient.getBlockBlobClient(;

    // Display blob name and URL


For loops, you must use the object's name property to create a client then get the URL with the client. Iterators don't return client objects, they return item objects.

See also