User Manual — Back to User Manual
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
A link names what it wants in the path, and supplies arguments for it in the query:
vscode://ms-azuretools.vscode-documentdb/<action>?<parameters>
| Action | What it does | Parameters |
|---|---|---|
connect |
Opens a connection to a cluster, optionally navigating into it | connectionString, database, collection |
local |
Opens the DocumentDB Local setup wizard | none |
local/documentdb |
Opens the DocumentDB Local setup wizard | none |
Only the actions in this table are recognized. A link naming anything else is refused with an explanatory message — the extension never treats the path as a command name, so a link cannot reach extension functionality that is not listed here.
Links written before actions existed keep working. A URL with no action, such as
vscode://ms-azuretools.vscode-documentdb?connectionString=..., meansconnect. You do not need to update existing links.
local accepts an optional local resource type. Currently, documentdb is the only supported
type, and omitting it defaults to documentdb, so /local and /local/documentdb are equivalent.
Unsupported resource types and additional path segments are refused rather than silently opening a
different setup experience.
These apply to the connect action.
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 | Collection to open (requires a database parameter or path) | 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: The extension opens the Collection View for this collection. A database must be supplied either through the database parameter or in the connection-string path; otherwise the link is rejected before a connection is added or opened.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.
Use this to take someone from a web page to a running local DocumentDB without asking them to find anything in the UI. It carries no parameters, because there is no connection yet — that is what the wizard is for.
vscode://ms-azuretools.vscode-documentdb/local
The explicit resource-type form is equivalent:
vscode://ms-azuretools.vscode-documentdb/local/documentdb
When URL handling confirmations are enabled in the extension settings, either form shows one confirmation before opening the setup wizard.
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.
Action routing: The extension reads the action from the path. An unrecognized action is refused rather than guessed at, so a mistyped link never acts on parameters you did not intend for it.
connect):
connectionString parameter and creates a new connection in the Connections View.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.