Skip to content

Interact with Azure CosmosDB document using Powershell

Notifications You must be signed in to change notification settings

JorgendG/PSCosmosDocument

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

PSCosmosDocument

Interact with Azure CosmosDB document using Powershell

Change these variables to make it work for your account.

$CosmosDBEndPoint = "https://youraccountname.documents.azure.com:443/"
$DatabaseId = "DatabaseName"
$CollectionId = "CollectionName"
$MasterKey = "xx Your read/write key xxx"

This script use the REST api to interact with Cosmos documents.

I've created/copied/modified 6 functions.

  • Generate-MasterKeyAuthorizationSignature
  • Query-CosmosDb
  • New-CosmosDocument
  • Set-CosmosDocument
  • Get-CosmosDocument
  • Remove-CosmosDocument

As an example the script retrieves the serialnumber, model and BIOS version of my computer and creates a Cosmos document.

$jsonRequest = @{
    id= "MYSERIAL"
    model = "eniac"
    biosversion = "1.2"
}

$json = $jsonRequest | ConvertTo-Json

New-CosmosDocument -EndPoint $CosmosDBEndPoint -DataBaseId $DatabaseId -CollectionId $CollectionId -MasterKey $MasterKey -JSON $JSON

About

Interact with Azure CosmosDB document using Powershell

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published