1. Packages
  2. Azure Classic
  3. API Docs
  4. mongocluster
  5. User

We recommend using Azure Native.

Azure v6.31.0 published on Monday, Dec 29, 2025 by Pulumi
azure logo

We recommend using Azure Native.

Azure v6.31.0 published on Monday, Dec 29, 2025 by Pulumi

    Manages a Mongo Cluster User.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as azure from "@pulumi/azure";
    
    const current = azure.core.getClientConfig({});
    const example = new azure.core.ResourceGroup("example", {
        name: "example-resources",
        location: "West Europe",
    });
    const exampleMongoCluster = new azure.mongocluster.MongoCluster("example", {
        name: "example-mc",
        resourceGroupName: example.name,
        location: example.location,
        administratorUsername: "adminTerraform",
        administratorPassword: "QAZwsx123",
        shardCount: 1,
        computeTier: "M30",
        highAvailabilityMode: "Disabled",
        storageSizeInGb: 32,
        version: "8.0",
        authenticationMethods: [
            "NativeAuth",
            "MicrosoftEntraID",
        ],
    });
    const exampleUser = new azure.mongocluster.User("example", {
        objectId: current.then(current => current.objectId),
        mongoClusterId: exampleMongoCluster.id,
        identityProviderType: "MicrosoftEntraID",
        principalType: "servicePrincipal",
        roles: [{
            database: "admin",
            name: "root",
        }],
    });
    
    import pulumi
    import pulumi_azure as azure
    
    current = azure.core.get_client_config()
    example = azure.core.ResourceGroup("example",
        name="example-resources",
        location="West Europe")
    example_mongo_cluster = azure.mongocluster.MongoCluster("example",
        name="example-mc",
        resource_group_name=example.name,
        location=example.location,
        administrator_username="adminTerraform",
        administrator_password="QAZwsx123",
        shard_count=1,
        compute_tier="M30",
        high_availability_mode="Disabled",
        storage_size_in_gb=32,
        version="8.0",
        authentication_methods=[
            "NativeAuth",
            "MicrosoftEntraID",
        ])
    example_user = azure.mongocluster.User("example",
        object_id=current.object_id,
        mongo_cluster_id=example_mongo_cluster.id,
        identity_provider_type="MicrosoftEntraID",
        principal_type="servicePrincipal",
        roles=[{
            "database": "admin",
            "name": "root",
        }])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/core"
    	"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/mongocluster"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		current, err := core.GetClientConfig(ctx, map[string]interface{}{}, nil)
    		if err != nil {
    			return err
    		}
    		example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
    			Name:     pulumi.String("example-resources"),
    			Location: pulumi.String("West Europe"),
    		})
    		if err != nil {
    			return err
    		}
    		exampleMongoCluster, err := mongocluster.NewMongoCluster(ctx, "example", &mongocluster.MongoClusterArgs{
    			Name:                  pulumi.String("example-mc"),
    			ResourceGroupName:     example.Name,
    			Location:              example.Location,
    			AdministratorUsername: pulumi.String("adminTerraform"),
    			AdministratorPassword: pulumi.String("QAZwsx123"),
    			ShardCount:            pulumi.Int(1),
    			ComputeTier:           pulumi.String("M30"),
    			HighAvailabilityMode:  pulumi.String("Disabled"),
    			StorageSizeInGb:       pulumi.Int(32),
    			Version:               pulumi.String("8.0"),
    			AuthenticationMethods: pulumi.StringArray{
    				pulumi.String("NativeAuth"),
    				pulumi.String("MicrosoftEntraID"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = mongocluster.NewUser(ctx, "example", &mongocluster.UserArgs{
    			ObjectId:             pulumi.String(current.ObjectId),
    			MongoClusterId:       exampleMongoCluster.ID(),
    			IdentityProviderType: pulumi.String("MicrosoftEntraID"),
    			PrincipalType:        pulumi.String("servicePrincipal"),
    			Roles: mongocluster.UserRoleArray{
    				&mongocluster.UserRoleArgs{
    					Database: pulumi.String("admin"),
    					Name:     pulumi.String("root"),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Azure = Pulumi.Azure;
    
    return await Deployment.RunAsync(() => 
    {
        var current = Azure.Core.GetClientConfig.Invoke();
    
        var example = new Azure.Core.ResourceGroup("example", new()
        {
            Name = "example-resources",
            Location = "West Europe",
        });
    
        var exampleMongoCluster = new Azure.MongoCluster.MongoCluster("example", new()
        {
            Name = "example-mc",
            ResourceGroupName = example.Name,
            Location = example.Location,
            AdministratorUsername = "adminTerraform",
            AdministratorPassword = "QAZwsx123",
            ShardCount = 1,
            ComputeTier = "M30",
            HighAvailabilityMode = "Disabled",
            StorageSizeInGb = 32,
            Version = "8.0",
            AuthenticationMethods = new[]
            {
                "NativeAuth",
                "MicrosoftEntraID",
            },
        });
    
        var exampleUser = new Azure.MongoCluster.User("example", new()
        {
            ObjectId = current.Apply(getClientConfigResult => getClientConfigResult.ObjectId),
            MongoClusterId = exampleMongoCluster.Id,
            IdentityProviderType = "MicrosoftEntraID",
            PrincipalType = "servicePrincipal",
            Roles = new[]
            {
                new Azure.MongoCluster.Inputs.UserRoleArgs
                {
                    Database = "admin",
                    Name = "root",
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.azure.core.CoreFunctions;
    import com.pulumi.azure.core.ResourceGroup;
    import com.pulumi.azure.core.ResourceGroupArgs;
    import com.pulumi.azure.mongocluster.MongoCluster;
    import com.pulumi.azure.mongocluster.MongoClusterArgs;
    import com.pulumi.azure.mongocluster.User;
    import com.pulumi.azure.mongocluster.UserArgs;
    import com.pulumi.azure.mongocluster.inputs.UserRoleArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var current = CoreFunctions.getClientConfig(%!v(PANIC=Format method: runtime error: invalid memory address or nil pointer dereference);
    
            var example = new ResourceGroup("example", ResourceGroupArgs.builder()
                .name("example-resources")
                .location("West Europe")
                .build());
    
            var exampleMongoCluster = new MongoCluster("exampleMongoCluster", MongoClusterArgs.builder()
                .name("example-mc")
                .resourceGroupName(example.name())
                .location(example.location())
                .administratorUsername("adminTerraform")
                .administratorPassword("QAZwsx123")
                .shardCount(1)
                .computeTier("M30")
                .highAvailabilityMode("Disabled")
                .storageSizeInGb(32)
                .version("8.0")
                .authenticationMethods(            
                    "NativeAuth",
                    "MicrosoftEntraID")
                .build());
    
            var exampleUser = new User("exampleUser", UserArgs.builder()
                .objectId(current.objectId())
                .mongoClusterId(exampleMongoCluster.id())
                .identityProviderType("MicrosoftEntraID")
                .principalType("servicePrincipal")
                .roles(UserRoleArgs.builder()
                    .database("admin")
                    .name("root")
                    .build())
                .build());
    
        }
    }
    
    resources:
      example:
        type: azure:core:ResourceGroup
        properties:
          name: example-resources
          location: West Europe
      exampleMongoCluster:
        type: azure:mongocluster:MongoCluster
        name: example
        properties:
          name: example-mc
          resourceGroupName: ${example.name}
          location: ${example.location}
          administratorUsername: adminTerraform
          administratorPassword: QAZwsx123
          shardCount: '1'
          computeTier: M30
          highAvailabilityMode: Disabled
          storageSizeInGb: '32'
          version: '8.0'
          authenticationMethods:
            - NativeAuth
            - MicrosoftEntraID
      exampleUser:
        type: azure:mongocluster:User
        name: example
        properties:
          objectId: ${current.objectId}
          mongoClusterId: ${exampleMongoCluster.id}
          identityProviderType: MicrosoftEntraID
          principalType: servicePrincipal
          roles:
            - database: admin
              name: root
    variables:
      current:
        fn::invoke:
          function: azure:core:getClientConfig
          arguments: {}
    

    API Providers

    This resource uses the following Azure API Providers:

    • Microsoft.DocumentDB - 2025-09-01

    Create User Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new User(name: string, args: UserArgs, opts?: CustomResourceOptions);
    @overload
    def User(resource_name: str,
             args: UserArgs,
             opts: Optional[ResourceOptions] = None)
    
    @overload
    def User(resource_name: str,
             opts: Optional[ResourceOptions] = None,
             identity_provider_type: Optional[str] = None,
             mongo_cluster_id: Optional[str] = None,
             object_id: Optional[str] = None,
             principal_type: Optional[str] = None,
             roles: Optional[Sequence[UserRoleArgs]] = None)
    func NewUser(ctx *Context, name string, args UserArgs, opts ...ResourceOption) (*User, error)
    public User(string name, UserArgs args, CustomResourceOptions? opts = null)
    public User(String name, UserArgs args)
    public User(String name, UserArgs args, CustomResourceOptions options)
    
    type: azure:mongocluster:User
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args UserArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args UserArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args UserArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args UserArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args UserArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var azureUserResource = new Azure.MongoCluster.User("azureUserResource", new()
    {
        IdentityProviderType = "string",
        MongoClusterId = "string",
        ObjectId = "string",
        PrincipalType = "string",
        Roles = new[]
        {
            new Azure.MongoCluster.Inputs.UserRoleArgs
            {
                Database = "string",
                Name = "string",
            },
        },
    });
    
    example, err := mongocluster.NewUser(ctx, "azureUserResource", &mongocluster.UserArgs{
    	IdentityProviderType: pulumi.String("string"),
    	MongoClusterId:       pulumi.String("string"),
    	ObjectId:             pulumi.String("string"),
    	PrincipalType:        pulumi.String("string"),
    	Roles: mongocluster.UserRoleArray{
    		&mongocluster.UserRoleArgs{
    			Database: pulumi.String("string"),
    			Name:     pulumi.String("string"),
    		},
    	},
    })
    
    var azureUserResource = new com.pulumi.azure.mongocluster.User("azureUserResource", com.pulumi.azure.mongocluster.UserArgs.builder()
        .identityProviderType("string")
        .mongoClusterId("string")
        .objectId("string")
        .principalType("string")
        .roles(UserRoleArgs.builder()
            .database("string")
            .name("string")
            .build())
        .build());
    
    azure_user_resource = azure.mongocluster.User("azureUserResource",
        identity_provider_type="string",
        mongo_cluster_id="string",
        object_id="string",
        principal_type="string",
        roles=[{
            "database": "string",
            "name": "string",
        }])
    
    const azureUserResource = new azure.mongocluster.User("azureUserResource", {
        identityProviderType: "string",
        mongoClusterId: "string",
        objectId: "string",
        principalType: "string",
        roles: [{
            database: "string",
            name: "string",
        }],
    });
    
    type: azure:mongocluster:User
    properties:
        identityProviderType: string
        mongoClusterId: string
        objectId: string
        principalType: string
        roles:
            - database: string
              name: string
    

    User Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The User resource accepts the following input properties:

    IdentityProviderType string
    The identity provider type for the Mongo Cluster User. The only possible value is MicrosoftEntraID. Changing this forces a new resource to be created.
    MongoClusterId string
    The ID of the Mongo Cluster where the User should exist. Changing this forces a new resource to be created.
    ObjectId string
    The Object ID of the Entra ID User or Service Principal. Changing this forces a new resource to be created.
    PrincipalType string
    The principal type for the Mongo Cluster User. Possible values are user and servicePrincipal. Changing this forces a new resource to be created.
    Roles List<UserRole>
    One or more role blocks as defined below. Changing this forces a new resource to be created.
    IdentityProviderType string
    The identity provider type for the Mongo Cluster User. The only possible value is MicrosoftEntraID. Changing this forces a new resource to be created.
    MongoClusterId string
    The ID of the Mongo Cluster where the User should exist. Changing this forces a new resource to be created.
    ObjectId string
    The Object ID of the Entra ID User or Service Principal. Changing this forces a new resource to be created.
    PrincipalType string
    The principal type for the Mongo Cluster User. Possible values are user and servicePrincipal. Changing this forces a new resource to be created.
    Roles []UserRoleArgs
    One or more role blocks as defined below. Changing this forces a new resource to be created.
    identityProviderType String
    The identity provider type for the Mongo Cluster User. The only possible value is MicrosoftEntraID. Changing this forces a new resource to be created.
    mongoClusterId String
    The ID of the Mongo Cluster where the User should exist. Changing this forces a new resource to be created.
    objectId String
    The Object ID of the Entra ID User or Service Principal. Changing this forces a new resource to be created.
    principalType String
    The principal type for the Mongo Cluster User. Possible values are user and servicePrincipal. Changing this forces a new resource to be created.
    roles List<UserRole>
    One or more role blocks as defined below. Changing this forces a new resource to be created.
    identityProviderType string
    The identity provider type for the Mongo Cluster User. The only possible value is MicrosoftEntraID. Changing this forces a new resource to be created.
    mongoClusterId string
    The ID of the Mongo Cluster where the User should exist. Changing this forces a new resource to be created.
    objectId string
    The Object ID of the Entra ID User or Service Principal. Changing this forces a new resource to be created.
    principalType string
    The principal type for the Mongo Cluster User. Possible values are user and servicePrincipal. Changing this forces a new resource to be created.
    roles UserRole[]
    One or more role blocks as defined below. Changing this forces a new resource to be created.
    identity_provider_type str
    The identity provider type for the Mongo Cluster User. The only possible value is MicrosoftEntraID. Changing this forces a new resource to be created.
    mongo_cluster_id str
    The ID of the Mongo Cluster where the User should exist. Changing this forces a new resource to be created.
    object_id str
    The Object ID of the Entra ID User or Service Principal. Changing this forces a new resource to be created.
    principal_type str
    The principal type for the Mongo Cluster User. Possible values are user and servicePrincipal. Changing this forces a new resource to be created.
    roles Sequence[UserRoleArgs]
    One or more role blocks as defined below. Changing this forces a new resource to be created.
    identityProviderType String
    The identity provider type for the Mongo Cluster User. The only possible value is MicrosoftEntraID. Changing this forces a new resource to be created.
    mongoClusterId String
    The ID of the Mongo Cluster where the User should exist. Changing this forces a new resource to be created.
    objectId String
    The Object ID of the Entra ID User or Service Principal. Changing this forces a new resource to be created.
    principalType String
    The principal type for the Mongo Cluster User. Possible values are user and servicePrincipal. Changing this forces a new resource to be created.
    roles List<Property Map>
    One or more role blocks as defined below. Changing this forces a new resource to be created.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the User resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing User Resource

    Get an existing User resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: UserState, opts?: CustomResourceOptions): User
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            identity_provider_type: Optional[str] = None,
            mongo_cluster_id: Optional[str] = None,
            object_id: Optional[str] = None,
            principal_type: Optional[str] = None,
            roles: Optional[Sequence[UserRoleArgs]] = None) -> User
    func GetUser(ctx *Context, name string, id IDInput, state *UserState, opts ...ResourceOption) (*User, error)
    public static User Get(string name, Input<string> id, UserState? state, CustomResourceOptions? opts = null)
    public static User get(String name, Output<String> id, UserState state, CustomResourceOptions options)
    resources:  _:    type: azure:mongocluster:User    get:      id: ${id}
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    IdentityProviderType string
    The identity provider type for the Mongo Cluster User. The only possible value is MicrosoftEntraID. Changing this forces a new resource to be created.
    MongoClusterId string
    The ID of the Mongo Cluster where the User should exist. Changing this forces a new resource to be created.
    ObjectId string
    The Object ID of the Entra ID User or Service Principal. Changing this forces a new resource to be created.
    PrincipalType string
    The principal type for the Mongo Cluster User. Possible values are user and servicePrincipal. Changing this forces a new resource to be created.
    Roles List<UserRole>
    One or more role blocks as defined below. Changing this forces a new resource to be created.
    IdentityProviderType string
    The identity provider type for the Mongo Cluster User. The only possible value is MicrosoftEntraID. Changing this forces a new resource to be created.
    MongoClusterId string
    The ID of the Mongo Cluster where the User should exist. Changing this forces a new resource to be created.
    ObjectId string
    The Object ID of the Entra ID User or Service Principal. Changing this forces a new resource to be created.
    PrincipalType string
    The principal type for the Mongo Cluster User. Possible values are user and servicePrincipal. Changing this forces a new resource to be created.
    Roles []UserRoleArgs
    One or more role blocks as defined below. Changing this forces a new resource to be created.
    identityProviderType String
    The identity provider type for the Mongo Cluster User. The only possible value is MicrosoftEntraID. Changing this forces a new resource to be created.
    mongoClusterId String
    The ID of the Mongo Cluster where the User should exist. Changing this forces a new resource to be created.
    objectId String
    The Object ID of the Entra ID User or Service Principal. Changing this forces a new resource to be created.
    principalType String
    The principal type for the Mongo Cluster User. Possible values are user and servicePrincipal. Changing this forces a new resource to be created.
    roles List<UserRole>
    One or more role blocks as defined below. Changing this forces a new resource to be created.
    identityProviderType string
    The identity provider type for the Mongo Cluster User. The only possible value is MicrosoftEntraID. Changing this forces a new resource to be created.
    mongoClusterId string
    The ID of the Mongo Cluster where the User should exist. Changing this forces a new resource to be created.
    objectId string
    The Object ID of the Entra ID User or Service Principal. Changing this forces a new resource to be created.
    principalType string
    The principal type for the Mongo Cluster User. Possible values are user and servicePrincipal. Changing this forces a new resource to be created.
    roles UserRole[]
    One or more role blocks as defined below. Changing this forces a new resource to be created.
    identity_provider_type str
    The identity provider type for the Mongo Cluster User. The only possible value is MicrosoftEntraID. Changing this forces a new resource to be created.
    mongo_cluster_id str
    The ID of the Mongo Cluster where the User should exist. Changing this forces a new resource to be created.
    object_id str
    The Object ID of the Entra ID User or Service Principal. Changing this forces a new resource to be created.
    principal_type str
    The principal type for the Mongo Cluster User. Possible values are user and servicePrincipal. Changing this forces a new resource to be created.
    roles Sequence[UserRoleArgs]
    One or more role blocks as defined below. Changing this forces a new resource to be created.
    identityProviderType String
    The identity provider type for the Mongo Cluster User. The only possible value is MicrosoftEntraID. Changing this forces a new resource to be created.
    mongoClusterId String
    The ID of the Mongo Cluster where the User should exist. Changing this forces a new resource to be created.
    objectId String
    The Object ID of the Entra ID User or Service Principal. Changing this forces a new resource to be created.
    principalType String
    The principal type for the Mongo Cluster User. Possible values are user and servicePrincipal. Changing this forces a new resource to be created.
    roles List<Property Map>
    One or more role blocks as defined below. Changing this forces a new resource to be created.

    Supporting Types

    UserRole, UserRoleArgs

    Database string
    The name of the database to which the role will be applied. Changing this forces a new resource to be created.
    Name string
    The role name. The only possible value is root. Changing this forces a new resource to be created.
    Database string
    The name of the database to which the role will be applied. Changing this forces a new resource to be created.
    Name string
    The role name. The only possible value is root. Changing this forces a new resource to be created.
    database String
    The name of the database to which the role will be applied. Changing this forces a new resource to be created.
    name String
    The role name. The only possible value is root. Changing this forces a new resource to be created.
    database string
    The name of the database to which the role will be applied. Changing this forces a new resource to be created.
    name string
    The role name. The only possible value is root. Changing this forces a new resource to be created.
    database str
    The name of the database to which the role will be applied. Changing this forces a new resource to be created.
    name str
    The role name. The only possible value is root. Changing this forces a new resource to be created.
    database String
    The name of the database to which the role will be applied. Changing this forces a new resource to be created.
    name String
    The role name. The only possible value is root. Changing this forces a new resource to be created.

    Import

    Mongo Cluster Users can be imported using the resource id, e.g.

    $ pulumi import azure:mongocluster/user:User example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.DocumentDB/mongoClusters/cluster1/users/user1
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    Azure Classic pulumi/pulumi-azure
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the azurerm Terraform Provider.
    azure logo

    We recommend using Azure Native.

    Azure v6.31.0 published on Monday, Dec 29, 2025 by Pulumi
      Meet Neo: Your AI Platform Teammate