Get-AzCosmosDBAccount Cmdlet Reference

This page provides detailed information about the Get-AzCosmosDBAccount cmdlet in Azure PowerShell, which is used to retrieve information about Azure Cosmos DB accounts.

This cmdlet is part of the Az.CosmosDB module. Ensure you have installed the latest version of the Azure PowerShell modules. You can update them by running Update-Module -Name Az.

SYNOPSIS

Retrieves one or more Azure Cosmos DB accounts.

SYNTAX

Get-AzCosmosDBAccount
    [[-Name] ]
    [-ResourceGroupName ]
    [-DefaultProfile ]
    []

Get-AzCosmosDBAccount
    [-ResourceGroupName ]
    [-Subscription ]
    [-DefaultProfile ]
    []

Get-AzCosmosDBAccount
    [-Id ]
    [-DefaultProfile ]
    []

Get-AzCosmosDBAccount
    [-InputObject ]
    [-DefaultProfile ]
    []

DESCRIPTION

The Get-AzCosmosDBAccount cmdlet retrieves one or more Azure Cosmos DB accounts in the current subscription.

This cmdlet can be used to retrieve all accounts in a subscription, all accounts in a specific resource group, or a specific account by its name.

EXAMPLES

Example 1: Get all Azure Cosmos DB accounts in the current subscription

Get-AzCosmosDBAccount

Example 2: Get all Azure Cosmos DB accounts in a resource group

Get-AzCosmosDBAccount -ResourceGroupName "MyResourceGroup"

Example 3: Get a specific Azure Cosmos DB account

Get-AzCosmosDBAccount -Name "MyCosmosDBAccount" -ResourceGroupName "MyResourceGroup"

Example 4: Get an Azure Cosmos DB account using its resource ID

Get-AzCosmosDBAccount -Id "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.DocumentDB/databaseAccounts/MyCosmosDBAccount"

PARAMETERS

  • -Name [System.String]
    Specifies the name of the Azure Cosmos DB account.
  • -ResourceGroupName [System.String]
    Specifies the name of the resource group that contains the Azure Cosmos DB account.
  • -Id [System.String]
    Specifies the resource ID of the Azure Cosmos DB account.
  • -InputObject [Microsoft.Azure.Commands.Cosmos.Models.PSCosmosDBAccount]
    Specifies an Azure Cosmos DB account object as input to the cmdlet.
  • -Subscription [System.String]
    Specifies the name or ID of the subscription on which to perform the operation.
  • -DefaultProfile [IAzureContextContainer]
    The credentials, account, tenant, and subscription that are used for communication with Azure Resource Manager.
  • -WhatIf [System.Management.Automation.SwitchParameter]
    Performs the operation without actually executing the changes and provides a summary of what the operation would do.
  • -Confirm [System.Management.Automation.SwitchParameter]
    Prompts you for confirmation before running the cmdlet.

INPUTS

System.String, Microsoft.Azure.Commands.Cosmos.Models.PSCosmosDBAccount

The InputObject parameter accepts a PSCosmosDBAccount object that can be piped into the cmdlet.

OUTPUTS

Microsoft.Azure.Commands.Cosmos.Models.PSCosmosDBAccount, Microsoft.Azure.Commands.Cosmos.Models.PSCosmosDBAccount[]

The cmdlet returns a single Azure Cosmos DB account object or an array of account objects.

NOTES

Important: Ensure you are logged in to Azure using Connect-AzAccount before executing this cmdlet. The Az.CosmosDB module must be installed and up-to-date for full functionality.

You can use wildcards with the -Name parameter, e.g., Get-AzCosmosDBAccount -Name "My*".