Azure Email Communication Service is slow (30 seconds to send email)

37298796 15 Reputation points
2023-03-11T16:05:47.3133333+00:00

When I use Azure Email Communication Services, it takes approximately 30 seconds to send per email, which is extremely slow. I've tried reusing the emailClient to see if subsequent emails are faster, but they're not. I've tried both the default Microsoft "DoNotReply" sender address as well as a custom domain sender address, and they both take about the same time.

Here is the line of code that takes so long.

var emailResult = await emailClient.SendAsync(Azure.WaitUntil.Completed, emailMessage);

This poses a few questions:

  • Is this because it's currently in Preview, or is this how long I should expect?
  • Perhaps I need to configure something in Azure?
  • Something else I haven't thought of?
Azure Communication Services
Azure Communication Services
An Azure communication platform for deploying applications across devices and platforms.
1,242 questions
Developer technologies | ASP.NET | ASP.NET Core
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,970 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Kris Blom 5 Reputation points
    2023-03-17T13:04:49.4133333+00:00

    I had the exact same issue, but when I read this thread I learned that WaitUntil.Started is what I needed. Works great now. Thank you for posting the great question and to Microsoft for the great answer.

    1 person found this answer helpful.
    0 comments No comments

  2. SnehaAgrawal-MSFT 22,706 Reputation points Moderator
    2023-03-16T16:38:11.6133333+00:00

    37298796 Sure, Thanks for reply! Email send is an asynchronous operation, which means our service accepts it immediately but will asynchronously try to send it in the backend.

    You can poll for the status of email send request. If you look at the above call, it does automatic polling in the backend (since first parameter is WaitUntil.Completed).

    You can also use WaitUntil.Started which will return immediately. In this case, they can poll for the status using EmailSendOperation.UpdateStatus() at a faster interval if you want.

    There is a sample for this in our github samples - communication-services-dotnet-quickstarts/SendEmailAdvanced/SendEmailWithManualPollingForStatus at main · Azure-Samples/communication-services-dotnet-quickstarts · GitHub

    Let us know if further query or issue remains.


  3. Michael Schaeufler 0 Reputation points
    2024-02-13T07:22:19.3166667+00:00

    Hello @SnehaAgrawal-MSFT

    I'm running into the same problem with Azure Communication Service for email and python. That has the two effects:

    1. Bad experiance for my app users to wait for 15-20 sec. for all functions that trigger an email in the backend (e.g. PW Reset)
    2. some functions in the backend run into a timeout while waiting for Azure Communication Service status.

    I use the sample code for python:

    message = {
        "content": {
            "subject": "This is the subject",
            "plainText": "This is the body",
            "html": "<html><h1>This is the body</h1></html>"
        },
        "recipients": {
            "to": / "cc": / "bcc": [...]
        },
        "senderAddress": "******@contoso.com"
    }
    poller = email_client.begin_send(message)
    #result = poller.result() -->Commented out programme command
    

    I'm wondering if this is a good idea to commented the result poller. At least it solved my problem of the delay in the program.

    Is email_client.begin_send function having a configuration like the sms service with wait_until_started=True as discripted here: Why sending a mail using Azure email communication service is too slow?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.