angular-azure-blob-service
angular-azure-blob-service copied to clipboard
Getting 403 on using SAS token generated programmatically from "azure-storage" npm module (azure storage SDK "generateSharedAccessSignature" method). Works fine with SAS token generated through azure portal.
Getting this error in response when trying to upload -
<Error><Code>AuthenticationFailed</Code><Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. </Message><AuthenticationErrorDetail>Signature fields not well formed.</AuthenticationErrorDetail></Error>
Javacript function -
function getSASUri(containerName,blobName) {
var accountName = config.StorageAccountName;
var accountKey = config.StorageAccountKey;
var blobService = azure.createBlobService(accountName, accountKey);
var startDate = new Date();
startDate.setDate(startDate.getDate() - 5);
var expiryDate = new Date(startDate);
expiryDate.setDate(startDate.getDate() + 10);
var sharedAccessPolicy = {
AccessPolicy: {
Permissions: 'rwdlacup',
Start: startDate,
Expiry: expiryDate
}
};
let token = blobService.generateSharedAccessSignature(containerName, blobName, sharedAccessPolicy);
var sasUrl = blobService.getUrl(containerName, blobName, token);
return {
token : token,
sasUrl : sasUrl
};
};