SRV endpoints eliminate the need to update connection strings when nodes are added or removed. Clients connect to instances seamlessly, simplifying the design and maintenance of your application.
Prerequisites
Before you begin, make sure you have:
A replica set instance or sharded cluster instance with standard SSD storage
(For public SRV endpoints) A public endpoint already configured for the instance
Before you start
SRV endpoints are not shown in the console by default. You must apply for one before use.
Applying for or modifying an SRV endpoint takes 1–2 minutes to complete.
After modifying an SRV endpoint, update the connection string in your application promptly to avoid connection failures.
Apply for an SRV endpoint
Go to the MongoDB replica set instance list or MongoDB sharded cluster instance list. Select the resource group and region, then click the target instance ID.
In the left navigation pane, click Database Connections.
Apply for the SRV endpoint based on your connection type: Private endpoint Click Privatelink - Virtual Private Cloud on the right, then click Apply For A Private SRV Endpoint. Public endpoint Click Public Connection on the right, then click Apply For A Public SRV Endpoint.
ImportantYou must apply for the instance's public endpoint before applying for a public SRV endpoint.
In the Apply For An SRV Endpoint dialog box, click OK.
Modify an SRV endpoint
Use this procedure to change the connection address prefix of an existing SRV endpoint.
Go to the MongoDB replica set instance list or MongoDB sharded cluster instance list. Select the resource group and region, then click the target instance ID.
In the left navigation pane, click Database Connections.
Open the modify panel based on your connection type: Private endpoint Click Privatelink - Virtual Private Cloud on the right, then click Modify Private SRV Endpoint. Public endpoint Click Public Connection on the right, then click Modify Public SRV Endpoint.
Enter the new connection address prefix. The prefix must meet the following requirements:
Requirement Details Allowed characters Lowercase letters, digits, and hyphens (-) Start and end characters Must be a lowercase letter or a digit Prefix length At least 8 characters Total length (including prefix) No more than 63 characters Uniqueness Must be globally unique Click OK.