I am new Azure function. I want to call the Azure function which will trigger another Azure function. I have written bellow code but its giving me timeout. The code written in node js. Please suggest what to do.
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
};
};
Your code logic may be stuck at some point, so it gives you timeout.(Azure function has a default timeout limit.) I think the function chain of azure durable function fully meets your requirements, and you are using nodejs, so azure durable function is supported.
Please have a look of this: