Adding New Documents in Azure Cosmos DB with Powershell RRS feed

  • Question

  • Hi All,

    I'm trying to figure out how to create new Cosmos DB Document in a Collection using Powershell in Runbook.  I have tried to find documentation on how to performance this without any success.  I have created a Cosmos DB with a SQL API. I was wondering if anyone has tried doing this and if there are any recommendations to get started?

    Thanks in advance,


    Thursday, January 31, 2019 11:06 PM


All replies

  • Hi Brett,

    The MicrosoftDocs PowerShell examples are operational in nature and do not operate at the document level. 

    Azure PowerShell samples for Azure Cosmos DB

    There is however, a PowerShell example availabe in the MSDN Cosmos DB forum:

    Insert document in Cosmos DB using PowerShell (SQL API)

    Once you have your solution specific PowerShell script(s) created, you can then create PowerShell runbooks

    Although there is no one document with a tutorial that meets you specific needs, it is possible to accomplish the desired functonality you seek. 

    I hope this helps.



    Friday, February 1, 2019 6:59 PM
  • Hi Mike,

    Thanks this does help a lot! Figured out that I was having issues with a Partial Key which was causing my problem.  I'm able to query and post. One thing that I'm still trying to figure out is how to view the JSON from the document. When I query I get the ID, Etag, Timestamp and Uri, but not the JSON in the CosmosDB.  Any ideas?  Sorry if this is something simple I'm still getting my feet wet in Cosmos DB.



    Friday, February 1, 2019 9:09 PM
  • Hi Mike,

    Sorry I figured it out.



    Friday, February 1, 2019 9:34 PM