How to connect to Azure Cosmos DB for MongoDB vCore via a private endpoint from app service?

Phillip Hu 0 Reputation points
2024-05-17T03:22:11.1066667+00:00

Hi everyone,

I'm having trouble connecting to the mongodb from one of my web app. It used to work perfectly until a private endpoint was configured. I tried to replace the domain name in the connection string with the FQDN. I got this "pymongo.errors.ServerSelectionTimeoutError" error message.

Anyone can help please?

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,481 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,097 questions
{count} votes

1 answer

Sort by: Most helpful
  1. SnehaAgrawal-MSFT 19,196 Reputation points
    2024-05-21T12:47:20.0266667+00:00

    @Phillip Hu Thanks for reaching here! If you are Unable to Connect to Azure Cosmos DB for MongoDB vCore - Timeout error

    This issue might occur when the cluster does not have the correct firewall rule(s) enabled.

    If you're trying to access the cluster from a non-Azure IP range, you need to add extra firewall rules.

    Refer to Security options and features - Azure Cosmos DB for MongoDB vCore for detailed steps.

    Firewall rules can be configured in the portal's Networking setting for the cluster.

    Options include adding a known IP address/range or enabling public IP access.

    Screenshot of the Timeout error solution for Azure Cosmos DB for MongoDB vCore.

    Also, suggest you to verify that the network security group rules are configured correctly. You can check the NSG rules in the Azure portal under the "Networking" section of your MongoDB resource.

    Double check the connection string settings are correct. You can check the connection string in your web app's configuration settings to ensure that it is using the correct FQDN and port number.

    Also try connecting to the MongoDB server from a different machine to see if the issue is specific to your web app.

    Please let us know.

    0 comments No comments