【发布时间】:2020-09-08 04:26:06
【问题描述】:
我是新的 Azure 函数。我想调用将触发另一个 Azure 函数的 Azure 函数。我写了下面的代码,但它给了我超时。用 node js 编写的代码。 请提出建议。
module.exports = async function (context, req, callback) {
UtilityAccountNumber=req.body.UtilityAccountNumber.split(',');
if(UtilityAccountNumber=='' || typeof UtilityAccountNumber==='undefined' || !(Array.isArray(UtilityAccountNumber) && UtilityAccountNumber.length) ){
response={
status: 0,
message:"Please provide utility acccount number."
};
else{
if(UtilityAccountNumber.length){
for(let accountNo of UtilityAccountNumber){
try
{
var options = {
host: process.env.API_HOST,
port: process.env.PORT,
path: '/api/'+process.env.WEBSCRAPERMASTER,
method: 'POST'
};
var myreq = http.request(options, function(res) {
});
myreq.end();
}
catch (ex) // if failed
{
await logHTTPErrorResponse(ex, huId);
console.error(ex);
}
}
}
}
context.res = {
status: 200,
body: response
};
};
【问题讨论】:
-
Azure Functions 中可能的最大超时为 10 分钟。您的用例听起来很适合作为 Azure Functions 扩展的 Durable 函数。你已经探索过它们了吗?如果没有,这些链接可能会有所帮助。 Durable 函数入门 - [docs.microsoft.com/en-us/azure/azure-functions/durable/… 还可以查看函数链 [docs.microsoft.com/en-us/azure/azure-functions/durable/…
标签: node.js azure timeout azure-functions