Quickstart: How to connect a verified email domain
This quickstart describes how to connect a verified domain in Azure Communication Services to send email.
Prerequisites
- An Azure account with an active subscription. Create an account for free..
- An Azure Email Communication Services Resource ready to provision domains. Get started creating an Email Communication Resource.
- An Azure Managed Domain or Custom Domain provisioned and ready to send emails. This domain must be fully verified before attempting to link it to the Communication Service resource.
- An Azure Communication Services Resource. Create a Communication Services Resources.
Connect an email domain to a Communication Service Resource
In the Azure Communication Service Resource overview page, in the left navigation panel under Email, click Domains.
Select one of the following options:
Select one of the verified domains by filtering:
- Subscription
- Resource Group
- Email Service
- Verified Domain
Note
You can only connect domains in the same geography. Please ensure that the Data location for Communication Resource and Email Communication Resource you selected during resource creation are in the same geography.
Note
We enable customers to link up to 100 custom domains to a single communication service resource. All Mail-From addresses configured under these custom domains are accessible for the communication service resource. You can only link verified custom domains.
Disconnect an email domain from the Communication Service Resource
Prerequisites
- An Azure account with an active subscription. Create an account for free.
- An Azure Email Communication Services Resource ready to provision domains. Get started creating an Email Communication Resource.
- An Azure Managed Domain or Custom Domain provisioned and ready to send emails. This domain must be fully verified before attempting to link it to the Communication Service resource.
- An Azure Communication Services Resource. Create a Communication Services Resources.
Connect an email domain to a Communication Service Resource
Replace the {subscription-id}
, {resource-group-name}
, {communication-services-resource-name}
, and {linked-domain-resource-id}
in the sample request.
Format the linked domain resource ID as follows:
/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Communication/emailServices/{email-service-name}/domains/{domain-name}
If you're using an Azure Managed Domain, the domain-name
is "AzureManagedDomain". The email-service-name
should be the same email service that you used to provision the domain.
Once these values are populated, make a PATCH request using the following Request URL and body.
https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Communication/CommunicationServices/{communication-services-resource-name}?api-version=2023-03-31
{
"properties": {
"linkedDomains": ["{linked-domain-resource-id}"]
}
}
Disconnect an email domain from the Communication Service Resource
Replace the {subscription-id}
, {resource-group-name}
, and {communication-services-resource-name}
in the sample request.
Once these values are populated, make a PATCH request using the following Request URL and body.
https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Communication/CommunicationServices/{communication-services-resource-name}?api-version=2023-03-31
{
"properties": {
"linkedDomains": []
}
}
Prerequisites
- An Azure account with an active subscription. Create an account for free.
- An Azure Email Communication Services Resource ready to provision domains. Get started creating an Email Communication Resource.
- An Azure Managed Domain or Custom Domain provisioned and ready to send emails. This domain must be fully verified before attempting to link it to the Communication Service resource.
- An Azure Communication Services Resource. Create a Communication Services Resources.
- We're using a service principal for authentication. Set the values of the client ID, tenant ID, and client secret of the Microsoft Entra application as the following environment variables:
AZURE_CLIENT_ID
,AZURE_TENANT_ID
, andAZURE_CLIENT_SECRET
.
Install the required packages
dotnet add package Azure.ResourceManager.Communication
Initialize the management client
Set the environment variable AZURE_SUBSCRIPTION_ID
with the subscription ID of the subscription your Domain and Email resources are in. Run the code sample to initialize the management client.
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Compute;
using Azure.ResourceManager.Resources;
ArmClient client = new ArmClient(new DefaultAzureCredential());
Connect an email domain to a Communication Service Resource
Replace the <subscription-id>
, <resource-group-name>
, <azure-communication-services-resource-name>
, and <linked-domain-resource-id>
in the sample code.
Format the linked domain resource ID as follows:
/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.Communication/emailServices/<email-service-name>/domains/<domain-name>
If you're using an Azure Managed Domain, the domain-name
is "AzureManagedDomain." The email-service-name
should be the same email service that you used to provision the domain.
Once these values are populated, run the sample code.
ResourceIdentifier communicationServiceResourceId = CommunicationServiceResource.CreateResourceIdentifier("<subscription-id>", "<resource-group-name>", "<azure-communication-services-resource-name>");
CommunicationServiceResource communicationServiceResource = client.GetCommunicationServiceResource(communicationServiceResourceId);
CommunicationServiceResourcePatch patch = new CommunicationServiceResourcePatch()
{
LinkedDomains =
{
"<linked-domain-resource-id>",
},
};
CommunicationServiceResource result = await communicationServiceResource.UpdateAsync(patch);
Disconnect an email domain from the Communication Service Resource
Replace the <subscription-id>
, <resource-group-name>
, and <azure-communication-services-resource-name>
in the sample code.
Once these values are populated, run the sample code.
ResourceIdentifier communicationServiceResourceId = CommunicationServiceResource.CreateResourceIdentifier("<subscription-id>", "<resource-group-name>", "<azure-communication-services-resource-name>");
CommunicationServiceResource communicationServiceResource = client.GetCommunicationServiceResource(communicationServiceResourceId);
CommunicationServiceResourcePatch patch = new CommunicationServiceResourcePatch();
patch.LinkedDomains.Clear();
CommunicationServiceResource result = await communicationServiceResource.UpdateAsync(patch);
Prerequisites
- An Azure account with an active subscription. Create an account for free.
- An Azure Email Communication Services Resource ready to provision domains. Get started creating an Email Communication Resource.
- An Azure Managed Domain or Custom Domain provisioned and ready to send emails. This domain must be fully verified before attempting to link it to the Communication Service resource.
- An Azure Communication Services Resource. Create a Communication Services Resources.
- We're using a service principal for authentication. Set the values of the client ID, tenant ID, and client secret of the Microsoft Entra application as the following environment variables:
AZURE_CLIENT_ID
,AZURE_TENANT_ID
, andAZURE_CLIENT_SECRET
.
Install the required packages
npm install @azure/arm-communication
npm install @azure/identity
Initialize the management client
Replace the field in the sample code with the subscription ID of the subscription your Domain and Email resources are in. Run the code sample to initialize the management client.
const { CommunicationServiceManagementClient } = require("@azure/arm-communication");
const { DefaultAzureCredential } = require("@azure/identity");
const credential = new DefaultAzureCredential();
const subscriptionId = "<your-subscription-id>";
client = new CommunicationServiceManagementClient(credential, subscriptionId);
Connect an email domain to a Communication Service Resource
Replace the <resource-group-name>
, <azure-communication-services-resource-name>
, and <linked-domain-resource-id>
in the sample code.
Format the linked domain resource ID as follows:
/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.Communication/emailServices/<email-service-name>/domains/<domain-name>
If you're using an Azure Managed Domain, the domain-name
is "AzureManagedDomain". The email-service-name
should be the same email service that you used to provision the domain.
Once these values are populated, run the sample code.
const parameters = {
dataLocation: "United States",
location: "Global",
linkedDomains: [
"<linked-domain-resource-id>"
]
};
const result = await client.communicationServices.beginCreateOrUpdateAndWait(
"<resource-group-name>",
"<azure-communication-services-resource-name>",
parameters
);
Disconnect an email domain from the Communication Service Resource
Replace the <resource-group-name>
, and <azure-communication-services-resource-name>
in the sample code.
Once these values are populated, run the sample code.
const parameters = {
dataLocation: "United States",
location: "Global"
};
const result = await client.communicationServices.beginCreateOrUpdateAndWait(
"<resource-group-name>",
"<azure-communication-services-resource-name>",
parameters
);
Prerequisites
- An Azure account with an active subscription. Create an account for free..
- An Azure Email Communication Services Resource ready to provision domains. Get started creating an Email Communication Resource.
- An Azure Managed Domain or Custom Domain provisioned and ready to send emails. This domain must be fully verified before attempting to link it to the Communication Service resource.
- An Azure Communication Services Resource. Create a Communication Services Resources.
- We're using a service principal for authentication. Set the values of the client ID, tenant ID and client secret of the Microsoft Entra application as the following environment variables:
AZURE_CLIENT_ID
,AZURE_TENANT_ID
, andAZURE_CLIENT_SECRET
.
Install the required packages
Add the following dependency to your pom.xml
.
<dependency>
<groupId>com.azure.resourcemanager</groupId>
<artifactId>azure-resourcemanager-communication</artifactId>
<version>2.0.0</version>
</dependency>
Initialize the management client
Set the environment variable AZURE_SUBSCRIPTION_ID
with the subscription ID of the subscription your Domain and Email resources are in. Run the code sample to initialize the management client.
AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);
TokenCredential credential = new DefaultAzureCredentialBuilder()
.authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint())
.build();
CommunicationManager manager = CommunicationManager
.authenticate(credential, profile);
Connect an email domain to a Communication Service Resource
Replace the <resource-group-name>
, <azure-communication-services-resource-name>
, and <linked-domain-resource-id>
in the sample code.
The linked domain resource ID should be in the following format.
/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.Communication/emailServices/<email-service-name>/domains/<domain-name>
If you are using an Azure Managed Domain, the domain-name
is "AzureManagedDomain". The email-service-name
should be the same email service that you used to provision the domain.
Once these values are populated, run the sample code.
List<String> linkedDomains = new ArrayList<>();
linkedDomains.add("<linked-domain-resource-id>")
manager
.communicationServices()
.define("<azure-communication-services-resource-name>")
.withRegion("Global")
.withExistingResourceGroup("<resource-group-name>")
.withDataLocation("United States")
.withLinkedDomains(linkedDomains)
.create();
Disconnect an email domain from the Communication Service Resource
Replace the <resource-group-name>
, and <azure-communication-services-resource-name>
in the sample code.
Once these values are populated run the sample code.
manager
.communicationServices()
.define("<azure-communication-services-resource-name>")
.withRegion("Global")
.withExistingResourceGroup("<resource-group-name>")
.withDataLocation("United States")
.create();
Prerequisites
- An Azure account with an active subscription. Create an account for free..
- An Azure Email Communication Services Resource ready to provision domains. Get started creating an Email Communication Resource.
- An Azure Managed Domain or Custom Domain provisioned and ready to send emails. This domain must be fully verified before attempting to link it to the Communication Service resource.
- An Azure Communication Services Resource. Create a Communication Services Resources.
- We're using a service principal for authentication. Set the values of the client ID, tenant ID and client secret of the Microsoft Entra application as the following environment variables:
AZURE_CLIENT_ID
,AZURE_TENANT_ID
, andAZURE_CLIENT_SECRET
.
Install the required packages
pip install azure-mgmt-communication
pip install azure-identity
Initialize the management client
Replace the field in the sample code with the subscription ID of the subscription your Domain and Email resources are in. Run the code sample to initialize the management client.
from azure.mgmt.communication import CommunicationServiceManagementClient
from azure.identity import DefaultAzureCredential
credential = DefaultAzureCredential()
subscription_id = "<your-subscription-id>"
client = CommunicationServiceManagementClient(credential, subscription_id)
Connect an email domain to a Communication Service Resource
Replace the <resource-group-name>
, <azure-communication-services-resource-name>
, and <linked-domain-resource-id>
in the sample code.
The linked domain resource ID should be in the following format.
/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.Communication/emailServices/<email-service-name>/domains/<domain-name>
If you are using an Azure Managed Domain, the domain-name
is "AzureManagedDomain". The email-service-name
should be the same email service that you used to provision the domain.
Once these values are populated, run the sample code.
response = client.communication_services.begin_create_or_update(
resource_group_name="<resource-group-name>",
communication_service_name="<azure-communication-services-resource-name>",
parameters={
"location": "Global",
"properties": {
"dataLocation": "United States",
"linkedDomains": [
"<linked-domain-resource-id>"
],
}
},
).result()
Disconnect an email domain from the Communication Service Resource
Replace the <resource-group-name>
and <azure-communication-services-resource-name>
in the sample code.
Once these values are populated run the sample code.
response = client.communication_services.begin_create_or_update(
resource_group_name="<resource-group-name>",
communication_service_name="<azure-communication-services-resource-name>",
parameters={
"location": "Global",
"properties": {
"dataLocation": "United States"
}
},
).result()
Next steps
Related articles
- Familiarize yourself with the Email client library