I am trying to configure an Azure function app health check, to check the availability of a function app.
So, I have created a separate endpoint for it. It seems to be working as seen in the metrics graph below.
But the health check status is stuck at Health Check:0.00% (Healthy 0 / Degraded 1)
.
Do you have any idea on how to make health check to work?
My code:
import base64
import json
import logging
import os
import azure.functions as func
import requests
def main(req: func.HttpRequest) -> func.HttpResponse:
return func.HttpResponse("", status_code=200)
2
Answers
I think the only problem is the
auth_level
. The default value isfunction
, which meansA function-specific API key is required
. The health check request doesn’t insert any keys, so requests to the endpoint will return 401 (Unauthorized).Depending on which version you use, the solution is the same, but applied at different points:
V1
Set the
authLevel
toanonymous
, something like the example below:V2
For those who are using the recent version, try to set the
auth_level
toANONYMOUS
like the example below:Another simple approach worth mention is to just point the health check path to the root of the application. By default it’ll return a homepage and 200 http code, which is exactly what you need.
If your health check doesn’t require anything fancy (checking other services, etc), that change will save you some functions calls.