如何使用节点从存储帐户表获取特定列?
我需要在存储帐户表中获取特定列的列表。但是,当我尝试借助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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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