Redaguoti

Bendrinti naudojant


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

Connect an email domain to a Communication Service Resource

  1. In the Azure Communication Service Resource overview page, in the left navigation panel under Email, click Domains.

    Screenshot that shows the left navigation panel for linking Email Domains.

  2. Select one of the following options:

    • From the upper navigation bar, click Connect domain.

    • From the splash screen, click Connect domain.

      Screenshot that shows how to connect one of your verified email domains.

  3. Select one of the verified domains by filtering:

    • Subscription
    • Resource Group
    • Email Service
    • Verified Domain

    Screenshot that shows how to filter and select one of the verified email domains to connect.

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.

  1. Click Connect.

    Screenshot that shows one of the verified email domains is now connected.

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

  1. In the Azure Communication Services Resource overview page, from the left navigation panel under Email, click Domains.

  2. Select the Connected Domains, then click ... and select Disconnect.

    Screenshot that shows how to disconnect the connected domain.

Prerequisites

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

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

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

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

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