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
2 changes: 1 addition & 1 deletion src/documentdb/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Release History
* 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
* Add ``az documentdb mongocluster entra-user`` commands to manage Microsoft Entra ID
database users.
* Add ``az documentdb mongocluster identity`` commands to manage the cluster's
user-assigned managed identity.
Expand Down
9 changes: 5 additions & 4 deletions src/documentdb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ managed identity, cross-region read replicas, and point-in-time restore.
|--|--|
| `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 entra-user` | Manage Microsoft Entra ID 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 |

Expand Down Expand Up @@ -60,11 +60,12 @@ az documentdb mongocluster firewall-rule create -n AllowMyIp --cluster-name MyCl
az documentdb mongocluster firewall-rule list --cluster-name MyCluster -g MyResourceGroup
```

### Microsoft Entra-backed users
### Microsoft Entra ID users

```bash
az documentdb mongocluster user create -n alice --cluster-name MyCluster -g MyResourceGroup \
--type User --role db=admin role=root
# The user is identified by its Microsoft Entra object (client) ID, not a friendly name.
az documentdb mongocluster entra-user create --object-id 11111111-1111-1111-1111-111111111111 \
--cluster-name MyCluster -g MyResourceGroup --type User --role db=admin role=root
```

### Managed identity (user-assigned)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def _build_arguments_schema(cls, *args, **kwargs):

_args_schema = cls._args_schema
_args_schema.admin_password = AAZPasswordArg(
options=["-p", "--admin-password"],
options=["-p", "--password", "--admin-password"],
arg_group="Administrator",
help="The administrator password.",
required=True,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _build_arguments_schema(cls, *args, **kwargs):

_args_schema = cls._args_schema
_args_schema.admin_password = AAZPasswordArg(
options=["-p", "--admin-password"],
options=["-p", "--password", "--admin-password"],
arg_group="Administrator",
help="The administrator password.",
nullable=True,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@


@register_command_group(
"documentdb mongocluster user",
"documentdb mongocluster entra-user",
)
class __CMDGroup(AAZCommandGroup):
"""Manage User
"""Manage Microsoft Entra ID users on a mongo cluster.
"""
pass

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@


@register_command(
"documentdb mongocluster user create",
"documentdb mongocluster entra-user create",
)
class Create(AAZCommand):
"""Create a new user or updates an existing user on a mongo cluster.
"""Create or update a Microsoft Entra ID user on a mongo cluster.

:example: Create an Entra-backed user.
az documentdb mongocluster user create -n alice-entra --cluster-name MyCluster -g MyResourceGroup --type User --role db=admin role=root
:example: Create an Entra ID user (service principal or user) by object ID.
az documentdb mongocluster entra-user create --object-id 11111111-1111-1111-1111-111111111111 --cluster-name MyCluster -g MyResourceGroup --type User --role db=admin role=root
"""

_aaz_info = {
Expand Down Expand Up @@ -58,9 +58,9 @@ def _build_arguments_schema(cls, *args, **kwargs):
_args_schema.resource_group = AAZResourceGroupNameArg(
required=True,
)
_args_schema.user_name = AAZStrArg(
options=["-n", "--name", "--user-name"],
help="The name of the mongo cluster user.",
_args_schema.object_id = AAZStrArg(
options=["-n", "--name", "--object-id"],
help="Object ID (client ID) of the Microsoft Entra principal. Provide the GUID of the service principal or user, not a friendly name or UPN.",
required=True,
fmt=AAZStrArgFormat(
pattern="^[a-zA-Z0-9\\-]*",
Expand Down Expand Up @@ -189,7 +189,7 @@ def url_parameters(self):
required=True,
),
**self.serialize_url_param(
"userName", self.ctx.args.user_name,
"userName", self.ctx.args.object_id,
required=True,
),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@


@register_command(
"documentdb mongocluster user delete",
"documentdb mongocluster entra-user delete",
confirmation="Are you sure you want to perform this operation?",
)
class Delete(AAZCommand):
"""Delete a mongo cluster user.
"""Delete a Microsoft Entra ID user from a mongo cluster.

:example: Delete a user.
az documentdb mongocluster user delete -n alice@contoso.com --cluster-name MyCluster -g MyResourceGroup
:example: Delete an Entra ID user by object ID.
az documentdb mongocluster entra-user delete --object-id 11111111-1111-1111-1111-111111111111 --cluster-name MyCluster -g MyResourceGroup

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naming convention here might be add/remove or assign/remove rather than create/delete since the entra user already exists it's just about granting the user admin access to the data plane.

"""

_aaz_info = {
Expand Down Expand Up @@ -60,9 +60,9 @@ def _build_arguments_schema(cls, *args, **kwargs):
_args_schema.resource_group = AAZResourceGroupNameArg(
required=True,
)
_args_schema.user_name = AAZStrArg(
options=["-n", "--name", "--user-name"],
help="The name of the mongo cluster user.",
_args_schema.object_id = AAZStrArg(
options=["-n", "--name", "--object-id"],
help="Object ID (client ID) of the Microsoft Entra principal. Provide the GUID of the service principal or user, not a friendly name or UPN.",
required=True,
id_part="child_name_1",
fmt=AAZStrArgFormat(
Expand Down Expand Up @@ -153,7 +153,7 @@ def url_parameters(self):
required=True,
),
**self.serialize_url_param(
"userName", self.ctx.args.user_name,
"userName", self.ctx.args.object_id,
required=True,
),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@


@register_command(
"documentdb mongocluster user list",
"documentdb mongocluster entra-user list",
)
class List(AAZCommand):
"""List all the users on a mongo cluster.
"""List the Microsoft Entra ID users on a mongo cluster.
:example: List users on a cluster.
az documentdb mongocluster user list --cluster-name MyCluster -g MyResourceGroup
:example: List Entra ID users on a cluster.
az documentdb mongocluster entra-user list --cluster-name MyCluster -g MyResourceGroup
"""

_aaz_info = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@


@register_command(
"documentdb mongocluster user show",
"documentdb mongocluster entra-user show",
)
class Show(AAZCommand):
"""Get the defintion of a Mongo cluster user.
"""Get the definition of a Microsoft Entra ID user on a mongo cluster.

:example: Get a user.
az documentdb mongocluster user show -n alice@contoso.com --cluster-name MyCluster -g MyResourceGroup
:example: Get an Entra ID user by object ID.
az documentdb mongocluster entra-user show --object-id 11111111-1111-1111-1111-111111111111 --cluster-name MyCluster -g MyResourceGroup
"""

_aaz_info = {
Expand Down Expand Up @@ -58,9 +58,9 @@ def _build_arguments_schema(cls, *args, **kwargs):
_args_schema.resource_group = AAZResourceGroupNameArg(
required=True,
)
_args_schema.user_name = AAZStrArg(
options=["-n", "--name", "--user-name"],
help="The name of the mongo cluster user.",
_args_schema.object_id = AAZStrArg(
options=["-n", "--name", "--object-id"],
help="Object ID (client ID) of the Microsoft Entra principal. Provide the GUID of the service principal or user, not a friendly name or UPN.",
required=True,
id_part="child_name_1",
fmt=AAZStrArgFormat(
Expand Down Expand Up @@ -130,7 +130,7 @@ def url_parameters(self):
required=True,
),
**self.serialize_url_param(
"userName", self.ctx.args.user_name,
"userName", self.ctx.args.object_id,
required=True,
),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@


@register_command(
"documentdb mongocluster user update",
"documentdb mongocluster entra-user update",
)
class Update(AAZCommand):
"""Update a new user or updates an existing user on a mongo cluster.
"""Update a Microsoft Entra ID user on a mongo cluster.

:example: Update a user's roles.
az documentdb mongocluster user update -n alice-entra --cluster-name MyCluster -g MyResourceGroup --role db=admin role=root
:example: Update an Entra ID user's roles.
az documentdb mongocluster entra-user update --object-id 11111111-1111-1111-1111-111111111111 --cluster-name MyCluster -g MyResourceGroup --role db=admin role=root
"""

_aaz_info = {
Expand Down Expand Up @@ -61,9 +61,9 @@ def _build_arguments_schema(cls, *args, **kwargs):
_args_schema.resource_group = AAZResourceGroupNameArg(
required=True,
)
_args_schema.user_name = AAZStrArg(
options=["-n", "--name", "--user-name"],
help="The name of the mongo cluster user.",
_args_schema.object_id = AAZStrArg(
options=["-n", "--name", "--object-id"],
help="Object ID (client ID) of the Microsoft Entra principal. Provide the GUID of the service principal or user, not a friendly name or UPN.",
required=True,
id_part="child_name_1",
fmt=AAZStrArgFormat(
Expand Down Expand Up @@ -191,7 +191,7 @@ def url_parameters(self):
required=True,
),
**self.serialize_url_param(
"userName", self.ctx.args.user_name,
"userName", self.ctx.args.object_id,
required=True,
),
}
Expand Down Expand Up @@ -294,7 +294,7 @@ def url_parameters(self):
required=True,
),
**self.serialize_url_param(
"userName", self.ctx.args.user_name,
"userName", self.ctx.args.object_id,
required=True,
),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


@register_command(
"documentdb mongocluster user wait",
"documentdb mongocluster entra-user wait",
)
class Wait(AAZWaitCommand):
"""Place the CLI in a waiting state until a condition is met.
Expand Down Expand Up @@ -54,9 +54,9 @@ def _build_arguments_schema(cls, *args, **kwargs):
_args_schema.resource_group = AAZResourceGroupNameArg(
required=True,
)
_args_schema.user_name = AAZStrArg(
options=["-n", "--name", "--user-name"],
help="The name of the mongo cluster user.",
_args_schema.object_id = AAZStrArg(
options=["-n", "--name", "--object-id"],
help="Object ID (client ID) of the Microsoft Entra principal. Provide the GUID of the service principal or user, not a friendly name or UPN.",
required=True,
id_part="child_name_1",
fmt=AAZStrArgFormat(
Expand Down Expand Up @@ -126,7 +126,7 @@ def url_parameters(self):
required=True,
),
**self.serialize_url_param(
"userName", self.ctx.args.user_name,
"userName", self.ctx.args.object_id,
required=True,
),
}
Expand Down
7 changes: 4 additions & 3 deletions src/documentdb/azext_documentdb/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@

def load_command_table(self, _): # pylint: disable=unused-argument
from azext_documentdb.custom import (
UserCreate, UserUpdate, ResetPassword, ReplicaCreate, Restore)
self.command_table['documentdb mongocluster user create'] = UserCreate(loader=self)
self.command_table['documentdb mongocluster user update'] = UserUpdate(loader=self)
UserCreate, UserUpdate, ResetPassword, ReplicaCreate, Restore, ReplicaPromote)
self.command_table['documentdb mongocluster entra-user create'] = UserCreate(loader=self)
self.command_table['documentdb mongocluster entra-user update'] = UserUpdate(loader=self)
self.command_table['documentdb mongocluster reset-password'] = ResetPassword(loader=self)
self.command_table['documentdb mongocluster replica create'] = ReplicaCreate(loader=self)
self.command_table['documentdb mongocluster replica promote'] = ReplicaPromote(loader=self)
self.command_table['documentdb mongocluster restore'] = Restore(loader=self)
Loading
Loading