'How to fetch a particular column from storage account table using node?

I need to get a list of a particular column in a storage account table. But when I tried to do with the help of Microsoft documents, I'm getting an HTTP 403 "failed to authenticate" error.

My code is as follows:

const timestamp = (new Date()).toUTCString();
const accessKey = await StorageAccount.GetAccountKeyAsync();
const encodedUriPath = `${tableName}(PartitionKey='${partitionkey}', RowKey='${rowkey}')?$select=columnname`;
const endPoint = `https://${storageAccountName}.table.core.windows.net/${encodedUriPath}`;
const parsedUrl = url.parse(endPoint);
const stringToSign = timestamp + '\n/' + storageAccountName + parsedUrl.path;
const sharedKeyLite = crypto.createHmac('sha256', Buffer.from(accessKey, 'base64'))
  .update(stringToSign)
  .digest('base64');
return backOff(() => new Promise<Entity>((resolve, reject) => {
  request.get({
    'headers': {
      'Authorization': 'SharedKeyLite ' + tableService.storageAccountName + ':' + sharedKeyLite,
      'x-ms-date': timestamp,
      'x-ms-version': tableService.storageApiVersion,
      'Accept': 'application/json',
      'Prefer': 'return-content'
    },
    'url': endPoint,
    'json': true
  }, function (err, result) {
    if (err) {
      return reject(err);
    }
    return resolve(result.body));
  });
}), AzureBackOff.retryPolicy);

Please help me to resolve this. Thanks in advance



Solution 1:[1]

403 means there is something wrong with your SAS token or shared key. You can use storage explorer to generate SAS with the same configuration and see if it works.

Azure Table storage is a service that stores non-relational structured data (also known as structured NoSQL data) in the cloud, providing a key/attribute store with a schemaless design. There is no easy way to query the union of all properties of all entities in a table.

Workaround – You can pull out the data and do a distinct on the union.

You can refer this link for more information

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 AbhishekKhandave-MT