Page Type | Languages | Key Services | Tools |
---|---|---|---|
Sample | Python PowerShell |
Azure Communication Services (ACS) |
This is a work-in-progress repository to demonstrate how to use the features of Azure Communication Services.
- An Azure Subscription - for hosting cloud infrastructure
- Az CLI - for deploying Azure infrastructure as code
- Python - for Python development
This section uses this guide as a basis to demonstrate how to use Python to send emails with Azure Communication Services' email-as-a-service solution.
The steps to set up and send emails are as follows:
-
In the
infra/acs.ps1
file:- Note: Ensure you run
az login
prior to running any other Az CLI commands. - Update the variable names to the resource names you'd like to use.
- Run the
az group create
command to create a resource group. - Run the
az communication create
command to create an Azure Communication Services resource (doc).
- Note: Ensure you run
-
Get the connection string by navigating to the ACS resource that was created and go to the 'Keys' blade.
-
Create an Email Communication Service (via Azure Portal):
- Follow the steps laid out in this guide.
- Note: Ensure that the Email Communication Service is created with the same Data Location as the Azure Communication Services resource set up in the previous step.
- Go to the 'Provision domains' blade of the newly created Email Communication Service and either add a free Azure subdomain or set up a custom domain. This will create an Email Communication Services Domain resource.
- Follow the steps laid out in this guide.
-
In Azure Communication Service resource, connect the domain you just created:
- Follow the steps laid out in this guide.
- Install the dependencies listed in the
email/requirements.txt
file. - In the
email/
folder, create a file calledconnection.txt
. Paste the connection string from Step 2 above into the file. - Update the
sender_address
variable inemail/send-email.py
:- Go to the Email Communication Services Domain resource created in Step 3 above. You may edit and retrieve the 'MailFrom' value from here.
- Update the
sender_address
variable with the 'MailFrom' value.
- Update the
recipient_address
variable inemail/send-email.py
with your desired recipient email address. - Run the code in
email/send-email.py
.