Following the official doc, I write this script trying to connect a custom domain azure storage space:
const { BlobServiceClient } = require("@azure/storage-blob");
const account = "validaccount";
const sas = "sv=xxxx&.......";
const blobServiceClient = new BlobServiceClient(`https://${account}.blob.core.customdomain.name${sas}`);
//===============
async function main() {
let i = 1;
let containers = blobServiceClient.listContainers();
for await (const container of containers) {
console.log(`Container ${i++}: ${container.name}`);
}
}
main();
I got error: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
I'm sure the SASURI is valid, I can use it in azure blob storage explorer, but in my code it doesn't work.
I tried some combinations likeļ¼
https://${account}.blob.core.customdomain.name?${sas}
//add a '?'https://${account}.blob.core.customdomain.name/abc?${sas}
//abc is a valid container namehttps://${account}.blob.core.customdomain.name/abc${sas}
//remove '?' but keep container namehttps://${account}.blob.core.customdomain.name',sas
//try to pass as two parameters.
But all failed.
I'm not sure there is another method.
I guess it maybe because the SAS token is only authorized to the abc
container, it can't read the domains root.
but if so, why the 2nd combination was also failed.
I use @azure/storage-blob v12.3.0