If you are a Database Administrator, you always need to know what is happening in the database. You need to be aware of the activities going on in the database.
Therefore, in order to monitor activities in the database, email notifications can help a lot. You can define a notification email that will be triggered when a certain action triggers in the database.
In an Azure SQL database, you can send email notifications using a SendGrid account. This article will help you to know how you can send email notifications with the help of a SendGrid account.
- Create SendGrid account in Azure
- Generate API key in SendGrid
- Create a logic app in Azure
Create SendGrid account in Azure
This section will help you to create a SendGrid account in Microsoft Azure. Follow the below steps to create a SendGrid account:
- Open your Azure portal and search for SendGrid in the search box.
- Click on SendGrid Accounts.

- Click on Create to create a new SendGrid account.
- Specfify the subscription to use, resource group, name of the account and your plan. You can click on Change plan to select the plan you want to use.
- I am using the Free plan. You can select any plan depending on your requirements. Click on Review + subscribe.

- Review the configuration of the SendGrid account and click on Subscribe.
- The subscription is created. However, the process is not complete yet.
- In the Azure portal, search for your SendGrid account in the search box and click on it.
- Then click on Open SaaS Account on publisher’s site to configure your SendGrid account. The SendGrid website will be opened in a new tab.
- Firstly, you have to verify your account details. Also, you have to create a sender. I am selecting the Single Sender type.
- Enter the details of the sender like email address that will be used to send the email. After entering the details, click on Create.

- Once your have created the sender, you have to verify the sender email address.
- After the verification yo can navigate to your dashboard and manage your SendGrid account.
Read: How to Create a Single Database in Azure SQL
Generate API key in SendGrid
The next step is to create an API key that you will use to authenticate to the SendGrid account while sending emails from the Azure SQL database.
- To create an API key, navigate to Settings in the left side navigation bar and click on API Keys and then click on Create API Key.

- Specify the name for your API Key and select the access type according to your requirements. Click on Create & View.

- You will see the API key that you have generated. Copy that API Key in a safe place carefully.
Read: Pause and resume Azure SQL database
Create a logic app in Azure
The next step is to create a logic app in Azure. The logic app will help you to trigger an action. In our case, that action is to send an email using the SendGrid API. Follow the steps below to create the logic app:
- In the Azure portal, search for Logic Apps and open it.
- Click on Add to create a logic app.
- In the Basics tab, specify the subscription to use, name of the resource group, the logic app name and the region. Click on Next : Hosting >.

- In the Hosting tab, select the azure storage account to use and the plans type. If you do not have one, you have to create it. You can click on Next to configure more options. At the end click on Create.
- If you do not know how to create a storage account in Azure, you can read our article Backup and restore SQL Server to Azure Blob storage. We have defined in this article how you can create a storage account in Azure.
- The next step is to create triggers and actions in the Azure logic app.
- To create a trigger, open your logic app that you have created and click on Events in the left side navigation bar.
- Click on Logic Apps.

- Click on Templates and select the template named Blank Logic App.

- Search for SQL Server and select the trigger according to your requirements. I am selecting the When an item is created(v2). This trigger will fire an event when any new entry will be made in the spceified table in the database.
- You have to make a connection with your database. Specify the necessary details about your database to make a connection. See the image below for reference:

- Now you have to specify the table in the database in which when a record is created, an email will be sent. Also set the time frequency for the trigger.
- For example, if you have set the time frequeny to 1 minute, the trigger will check for any new record in the table after every 1 minute and send the email if any new record is found in the table. Click on New step.

- Search for SendGrid in the search box and click on SendGrid.
- In the SendGrid actions, select the Send email (v4) action.

- Specify the connection name of the connection to the Azure SQL database that we created earlier. In our example, it was TestCon. Also, specify the SendGrid API Key that you created earlier. Click on Create.

- Now you have to specify the email parameters like the sender’s email address, reciever’s email address, subject of the email and the body of the email.
- In the body of the email, you can also select some dynamic content.
- For example, you can create a column in the table to store HTML content and select this column in the email body. Now the HTML code will be sent to the sender.
- Click on Save As to save the app. Specofy the name of the app and click on Create to create the app.

- Now if we insert a new row in the Student table, we will get an email on the specified email address.
You may also like to read the following articles on Azure SQL.
- How to Connect to Azure SQL database
- Reset Password Azure SQL database
- Bulk loading data to Azure SQL
- How to create table in Azure SQL
- How to rename a database in Azure SQL
Thus, you might have learned how you can send emails from an Azure SQL database.
- Create SendGrid account in Azure
- Generate API key SendGrid
- Create a logic app in Azure
I am Bijay having more than 15 years of experience in the Software Industry. During this time, I have worked on MariaDB and used it in a lot of projects. Most of our readers are from the United States, Canada, United Kingdom, Australia, New Zealand, etc.
Want to learn MariaDB? Check out all the articles and tutorials that I wrote on MariaDB. Also, I am a Microsoft MVP.