Hi I have a azure storage account where i will upload and create a sas url to download the image. below is the code that i used ,
const {
BlobServiceClient,
StorageSharedKeyCredential,
BlobSASPermissions,
generateBlobSASQueryParameters,
} = require("@azure/storage-blob");
const { ClientSecretCredential } = require("@azure/identity");
const clientCred = new ClientSecretCredential(process.env.STORAGE_TENANT,process.env.STORAGE_APPID,process.env.STORAGE_PASSWORD)
const blobServiceClient = new BlobServiceClient(
`https://${process.env.STORAGE_ACCOUNT_NAME}.blob.core.windows.net`,
clientCred
);
var blobName = "blobName";
var containeName = process.env.PROFILE_UPLOAD_CONTAINER_NAME;
const containerClient = blobServiceClient.getContainerClient(containeName);
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
const response = await blockBlobClient.uploadData(image.data, {
blobHTTPHeaders: {
blobContentType: image.mimetype,
},
});
if (response.etag) {
const cerds = new StorageSharedKeyCredential(
process.env.STORAGE_APPID,** ( earlier i used account name and key it worked perfectly fine)**
process.env.STORAGE_PASSWORD
);
const date = new Date();
const expires = new Date(
Date.UTC(
date.getFullYear() + 2,
date.getMonth(),
date.getDate(),
23,
59,
59
)
);
const sasToken = generateBlobSASQueryParameters(
{
containerName: containeName,
blobName: blobName,
expiresOn: expires,
permissions: BlobSASPermissions.parse("racwd"),
},
**cerds** (i need to create cerds using tenantid,appid and password)
).toString();
const sasUrl = blockBlobClient.url + "?" + sasToken;
console.log("sasUrl", sasUrl);
I will not have account key. How to access the sasurl by using only tenantid,appid and password. Kindly guide
I am able to upload using tenantid,appid and password , but when i try to create a downloadable sasurl i am unable to do so, using the above tenantid,appid and password