How do I get email alerts with Azure SQL Instance as a Service similar to alerts from SQL Server.

Sawyer, Robert E 1 Reputation point
2022-11-21T21:52:08.267+00:00

SQL Server normally has alerts, this feature is not available on Azure SQL Instance as a service. What do I have to do or purchase to get this functionality?

Azure SQL Database
{count} votes

3 answers

Sort by: Most helpful
  1. Sawyer, Robert E 1 Reputation point
    2022-11-21T21:58:32.88+00:00

    Ok, here is the stupid answer,

    Create a job that queries the event logs and send an email if it sees a login failure. Keep a table with the last time it ran and filter the results by time.

    However, I don't seem to be able to query the event logs either.

    0 comments No comments

  2. Alberto Morillo 28,036 Reputation points MVP
    2022-11-21T22:05:56.31+00:00

    You can send alerts using dbmail on Managed Instance as explained on this documentation. You can use sp_readmierrorlog to read Managed Instance error log as explained on this documentation.


  3. Bas Pruijn 846 Reputation points
    2022-11-22T12:21:34.247+00:00

    If you are looking for a way to check login failures, you should look at setting up security auditing on the database or server. You can send the audit logs to storage, Event Hub or Log Analytics. Querying results in Log Analytics is not hard to do. All is described here: https://learn.microsoft.com/en-us/azure/azure-sql/database/auditing-overview?view=azuresql

    An other approach would be to make use of Azure SQL triggered functions. A function is triggered every time something changes in a table in the database (insert/update/delete). See https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-azure-sql?tabs=in-process%2Cextensionv4&pivots=programming-language-csharp. This functionality is still in preview though.

    0 comments No comments