Send emails via SMTP relay with Azure Communication Service
We’ve come across multiple cases where customers want to send emails from Applications migrated to Azure through some kind of SMTP service. Though we’ve seen customers opting for O365 for SMTP relay, this can create issues due to throttling limitations in Office Service. Also, managing mailbox and license assignment on Office 365 console is a different story; customers would want to have seamless SMTP relay service experience from single console on Azure.
Though Azure Communication service supports sending emails outbound but currently it requires you to integrate it via the ACS SDK that Microsoft provide. In scenarios where you don’t want to modify code and just change the pointing of your SMTP server to Azure, you can now use ACS - SMTP relay built into Email communication service.
Azure Communication Service supports different types of notifications, SMTP relay in ACS is now Generally available and this blog post is simple step by step instructions of how you can quickly test the service and then migrate from Sendgrid or another service you’re using to native ACS – Email communication service for better operational experience and support.
Create Azure Communication Service Account
First step you’ll need to do is to create an ACS account. This is a parent service which has multiple notification services inside it(Chat,SMS, Email etc). Email communications service is one of them.
Create Email communication service
We’ll have to create ECS which is the actual service that holds configuration details.
Add a custom domain to ECS
ECS provides Azure managed domain which look like this “GUID.azurecomm.net” this provides limited volume of email hence using custom domain is preferred. Once you add a custom domain, the UI provides you with TXT record which you’ll need to create in your Name server. This would take 15 minutes to verify the domain
Once domain is verified the screen looks like this, you’ll have to create SPF and DKIM records so that your email doesn’t land in junk and ownership is maintained.
Once all the records are created the screen would look like this, please ignore the azure managed domain. You can only have custom domain in the account and doesn’t have to add Azure Domain explicitly.
Attach custom domain to ACS Account
Once email is validated we’ll need to attach ECS to ACS.
Create and Assign custom RBAC Role for Authentication
We’ll be using 587 port to send email which is authenticated SMTP. For authentication we have Entra ID authentication. Create a service principal by going to Entra ID – App registration page. Register the app and create a client secret. Note down Client ID, Tenant ID and Secret value. This will be used in next stage for authentication. We’ll need to create a custom RBAC role which has permission to send email. We’ll clone reader role.
And we’ll be adding two actions which is present in Azure Communication service resource provider.
Once the Role is created we’ll need to assign this to service principal
Test SMTP Relay via Powershell
That’s all, now you’ll need to find out the sender email. Which is default [email protected]
You’ll need credentials to authenticate to the service.
- Username is < Azure Communication Services Resource name>. < Entra Application ID>. < Entra Tenant ID>
- Password is the client secret which you’ve generated.
- Port that we’ll need to use is 587
- SMTP server address is smtp.azurecomm.net
Now you can use any third party application to send email via the above parameters. To showcase we can use PowerShell with the same parameters to send emails.
Conclusion: I trust this guide helps you in configuring SMTP relay and send emails from your custom application without any change to the application/code.
Happy Learning!
Personal Blog post of SMTP relay:
Send emails via SMTP relay with Azure Communication Service
Find similar tech blog on my personal blog
https://www.azuredoctor.com/
Published on:
Learn moreRelated posts
[Azure AI Search] Internal Server Error when creating CMK encrypted objects
Scenario Customers follow the Microsoft doc to create CMK encrypted objects (data source, index etc.), but get the 500 Internal Serv...
Azure SDK Release (September 2024)
The Azure SDKs release every month. This post includes the month's highlights and release notes. The post Azure SDK Release (September 2024) a...
Azure Boards, September Update
September was a productive month for Azure Boards, and we’re excited to share some of the new features coming your way. Area and Iteration Lev...
Build a chatbot on your own data in 1 hour with Azure SQL, Langchain and Chainlit
Chatbots are the hot topic lately, and now you can create them easily by downloading solutions like OpenWebUI, connect it to Ollama or any Ope...
Announcing the public preview of the new Azure FXv2-series Virtual Machines
Today, Microsoft is announcing the public preview of the new Azure FXv2-series Virtual Machines (VMs), based on the 5th Generation Intel® Xeon...
Specifying client ID and secret when creating an Azure ACS principal via AppRegNew.aspx will be removed
Starting from early October 2024, Azure ACS (Access Control Service) will remove the option to specify client ID and secret when creating prin...
Azure Meetup Duesseldorf
Talk: How to get from DevOops to DevOps - Learn how to deploy your Power Platform projects with Azure DevOps.
Announcing Public Preview of Windows Server Hotpatch enabled by Azure Arc
We’re excited to announce the Public Preview of Hotpatch enabled by Azure Arc for Windows Sever 2025 Datacenter and Standard editions! ...
OneDrive support for RemoteApp in Azure Virtual Desktop
We are excited to announce that Microsoft OneDrive support is now available for RemoteApp in Azure Virtual Desktop! Previously, OneDrive could...
Announcing Cost and Performance Improvements with Azure Cosmos DB’s Binary Encoding
We are excited to announce a significant enhancement to Azure Cosmos DB, bringing substantial cost savings and performance improvements to our...