Edit

New-AzDocumentDBUser

Create a Microsoft Entra ID user on a mongo cluster.

Syntax

Default (Default)

New-AzDocumentDBUser
    -Name <String>
    -MongoClusterName <String>
    -ResourceGroupName <String>
    [-SubscriptionId <String>]
    -Type <String>
    [-Role <Hashtable[]>]
    [-DefaultProfile <PSObject>]
    [-AsJob]
    [-NoWait]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

Create (grant) a Microsoft Entra ID principal access to a mongo cluster by assigning it database roles. The '-Type' parameter surfaces the Entra principal type; the service models the identity provider as a discriminated union (identityProvider -> microsoftEntraID -> principalType) that the generated cmdlet does not flatten, so this wrapper exposes a simple '-Type' flag and builds the nested request body.

Examples

Example 1: Assign a Microsoft Entra ID user to a mongo cluster

New-AzDocumentDBUser -Name 00000000-0000-0000-0000-000000000000 -MongoClusterName myCluster -ResourceGroupName myResourceGroup `
    -Type User -Role @(@{ Db = 'admin'; Role = 'root' })
Name                                  ProvisioningState
----                                  -----------------
00000000-0000-0000-0000-000000000000  Succeeded

Grant a Microsoft Entra ID principal data-plane access to a mongo cluster. -Name is the object id of the Entra principal, -Type is the principal type (User or ServicePrincipal), and -Role assigns one or more database roles. Microsoft Entra authentication must be enabled on the cluster (see -AuthConfigAllowedMode on New-AzDocumentDBMongoCluster).

Parameters

-AsJob

Run the command as a job.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DefaultProfile

The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.

Parameter properties

Type:PSObject
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzureRMContext, AzureCredential

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-MongoClusterName

The name of the mongo cluster.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Name

The Microsoft Entra object (client) ID of the user or service principal.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:UserName

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-NoWait

Run the command asynchronously.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ResourceGroupName

The name of the resource group. The name is case insensitive.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Role

The database roles to assign, each as a hashtable with 'Db' and 'Role' keys. Example: -Role @(@{ Db = 'admin'; Role = 'root' })

Parameter properties

Type:

Hashtable[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-SubscriptionId

The ID of the target subscription.

Parameter properties

Type:String
Default value:(Get-AzContext).Subscription.Id
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Type

The Microsoft Entra principal type of the user.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Outputs

IUser