Ever wondered how you can receive an SMS or email notification when an exception occurs e.g. when an email is not sent or a user was not able to sign in with Microsoft? In this article, I will explain how you can receive an SMS whenever the WPO365 | LOGIN plugin cannot sign in a user or failed to send an email.
First of all, sign into Azure Portal and create a new Application Insights resource.
Application Insights is a great help to collect diagnostic data such as traces and exceptions. On top of that it allows you to configure Alerts that help you monitor – for example – the performance of the WPO365 | LOGIN plugin, as I am about to explain. Once you created a new Application Insights resource in Azure, you can refer to it, using its Instrumentation Key. You find this identifier on the Overview page of the Application Insights resource. Copy the Instrumentation Key to the clipboard, since you need it for the next step.
Next, navigate to the WPO365 | LOGIN plugin’s Debug page and change the log location from Locally (on the server) to Remotely (Application Insights). and paste the Instrumentation Key in the corresponding field that then appears.
From this moment, all Errors that the WPO365 | LOGIN plugin encounters, will be logged in Application Insights. If you would like to log also all Warning and Debug traces, then you must check the option Enable debug log on the plugin’s Debug page (this is not recommended for production).
Already now you are able to monitor all Errors in a very easy way. Simply go to your Application Insights resource and select Failures. On this page you can activate the Exceptions tab. On this tab you can change the timespan e.g. to view Exceptions that occurred in the last 3 days.
To get notified e.g. to receive an SMS whenever an exception is logged, select Alerts under the Monitoring menu and click to + Create a new Alert rule.
Please note that Alerts is a paid function and that you will be billed for it.
On the next page when creating an alert, you must specify the Condition when the Alert rule should trigger (and thus should notify you). As a Signal you must select Exceptions. If you leave the default Alert logic, Dimensions and When to evaluate unchanged, the alert will be triggered whenever 1 or more Exceptions occur in a timeframe of the last 5 minutes (and this is evaluated each minute).
Continue to Actions by clicking the Next: Actions button at the bottom of the Condition tab. On the Actions tab you can click to Create (a new) action group.
You are asked to enter a unique name and display name for the new Action group. The Action group bundles one or more notifications and one or more actions with the Alert rule.
Continue to Notifications by clicking the Next: Notifications button at the bottom.
Perform the following steps to create an Email and SMS notifications:
- Select Email / SMS / Push / Voice as the desired Notification type.
- Enter a name for the Notification.
- Fill out the details for Email and SMS in the Email / SMS message / Push / Voice panel.
- Optionally enable the common alert schema.
- Click OK to save the details for Email and SMS.
- Click Review + create and finalize the new Action group.
Please note As soon as you have completed the creation of the Action group, you will receive an SMS that you have been added to the new Action group. If you don’t receive this confirmation, then please review your configuration.
Once you’re back on the Actions tab of the Create Alert rule page, ensure that the new group has been selected. If not, then click to Select (an) action group and select the newly created Action group.
On the Create alert rule page, click Review + create and finalize the Alert rule.
At this point, you have configured a new Azure Alert rule and you will be notified (almost) instantly whenever the WPO365 | LOGIN plugin logs an Exception.