ApplicationInsights-node.js icon indicating copy to clipboard operation
ApplicationInsights-node.js copied to clipboard

Examples for wrapping an Azure Functions timer trigger?

Open timtucker-dte opened this issue 3 years ago • 2 comments

All the Azure Functions examples are focused on wrapping http triggers.

Can we get an example for correlating the logs associated with the invocation of an Timer Trigger function? https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer?tabs=in-process&pivots=programming-language-javascript

timtucker-dte avatar May 26 '22 16:05 timtucker-dte

@timtucker-dte I never used Timer triggers before but looking at the example in the docs you shared, looks like "context" object should be available, so example code should work, are you getting some kind or error?

hectorhdzg avatar May 31 '22 16:05 hectorhdzg

The issue was that there's no request for a timer.

I did some more looking and eventually found that startOperation had an alternate signature that took in a string instead of a request, then found that I could just pass context.executionContext.functionName to both that and the later call to trackRequest (as the name, instead of building it from the request URL).

Also needed to pass url as undefined (since trackRequest requires a value for url)

timtucker-dte avatar May 31 '22 17:05 timtucker-dte