在尝试使用Azure的Node.js SDK时,我目前遇到了一个403错误。当我直接调用它时,下面的函数工作得很好:
module.exports = function (file, callback) {
if (!fs.existsSync('./data')) {
mkdirp('./data', function (err) {
if (err) console.log(err)
})
}
fileService.getFileToStream('chatbot', '', file, fs.createWriteStream('data/' + file), function (err, res, response) {
if (!err) {
fs.readFile('data/' + file, 'utf8', function (err, data) {
if (!err) {
callback(null, data)
} else {
callback(err)
}
})
} else {
callback(err)
}
})
}但是,当我从更广泛的应用程序调用它时,我会收到一个403错误:
{ StorageError: Forbidden
at Function.StorageServiceClient._normalizeError (/Users/tombarton/Sites/TestApplication/node_modules/azure-storage/lib/common/services/storageserviceclient.js:1174:23)
at FileService.StorageServiceClient._processResponse (/Users/tombarton/Sites/TestApplication/node_modules/azure-storage/lib/common/services/storageserviceclient.js:729:50)
at Request.processResponseCallback [as _callback] (/Users/tombarton/Sites/TestApplication/node_modules/azure-storage/lib/common/services/storageserviceclient.js:310:37)
at Request.self.callback (/Users/tombarton/Sites/TestApplication/node_modules/azure-storage/node_modules/request/request.js:187:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request.<anonymous> (/Users/tombarton/Sites/TestApplication/node_modules/azure-storage/node_modules/request/request.js:1044:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at IncomingMessage.<anonymous> (/Users/tombarton/Sites/TestApplication/node_modules/azure-storage/node_modules/request/request.js:965:12)
name: 'StorageError',
message: 'Forbidden',
code: 'Forbidden',
statusCode: 403,
requestId: '51ce6605-001a-00c1-1d52-ae966b000000' }问题是,除了403错误之外,我似乎无法进一步调试它。由于代码完全独立工作,所以我知道访问密钥不是问题。Azure允许您记录表、Blobs和队列的访问数据,但不能记录文件服务( File )的访问数据,这似乎令人难以置信地沮丧(https://learn.microsoft.com/en-us/rest/api/storageservices/fileservices/enabling-storage-logging-and-accessing-log-data#HowtoenableStorageLoggingusingtheWindowsAzureManagementPortal)。
有人对我如何进一步调试这个问题有任何想法吗?
发布于 2017-04-06 15:06:40
有一个ApplicationInsights包中的问题会导致存储端的403个响应。此问题已在0.18.0版中得到解决。
https://stackoverflow.com/questions/43241910
复制相似问题