Manual — Back to Documentation Index
DocumentDB for VS Code supports activation through custom URLs, enabling you to integrate the extension seamlessly with your development environment and build deep links directly to your DocumentDB and MongoDB clusters. This powerful feature allows you to create shortcuts that can open specific connections, navigate to particular databases, or even jump directly to a collection view within the extension.
This URL-based activation is particularly useful for:
The prefix for URLs handled by this extension is:
vscode://ms-azuretools.vscode-documentdb
The following table lists all supported URL parameters:
Parameter | Required | Description | Example Value |
---|---|---|---|
connectionString |
Yes | The MongoDB/DocumentDB connection string (double URL-encoded) | mongodb%253A%252F%252F... |
database |
No | Name of the database to open after connection | myDatabase |
collection |
No | Name of the collection to open (requires database parameter) |
myCollection |
connectionString
: The core parameter that defines the database connection. Must be a valid DocumentDB or MongoDB connection string that has been double URL-encoded (see encoding section below). Note: While it’s possible to include a database name in the connection string, it’s recommended to use the separate database
parameter instead to keep the API simple and consistent.database
: When provided, the extension will automatically navigate to the specified database after establishing the connection.collection
: When provided along with database
, the extension will open the Collection View for the specified collection within that database.The connectionString
parameter must be encoded twice to ensure proper parsing. This is because the connection string itself contains special characters that need to be preserved through the URL parsing process.
The encoding happens in two steps:
For example, the string "mongo+srv://"
would be transformed as follows:
mongo+srv://
mongo%2Bsrv%3A%2F%2F
mongo%252Bsrv%253A%252F%252F
This double encoding ensures that the URL is correctly parsed by both the operating system and the extension.
Here are practical examples of URLs with their decoded connection strings for clarity:
vscode://ms-azuretools.vscode-documentdb?connectionString=mongodb%253A%252F%252Fusername%253Apassword%2540localhost%253A27017
Parameter | Decoded Value |
---|---|
connectionString |
mongodb://username:password@localhost:27017 |
vscode://ms-azuretools.vscode-documentdb?connectionString=mongodb%253A%252F%252Fmyuser%253Amypass%2540localhost%253A27017&database=analytics
Parameter | Decoded Value |
---|---|
connectionString |
mongodb://myuser:mypass@localhost:27017 |
database |
analytics |
This URL will connect to the database and automatically navigate to the analytics
database.
vscode://ms-azuretools.vscode-documentdb?connectionString=mongodb%253A%252F%252Fadmin%253Asecret%2540localhost%253A27017%252Fecommerce&database=ecommerce&collection=orders
Parameter | Decoded Value |
---|---|
connectionString |
mongodb://admin:secret@localhost:27017/ecommerce |
database |
ecommerce |
collection |
orders |
This URL will connect to the database, navigate to the ecommerce
database, and open the Collection View for the orders
collection.
When you click a DocumentDB for VS Code URL, the following process occurs:
Activation: The vscode://
prefix tells the operating system to activate VS Code. The ms-azuretools.vscode-documentdb
segment activates the DocumentDB for VS Code extension.
Connection Handling:
connectionString
parameter and creates a new connection in the Connections View.Navigation (if additional parameters are provided):
database
parameter is provided, the extension navigates to that database.database
and collection
parameters are provided, the extension opens the Collection View for the specified collection.connectionString
is valid and properly double-encoded to avoid connection errors.