Welcome to the Microsoft Q&A Platform. Thank you for reaching out & I hope you are doing well.
Please follow the below steps to connect MongoDB cluster using Azure using private endpoint using azure portal.
To create a private endpoint to a node in an existing cluster, open the Networking page for the cluster.
- Select Add private endpoint.
-
- On the Basics tab of the Create a private endpoint screen, confirm the Subscription, Resource group, and Region. Enter a Name for the endpoint, such as my-cluster-1, and a Network interface name, such as my-cluster-1-nic.
- Select Next: Resource. Choose "Microsoft.DocumentDB/mongoClusters" for Resource type, and choose the target cluster for Resource. For Target sub-resource, choose "MongoCluster".
- Select Next: Virtual Network. Choose the desired Virtual network and Subnet. Under Private IP configuration, select Statically allocate IP address or keep the default, Dynamically allocate IP address.
- Select Next: DNS.
- Under Private DNS integration, for Integrate with private DNS zone, keep the default Yes or select No.
- Select Next: Tags, and add any desired tags.
- Select Review + create. Review the settings, and select Create when satisfied.
- Refer: https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/vcore/how-to-private-link#enable-private-access-on-an-existing-cluster
Additionally, you can enable using azure CLI commands.
Refer below doc for MongoDB connectivity.
https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/connect-account
Kindly let us know if the above helps or you need further assistance on this issue.