Bewerken

Delen via


New-AzCosmosDBMongoDBUserDefinition

Creates a new CosmosDB MongoDB User Definition.

Syntax

New-AzCosmosDBMongoDBUserDefinition
   -Id <String>
   -UserName <String>
   -Password <String>
   [-Mechanisms <String>]
   -DatabaseName <String>
   -Roles <System.Collections.Generic.List`1[Microsoft.Azure.PowerShell.Cmdlets.CosmosDB.Models.MongoDB.PSMongoRole]>
   [-CustomData <String>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzCosmosDBMongoDBUserDefinition
   -ResourceGroupName <String>
   -AccountName <String>
   -Id <String>
   -UserName <String>
   -Password <String>
   [-Mechanisms <String>]
   -DatabaseName <String>
   -Roles <System.Collections.Generic.List`1[Microsoft.Azure.PowerShell.Cmdlets.CosmosDB.Models.MongoDB.PSMongoRole]>
   [-CustomData <String>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzCosmosDBMongoDBUserDefinition
   -Id <String>
   -UserName <String>
   -Password <String>
   [-Mechanisms <String>]
   -DatabaseName <String>
   -Roles <System.Collections.Generic.List`1[Microsoft.Azure.PowerShell.Cmdlets.CosmosDB.Models.MongoDB.PSMongoRole]>
   [-CustomData <String>]
   -DatabaseAccountObject <PSDatabaseAccountGetResults>
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzCosmosDBMongoDBUserDefinition
   -Id <String>
   -UserName <String>
   -Password <String>
   [-Mechanisms <String>]
   -DatabaseName <String>
   -Roles <System.Collections.Generic.List`1[Microsoft.Azure.PowerShell.Cmdlets.CosmosDB.Models.MongoDB.PSMongoRole]>
   [-CustomData <String>]
   -DatabaseAccountObject <PSDatabaseAccountGetResults>
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzCosmosDBMongoDBUserDefinition
   -Id <String>
   -UserName <String>
   -Password <String>
   [-Mechanisms <String>]
   -DatabaseName <String>
   -Roles <System.Collections.Generic.List`1[Microsoft.Azure.PowerShell.Cmdlets.CosmosDB.Models.MongoDB.PSMongoRole]>
   [-CustomData <String>]
   [-ResourceId <String>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

Creates a new CosmosDB MongoDB User Definition. In order to specify the Role Definition's Roles, use the New-AzCosmosDBMongoDBRole cmdlet to create PSMongoRole objects to pass in through the Roles parameter.

Examples

Example 1: Default

$Roles = New-AzCosmosDBMongoDBRole -Database test -Role roleName


New-AzCosmosDBMongoDBUserDefinition `
	-AccountName accountName `
	-ResourceGroupName resourceGroupName `
	-DatabaseName 'test' `
	-UserName 'myName' `
	-Password 'pass' `
	-Id id `
	-Mechanisms 'SCRAM-SHA-256' `
	-CustomData 'test' `
	-Roles $Roles

Id           : /subscriptions/80be3961-0521-4a0a-8570-5cd5a4e2f98c/resourceGroups/mongorbactest02/providers/Microsoft.DocumentDB/databaseAccounts/ashwini001/mongodbUserDefinitions/test.testuser1
UserName     : testuser1
Password     :
Mechanisms   : SCRAM-SHA-256
DatabaseName : test
CustomData   :
Roles        : {Microsoft.Azure.Management.CosmosDB.Models.Role}

Example 2: ParentObject

$DatabaseAccount = Get-AzCosmosDBAccount -Name accountName -ResourceGroupName resourceGroupName
$Actions = 'insert', 'find'
$PrivilegeResource = New-AzCosmosDBMongoDBPrivilegeResource -Database test -Collection test
$Privilege = New-AzCosmosDBMongoDBPrivilege -PrivilegeResource $PrivilegeResource -Actions $Actions
$Roles = New-AzCosmosDBMongoDBRole -Database test -Role roleName
New-AzCosmosDBMongoDBRoleDefinition `
	-Id id `
	-Type CustomRole `
	-RoleName roleName `
	-Privileges $Privilege `
	-Roles $Roles `
	-DatabaseAccountObject $DatabaseAccount

Id           : /subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.DocumentDB/databaseAccounts/accountName/mongodbRoleDefinitions/id
RoleName     : roleName
Type         : CustomRole
DatabaseName : test
Privileges   : {Microsoft.Azure.Management.CosmosDB.Models.Privilege}
Roles        : {Microsoft.Azure.Management.CosmosDB.Models.Role, Microsoft.Azure.Management.CosmosDB.Models.Role}

Parameters

-AccountName

Name of the Cosmos DB database account.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-CustomData

Additional information about the user Definition.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DatabaseAccountObject

Role definition object.

Type:PSDatabaseAccountGetResults
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-DatabaseName

Database Name for the MongoDB Role Definition.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with Azure.

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Id

Role Definition Unique Id(Format is <databaseName>.<roleName>).

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-Mechanisms

Password for the user Definition.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Password

Password for the user Definition.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ResourceGroupName

Name of resource group.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ResourceId

ResourceId of the resource.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Roles

Set of inherited roles for CosmosDB MongoDB API Role Definition.

Type:List<T>[PSMongoRole]
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-UserName

Unique username(per database) for the user Definition.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-WhatIf

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

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Outputs

Microsoft.Azure.Commands.CosmosDB.Models.PSMongoDBRoleDefinitionGetResults