To be able to use send Emails through the Azure Communication Service you need a few ressources that are best created using Infrastructure-as-Code – in this case with Bicep.
Here’s what we need:
- Email Communication Service
- Email Communication Services Domain – either provided by Azure which is good for testing purposes or a custom one for production
- SenderUsername for the domain (e.g. noreply@mydomain.com)
- Communication Service that is linked to the Domain
To support different environments we also want to use an Azure-managed domain e.g. for dev & test scenarios and a proper custom domain for production.
Note
Only a sucessfully verified Email Communication Service Domain can be linked to the Communication Service. So you might need to run the script, verify the domain when it first fails and then run the script again.
Code
Here’s the full code which can be called directly as a module by just passing the info if we’re in a production environment or not.
Also check out Philipp’s blog post about how to use the Azure Email Communication Service with .NET.
Hey Thomas, It was quite a insightful article for me as I’m trying to deploy about 100 email communication service to my Azure account.
I’m from non technical background and trying to understand how to deploy around 100 communication services with 100 different domains. Your article is the closet thing I found on internet.
Can you please give me some idea on how to do this? Deploying 100 communication service and 100 domains into my account and how to verify these domains after all.