We recommend using Azure Native.
Azure v6.21.0 published on Friday, Mar 7, 2025 by Pulumi
azure.cosmosdb.getMongoDatabase
Explore with Pulumi AI
Use this data source to access information about an existing Cosmos DB Mongo Database.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const example = azure.cosmosdb.getMongoDatabase({
    name: "test-cosmosdb-mongo-db",
    resourceGroupName: "test-cosmosdb-account-rg",
    accountName: "test-cosmosdb-account",
});
export const id = example.then(example => example.id);
import pulumi
import pulumi_azure as azure
example = azure.cosmosdb.get_mongo_database(name="test-cosmosdb-mongo-db",
    resource_group_name="test-cosmosdb-account-rg",
    account_name="test-cosmosdb-account")
pulumi.export("id", example.id)
package main
import (
	"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/cosmosdb"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		example, err := cosmosdb.LookupMongoDatabase(ctx, &cosmosdb.LookupMongoDatabaseArgs{
			Name:              "test-cosmosdb-mongo-db",
			ResourceGroupName: "test-cosmosdb-account-rg",
			AccountName:       "test-cosmosdb-account",
		}, nil)
		if err != nil {
			return err
		}
		ctx.Export("id", example.Id)
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;
return await Deployment.RunAsync(() => 
{
    var example = Azure.CosmosDB.GetMongoDatabase.Invoke(new()
    {
        Name = "test-cosmosdb-mongo-db",
        ResourceGroupName = "test-cosmosdb-account-rg",
        AccountName = "test-cosmosdb-account",
    });
    return new Dictionary<string, object?>
    {
        ["id"] = example.Apply(getMongoDatabaseResult => getMongoDatabaseResult.Id),
    };
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.cosmosdb.CosmosdbFunctions;
import com.pulumi.azure.cosmosdb.inputs.GetMongoDatabaseArgs;
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 example = CosmosdbFunctions.getMongoDatabase(GetMongoDatabaseArgs.builder()
            .name("test-cosmosdb-mongo-db")
            .resourceGroupName("test-cosmosdb-account-rg")
            .accountName("test-cosmosdb-account")
            .build());
        ctx.export("id", example.applyValue(getMongoDatabaseResult -> getMongoDatabaseResult.id()));
    }
}
variables:
  example:
    fn::invoke:
      function: azure:cosmosdb:getMongoDatabase
      arguments:
        name: test-cosmosdb-mongo-db
        resourceGroupName: test-cosmosdb-account-rg
        accountName: test-cosmosdb-account
outputs:
  id: ${example.id}
Using getMongoDatabase
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getMongoDatabase(args: GetMongoDatabaseArgs, opts?: InvokeOptions): Promise<GetMongoDatabaseResult>
function getMongoDatabaseOutput(args: GetMongoDatabaseOutputArgs, opts?: InvokeOptions): Output<GetMongoDatabaseResult>def get_mongo_database(account_name: Optional[str] = None,
                       name: Optional[str] = None,
                       resource_group_name: Optional[str] = None,
                       opts: Optional[InvokeOptions] = None) -> GetMongoDatabaseResult
def get_mongo_database_output(account_name: Optional[pulumi.Input[str]] = None,
                       name: Optional[pulumi.Input[str]] = None,
                       resource_group_name: Optional[pulumi.Input[str]] = None,
                       opts: Optional[InvokeOptions] = None) -> Output[GetMongoDatabaseResult]func LookupMongoDatabase(ctx *Context, args *LookupMongoDatabaseArgs, opts ...InvokeOption) (*LookupMongoDatabaseResult, error)
func LookupMongoDatabaseOutput(ctx *Context, args *LookupMongoDatabaseOutputArgs, opts ...InvokeOption) LookupMongoDatabaseResultOutput> Note: This function is named LookupMongoDatabase in the Go SDK.
public static class GetMongoDatabase 
{
    public static Task<GetMongoDatabaseResult> InvokeAsync(GetMongoDatabaseArgs args, InvokeOptions? opts = null)
    public static Output<GetMongoDatabaseResult> Invoke(GetMongoDatabaseInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetMongoDatabaseResult> getMongoDatabase(GetMongoDatabaseArgs args, InvokeOptions options)
public static Output<GetMongoDatabaseResult> getMongoDatabase(GetMongoDatabaseArgs args, InvokeOptions options)
fn::invoke:
  function: azure:cosmosdb/getMongoDatabase:getMongoDatabase
  arguments:
    # arguments dictionaryThe following arguments are supported:
- AccountName string
- The name of the Cosmos DB Account where the Mongo Database exists.
- Name string
- The name of this Cosmos DB Mongo Database.
- ResourceGroup stringName 
- The name of the Resource Group where the Cosmos DB Mongo Database exists.
- AccountName string
- The name of the Cosmos DB Account where the Mongo Database exists.
- Name string
- The name of this Cosmos DB Mongo Database.
- ResourceGroup stringName 
- The name of the Resource Group where the Cosmos DB Mongo Database exists.
- accountName String
- The name of the Cosmos DB Account where the Mongo Database exists.
- name String
- The name of this Cosmos DB Mongo Database.
- resourceGroup StringName 
- The name of the Resource Group where the Cosmos DB Mongo Database exists.
- accountName string
- The name of the Cosmos DB Account where the Mongo Database exists.
- name string
- The name of this Cosmos DB Mongo Database.
- resourceGroup stringName 
- The name of the Resource Group where the Cosmos DB Mongo Database exists.
- account_name str
- The name of the Cosmos DB Account where the Mongo Database exists.
- name str
- The name of this Cosmos DB Mongo Database.
- resource_group_ strname 
- The name of the Resource Group where the Cosmos DB Mongo Database exists.
- accountName String
- The name of the Cosmos DB Account where the Mongo Database exists.
- name String
- The name of this Cosmos DB Mongo Database.
- resourceGroup StringName 
- The name of the Resource Group where the Cosmos DB Mongo Database exists.
getMongoDatabase Result
The following output properties are available:
- AccountName string
- Id string
- The provider-assigned unique ID for this managed resource.
- Name string
- ResourceGroup stringName 
- Dictionary<string, string>
- A mapping of tags assigned to the Cosmos DB Mongo Database.
- AccountName string
- Id string
- The provider-assigned unique ID for this managed resource.
- Name string
- ResourceGroup stringName 
- map[string]string
- A mapping of tags assigned to the Cosmos DB Mongo Database.
- accountName String
- id String
- The provider-assigned unique ID for this managed resource.
- name String
- resourceGroup StringName 
- Map<String,String>
- A mapping of tags assigned to the Cosmos DB Mongo Database.
- accountName string
- id string
- The provider-assigned unique ID for this managed resource.
- name string
- resourceGroup stringName 
- {[key: string]: string}
- A mapping of tags assigned to the Cosmos DB Mongo Database.
- account_name str
- id str
- The provider-assigned unique ID for this managed resource.
- name str
- resource_group_ strname 
- Mapping[str, str]
- A mapping of tags assigned to the Cosmos DB Mongo Database.
- accountName String
- id String
- The provider-assigned unique ID for this managed resource.
- name String
- resourceGroup StringName 
- Map<String>
- A mapping of tags assigned to the Cosmos DB Mongo Database.
Package Details
- Repository
- Azure Classic pulumi/pulumi-azure
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the azurermTerraform Provider.