首页 > 解决方案 > 根本不执行简单的 Azure retrieveEntity

问题描述

这个非常简单的事情对我不起作用,即使我实际上已经从这里复制+粘贴了示例代码:

https://github.com/Azure/azure-storage-node

似乎 tableService.retrieveEntity 根本不会触发?context.log 不打印任何内容。我得到一个没有正文的状态 200,但这是因为这是 Azure 的默认设置。

如果我编写查询并同时使用 queryEntities 方法,也会出现同样的问题。

为简单起见,我在 Azure 门户中编写了这些内容。

这是我的代码:

var azure = require('azure-storage');

module.exports = async function (context, req) {

    var tableService = azure.createTableService('myTable', 'GoYVMvN+SXRJhzVERIYWFu6k0/DkZINIerS+YpwmQVy3ppPFJ+8bTavfisHJvsNbo5hjgpw40bWv8XXXXXXXXX==');

    tableService.retrieveEntity('myList', 'MyPartitionKey', '1', function(error, result, response) {

        context.log("retrieving...")

        if(!error){
            context.res = {
                status: 200,
                body: "The entity was retrieved"
            }
        } else {
            context.res = {
                status: 500,
                body: "The entity was not retrieved"
            }
        }
    });
};

标签: node.jsazure

解决方案


推荐阅读