如何使用节点从存储帐户表获取特定列?

发布于 2025-01-30 13:37:07 字数 1239 浏览 3 评论 0原文

我需要在存储帐户表中获取特定列的列表。但是,当我尝试借助Microsoft文档时,我会得到HTTP 403“未能身份验证”错误。

我的代码如下:

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);

请帮助我解决此问题。提前致谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

就此别过 2025-02-06 13:37:07

403意味着您的SAS令牌或共享密钥有问题。您可以使用存储资源管理器以相同的配置生成SAS,并查看其是否有效。

Azure表存储是一种在云中存储非相关结构化数据(也称为结构化NOSQL数据)的服务,它提供了一个 schemaless 设计的密钥/属性存储。没有简单的方法可以查询表格中所有实体的所有属性的结合。

解决方法 - 您可以拿出数据并在工会上做明显的事情。

您可以参考此 link 有关更多信息

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文