How to add and remove Multiple Sender Addresses to Azure Email Communication Service programmatically

119 views Asked by At

We can add multiple email sender's addresses after configuring custom domain (https://learn.microsoft.com/en-us/azure/communication-services/quickstarts/email/add-multiple-senders):

adding sender

Now, I want to do it programmatically with some of the SDKs. Is there any possibilities to do that?

1

There are 1 answers

0
Dilshod K On BEST ANSWER

I found examples here: https://learn.microsoft.com/en-us/azure/communication-services/quickstarts/email/add-multiple-senders-mgmt-sdks?pivots=programming-language-csharp

string subscriptionId = "";
string resourceGroupName = "";
string emailServiceName = "";
string domainName = "";
string emailAddressToAdd = "no-replay";
ArmClient client = new(new DefaultAzureCredential());

ResourceIdentifier senderUsernameResourceId = SenderUsernameResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, emailServiceName, domainName, emailAddressToAdd);
SenderUsernameResource senderUsernameResource = client.GetSenderUsernameResource(senderUsernameResourceId);

SenderUsernameResourceData data = new()
{
    Username = emailAddressToAdd,
    DisplayName = "No Replay",
};
senderUsernameResource.Update(WaitUntil.Completed, data);