bajermi2
bajermi2

Reputation: 418

Alert when Azure function fails to initialize

I have an Azure function, which fails while running Startup.cs (while initializing the runtime) because it can't load a key from a Key vault. I would like to automate the deployment of this function in the future and therefore I would like to set up an alert to trigger if the function can't initialize correctly for any reason. (I can fix this speficic error, I just use it as an example).

At the moment I see the error in the Notifications section of the function page in the Azure portal: Notifications

I also see the exceptions in Diagnose and solve problems -> Availability and Performance: Availability and Performance

But I can't seem to find a way to set up an alert to respond to this situation. I assumed that Resource health alert would cover this, but it doesn't. Maybe because to portal reports the function as Status: Running. I also can't find this error in Application Insights.

Is there any way to set up this alert?

Upvotes: 2

Views: 1069

Answers (1)

Pravallika KV
Pravallika KV

Reputation: 8704

To create the Alerts for Function App Runtime failures, start with the Alert Action Groups.

Open your function app in the Azure Portal and create the action group that points to your function and email configuration:

enter image description here

enter image description here

In the same function app menu > Logs > Get the Function Request Failure results such as below:
enter image description here

Then, click on “New Alert Rule” > Insert the values for Alert logic such as Frequency of Evaluation, Operator, Threshold Value, Measure of data summary, etc.,

  • Next, Select the Action Group which is created at the starting - that contains the Selected Function Data and the Email Notification configuration details:

enter image description here

enter image description here

After configuring the alert group, you’ll get the mail that the alerts are mailed accordingly:
enter image description here

I have given the wrong input to get the alert for the Function Runtime failure, which is driven to the Alerts:
Result:

enter image description here

enter image description here

For more details regarding Azure Alerts, refer to this MS Doc.

Updated Answer:

enter image description here - This query gives the function errors messages in the logs and from this panel we can create the alert rule for the errors and warnings.

Upvotes: 1

Related Questions