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:

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:

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

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:

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”
[…] Andy Brownsword sends an e-mail: […]
Thank you very much for this article. Was a great help with our post migration monitoring.