Categories
Azure SQL Server

Configuring Database Mail for SQL Agent Notifications in Managed Instance

SQL Agent jobs allow us to schedule and automate tasks on a SQL Server instance. Crucially, when things go wrong we need to know about them. That’s why we use notifications.

Setting up Operators and job Notifications is as expected on a Managed Instance. However, when it comes to sending the notifications we may have a challenge, as shown in the SQL Agent Error Logs:

SQL Agent Error Log showing a failure to send email notifications

The reason for this is that the Mail Profile hasn’t been configured against the SQL Server Agent. You can typically see this on the Properties dialog for the SQL Server Agent, but that’s not straightforward on a Managed Instance:

Comparison of the context menu for a SQL Managed Instance against a regular on-premises installation

There are no Properties available. On a regular instance, our configuration would look something like this:

Mail configuration of SQL Agent for an on-premises installation

So how do we configure the mail profile on a Managed Instance?

Well, we can’t. But we aren’t going to be left without notifications.

Instead of being configurable, the SQL Server Agent is hard-coded to look for a specific profile when sending notifications – AzureManagedInstance_dbmail_profile. This is due to the SQL Agent settings being read-only.

All we need is to create a profile on the instance which uses that specific name:

Creating a new Mail Profile within a Managed Instance using the required profile name

With the new specific profile in place, notifications will now automagically work as expected.

If you want to see what else you can’t do with the SQL Agent, check out these limitations and other differences you may stumble across in a Managed Instance.

2 replies on “Configuring Database Mail for SQL Agent Notifications in Managed Instance”

Leave a comment