We use the NodeJS @azure/storage-blob SDK to access the storage container/blobs in our organization. We have a system developed wherein the users can access the private containers by logging in into our servers and their accounts being added via our admin to certain IAM roles (Either giving them read/write/delete access to the blobs).
Now, we want to enable some new users to access to public container/blobs by default. We have made a container public and the public links to these storage containers/blobs are accessible by a URL but when trying to access them via the NodeJS API we get the "AuthorizationPermissionMismatch" error.
The code we use is below:
function getBlobDirectories(result) {
console.log(result);
}
function errorinlisting(err) {
console.log(err);
}
const containerClient = global.getBlobService(this.storageAccount,req.user).getContainerClient(this.containerName);
let blobDirIterator = containerClient.listBlobsByHierarchy('/');
blobDirIterator.next().then(getBlobDirectories).catch(errorinlisting);
The function getBlobService looks like this:
exports.getBlobService = (storageAcc, user)=> {
const account = storageAcc;
const accountKey = storageaccountkeys[storageAcc]
let blobServiceClient;
const simpleTokenCredential = new SimpleTokenCredential(user.azureToken);
blobServiceClient = new BlobServiceClient(
`https://${account}.blob.core.windows.net`,
simpleTokenCredential
);
return blobServiceClient;
}
Calling listBlobsByHierarchy, end up in error which ends up calling the errorinlisting
function above with "AuthorizationPermissionMismatch" error..
What could be the issue? Is this a bug in the NodeJS API?
Any help would be invaluable.