【问题标题】:Timeout Azure Function if trigger other azure function如果触发其他 azure 函数,则超时 Azure 函数
【发布时间】: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
    };


};

【问题讨论】:

标签: node.js azure timeout azure-functions


【解决方案1】:

你的代码逻辑可能会卡在某个点,所以它给你超时。(Azure函数有一个默认的超时限制。)我认为Azure持久函数的函数链完全符合你的要求,并且你正在使用nodejs,所以支持天蓝色持久功能。

请看这个:

https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-sequence?tabs=javascript

【讨论】:

    猜你喜欢
    • 2021-03-26
    • 2017-12-30
    • 2020-07-03
    • 1970-01-01
    • 2021-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多