Skip to content

Latest commit

 

History

History
53 lines (39 loc) · 2.41 KB

File metadata and controls

53 lines (39 loc) · 2.41 KB
title description author ms.service ms.subservice ms.topic ms.date ms.author ms.reviewer ms.custom
PowerShell script to create Azure Cosmos DB MongoDB API database and collection with autoscale
Azure PowerShell script - create Azure Cosmos DB MongoDB API database and collection with autoscale
seesharprun
cosmos-db
mongodb
sample
07/30/2020
sidandrews
mjbrown
devx-track-azurepowershell

Create a database and collection with autoscale for Azure Cosmos DB - API for MongoDB

[!INCLUDEMongoDB]

[!INCLUDE updated-for-az]

This sample requires Azure PowerShell Az 5.4.0 or later. Run Get-Module -ListAvailable Az to see which versions are installed. If you need to install, see Install Azure PowerShell module.

Run Connect-AzAccount to sign in to Azure.

Sample script

[!code-powershellmain]

Clean up deployment

After the script sample has been run, the following command can be used to remove the resource group and all resources associated with it.

Remove-AzResourceGroup -ResourceGroupName "myResourceGroup"

Script explanation

This script uses the following commands. Each command in the table links to command specific documentation.

Command Notes
Azure Cosmos DB
New-AzCosmosDBAccount Creates an Azure Cosmos DB Account.
New-AzCosmosDBMongoDBDatabase Creates a API for MongoDB Database.
New-AzCosmosDBMongoDBIndex Creates a API for MongoDB Index.
New-AzCosmosDBMongoDBCollection Creates a API for MongoDB Collection.
Azure Resource Groups
Remove-AzResourceGroup Deletes a resource group including all nested resources.

Next steps

For more information on the Azure PowerShell, see Azure PowerShell documentation.