Azure Function with Service Control (Heartbeat & Metrics)

What is the teams advise on using Heartbeats and Metrics when running in an Azure Functions, assuming function are not running continually.

I have a NServicebus Azure Function that’s being triggered every 15min. It also has Heartbeat and Metrics enabled and it seems to be up continuously (which is logic if youre sending an heartbeat every 20sec). But this conflicts with the benefit of not running your function all the time.

Should I disable Heartbeat? I’m ok with that, but I still would like to recieive Metrics when it’s running. Is there a best practice configurating this, so that my function is not running constant?

Hi Remy,

The Heartbeats plugin and Metrics plugin do both have background processes that run while the endpoint is active but neither of them should affect the lifecycle of the function host. The function host will be shutdown if there has been no triggered functions in the timeframe defined by the functionTimeout. Even if one of the plugins is still running in the background, the process will be shut down if that timeout is reached.

Having said that, the heartbeats plugin is designed for endpoints that are “always on” and I wouldn’t recommend using it for endpoints hosted in Azure Functions.

The metrics plugin should work with Azure Functions but we haven’t specifically tested that combination. The plugin collects metric data about each message and sends a message with that data when its internal buffers are full or when a specific interval has passed (depending on which comes first).

Are there specific metrics that you are interested in that are missing from the built-in metrics that Azure Functions provides?

-Mike

Good to know that heartbeat and metrics are background processes and will not affect the lifecycle of the function host.

Are there specific metrics that you are interested in that are missing from the built-in metrics that Azure Functions provides?
No, I’m not missing any metrics. I use ServicePulse to monitor, and my understanding is that the following line is feeding these metrics to ServicePulse (through ServiceControl):
endpointConfiguration.EnableMetrics().SendMetricDataToServiceControl()

So therefore, I want this to be enabled when the Azure function is being triggered/running.

You are correct that the highlighted configuration sends data that shows up in ServicePulse.

Please let us know if you run into any issues with it.