Home > OS >  How to configure Azure APIM policy to send emails in case 401 errors
How to configure Azure APIM policy to send emails in case 401 errors

Time:02-09

I have a requirement to send alerts via emails in case if an API fails with 401 (Unauthorized access) errors. These apis use api-key for authentication. I tried to trigger a logic app from the on-error section of the Azure APIM policy but that didn't work. Is there a way to trigger an email (via logic app or any other means) in case of a 401 error?

Please note: I have already configured Azure Monitor alerts for 401 errors which notify us when the number of 401 errors exceed a threshold value. However, for some of our critical APIs we want to get alerted as soon as there is an unauthorised access error.

CodePudding user response:

No need to make things complicated with logic apps or azure functions.

Simply use Azure Alerts and create a query for your API logs that checks for status code 401

If you then see 401 the alert can send emails, send push messages, do many things out of the box it can also be setup to send messages to slack channels or teams, it is very powerful.

CodePudding user response:

Just attach App Insights to your APIM and create a metric based alert. No need to setup logic apps or write up your own query.

  •  Tags:  
  • Related