Demonstrates how to use ComosDB PowerShell module for bulk CRUD operations on Cosmos
Install-Module -Scope CurrentUser -Name CosmosDB
Sample JSON
{
"id": "1001",
"firstName": "John1001",
"lastName": "Doe1001"
}
- CreateCosmos.ps1
- DeleteAllRecords.ps1
- PopulateCollection.ps1
Remember to change the following to suit your environment
Set-StrictMode -Version "2.0"
$ErrorActionPreference="Stop"
$Global:CosmosResourceGroup="rg-demo-cosmos-serverless"
$Global:CosmosAccountName="saudemocosmosserverless"
$Global:CustomersManagementDatabase="CustomerManagement"
$Global:CustomersMasterContainer="customers"
$Global:Location="uksouth"
- Clone this repository
- Navigate to the folder which contains this README.MD file
- Launch PowerShell Core
- Ensure you have the core modules installed
- Change the variables in Common.ps1 to point to your Cosmos account
- Create a Cosmos account by runnning the script CreateCosmos.ps1
- Create a database and a collection (refer variables in Commons.ps1)
Run PopulateCollection.ps. You should now see 2 documents created
Run DeleteAllRecords.ps1
- Az.Accounts
- Az.Resources
- Az.CosmosDb
- CosmosDb