tommy vercetti
tommy vercetti

Reputation: 307

Azure Function cost - are operations triggered by function also counted as function execution time?

I'm trying to estimate costs of Azure Functions. One thing that stays unclear for me is how exactly time execution of a function is being measured. I mean here an Azure Function that uses some binding such as Azure Cosmos DB Binding or File Storage binding.

For instance, I have a node.js azure function with outputBinding:

module.exports = function (context) {

  context.bindings.employeeDocument = JSON.stringify({ 
    id: context.bindings.myQueueItem.name + "-" + context.bindings.myQueueItem.employeeId,
    name: context.bindings.myQueueItem.name,
    employeeId: context.bindings.myQueueItem.employeeId,
    address: context.bindings.myQueueItem.address
  });

  context.done();
};

We set output binding to property "employeeDocument" and the data is being saved into DB after function returns. The question is: what happens after above block of code (saving to DB, maybe within some transaction, maybe other operations required for DB save) is it also counted as a time of execution of azure function? In other words, do we pay also for that what happens after we leave function block but was triggered by function?

Upvotes: 2

Views: 262

Answers (1)

Chris Anderson
Chris Anderson

Reputation: 8515

You pay from the time the "Function Started" message to the "Function Completed" message you see in your logs. This includes time to process input and output bindings. For estimating how much you'll pay, you can use the Azure Monitoring meter for duration (this is aggregated over time, across functions, so not very granular). If you want more granular insight, turn on App Insights for your Function App and use the duration property on the requests table.

Upvotes: 1

Related Questions