Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/documentdb/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.. :changelog:

Release History
===============

1.0.0b1
+++++++
* Initial release of the DocumentDB (Azure Cosmos DB for MongoDB vCore) extension.
* Add ``az documentdb mongocluster`` commands to create, update, show, list, and delete
mongo clusters, list connection strings, and check name availability.
* Add ``az documentdb mongocluster firewall-rule`` commands to manage IP firewall rules.
* Add ``az documentdb mongocluster user`` commands to manage Microsoft Entra-backed
database users.
* Add ``az documentdb mongocluster identity`` commands to manage the cluster's
user-assigned managed identity.
* Add ``az documentdb mongocluster replica`` commands to list and promote read replicas,
and ``replica create`` to create a cross-region GeoReplica.
* Add ``az documentdb mongocluster restore`` for point-in-time restore into a new cluster.
* Add ``az documentdb mongocluster reset-password`` to reset the administrator password.
98 changes: 98 additions & 0 deletions src/documentdb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Azure CLI DocumentDB Extension #

This is an extension to Azure CLI to manage **Azure Cosmos DB for MongoDB (vCore)**
clusters — the `Microsoft.DocumentDB/mongoClusters` resource — under the
`az documentdb mongocluster` command group.

## How to install ##

```bash
az extension add --name documentdb
```

## Background ##

DocumentDB (Mongo vCore) is a fully managed, MongoDB-compatible database service.
This extension exposes the management-plane operations for mongo clusters and their
sub-resources: IP firewall rules, Microsoft Entra-backed database users, user-assigned
managed identity, cross-region read replicas, and point-in-time restore.

## Command groups ##

| Group | Description |
|--|--|
| `az documentdb mongocluster` | Create and manage mongo clusters |
| `az documentdb mongocluster firewall-rule` | Manage IP firewall rules (public access) |
| `az documentdb mongocluster user` | Manage Microsoft Entra-backed database users |
| `az documentdb mongocluster identity` | Manage the cluster's user-assigned managed identity |
| `az documentdb mongocluster replica` | List, create, and promote cross-region read replicas |

## Usage examples ##

### Create and manage a cluster

```bash
# Create a cluster
az documentdb mongocluster create -n MyCluster -g MyResourceGroup --location eastus2 \
--admin-user dbadmin --admin-password MyP@ssw0rd123! \
--tier M30 --storage-size 128 --storage-type PremiumSSDv2 \
--shard-count 1 --high-availability Disabled

# Show and list
az documentdb mongocluster show -n MyCluster -g MyResourceGroup
az documentdb mongocluster list -g MyResourceGroup

# Get connection strings
az documentdb mongocluster list-connection-strings -n MyCluster -g MyResourceGroup

# Reset the administrator password
az documentdb mongocluster reset-password -n MyCluster -g MyResourceGroup --password NewP@ssw0rd123!

# Delete
az documentdb mongocluster delete -n MyCluster -g MyResourceGroup
```

### Firewall rules

```bash
az documentdb mongocluster firewall-rule create -n AllowMyIp --cluster-name MyCluster \
-g MyResourceGroup --start-ip-address 203.0.113.0 --end-ip-address 203.0.113.255
az documentdb mongocluster firewall-rule list --cluster-name MyCluster -g MyResourceGroup
```

### Microsoft Entra-backed users

```bash
az documentdb mongocluster user create -n alice --cluster-name MyCluster -g MyResourceGroup \
--type User --role db=admin role=root
```

### Managed identity (user-assigned)

```bash
az documentdb mongocluster identity assign -n MyCluster -g MyResourceGroup \
--mi-user-assigned <userAssignedIdentityResourceId>
az documentdb mongocluster identity show -n MyCluster -g MyResourceGroup
```

### Replicas (cross-region)

```bash
# List the parent cluster's replicas
az documentdb mongocluster replica list --cluster-name MyCluster -g MyResourceGroup

# Create a cross-region GeoReplica (the source must have the GeoReplicas preview feature enabled)
az documentdb mongocluster replica create -n MyReplica -g MyResourceGroup -l centralus \
--source-cluster MyCluster --source-location eastus2

# Promote a replica to primary
az documentdb mongocluster replica promote -n MyReplica -g MyResourceGroup
```

### Point-in-time restore

```bash
az documentdb mongocluster restore -n RestoredCluster -g MyResourceGroup --location eastus2 \
--source-cluster MyCluster --restore-time "2026-06-30T10:00:00Z" \
--admin-user dbadmin --admin-password MyP@ssw0rd123!
```
42 changes: 42 additions & 0 deletions src/documentdb/azext_documentdb/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

from azure.cli.core import AzCommandsLoader
from azext_documentdb._help import helps # pylint: disable=unused-import


class DocumentdbCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
custom_command_type = CliCommandType(
operations_tmpl='azext_documentdb.custom#{}')
super().__init__(cli_ctx=cli_ctx,
custom_command_type=custom_command_type)

def load_command_table(self, args):
from azext_documentdb.commands import load_command_table
from azure.cli.core.aaz import load_aaz_command_table
try:
from . import aaz
except ImportError:
aaz = None
if aaz:
load_aaz_command_table(
loader=self,
aaz_pkg_name=aaz.__name__,
args=args
)
load_command_table(self, args)
return self.command_table

def load_arguments(self, command):
from azext_documentdb._params import load_arguments
load_arguments(self, command)


COMMAND_LOADER_CLS = DocumentdbCommandsLoader
11 changes: 11 additions & 0 deletions src/documentdb/azext_documentdb/_help.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: disable=line-too-long
# pylint: disable=too-many-lines

from knack.help_files import helps # pylint: disable=unused-import
13 changes: 13 additions & 0 deletions src/documentdb/azext_documentdb/_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: disable=too-many-lines
# pylint: disable=too-many-statements


def load_arguments(self, _): # pylint: disable=unused-argument
pass
6 changes: 6 additions & 0 deletions src/documentdb/azext_documentdb/aaz/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------
10 changes: 10 additions & 0 deletions src/documentdb/azext_documentdb/aaz/latest/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from azure.cli.core.aaz import *


@register_command_group(
"documentdb",
)
class __CMDGroup(AAZCommandGroup):
"""Manage Document Db
"""
pass


__all__ = ["__CMDGroup"]
11 changes: 11 additions & 0 deletions src/documentdb/azext_documentdb/aaz/latest/documentdb/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from .__cmd_group import *
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from azure.cli.core.aaz import *


@register_command_group(
"documentdb mongocluster",
)
class __CMDGroup(AAZCommandGroup):
"""Manage Mongo Cluster
"""
pass


__all__ = ["__CMDGroup"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from .__cmd_group import *
from ._check_name_availability import *
from ._create import *
from ._delete import *
from ._list import *
from ._list_connection_strings import *
from ._show import *
from ._update import *
from ._wait import *
Loading
Loading