how to fix CORS permissions when uploading file to Azure Data Lake using blockBlobClient.upload?

javier cohenar 161 Reputation points

Following the docs I have the following code for uploading a file from String that leads to a CORS error

export async function uploadBlobFromString(containerName, path, fileContentsAsString){
    // Create blob client from container client
    let blobName = 'https://' + `${account}` + '' + `${path}` + `${accountKey}`
    const blobServiceClient = new BlobServiceClient(blobName);
    const containerClient = blobServiceClient.getContainerClient(containerName);
    const blockBlobClient = containerClient.getBlockBlobClient(blobName);

    await blockBlobClient.upload(fileContentsAsString, fileContentsAsString.length);
    return true
    throw (e)

However CORS configuration at the storage level seems ok to me:


Would much appreciate your help

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,099 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Anand Prakash Yadav 1,075 Reputation points Microsoft Vendor

    Hi javier cohenar,

    Thank you for posting your query here!

    If you are trying to upload file into Azure Data Lake store, you can use @azure/storage-file-datalake package to interact with Azure Data Lake Storage.

    You can find some samples for interacting with it here:

    Code sample for uploading a file from the same link.

    Please let us know if you have any further queries. I’m happy to assist you further.
    If you are still experiencing issues, it may be helpful to provide specific error messages.

    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    0 comments No comments