Cosmos DB command line tool for loading json docs into containers

Viewed 217

We have a need to pre-populate Cosmos DB containers with some static json files. This is a requirement for both local developer Cosmos DB emulator environments, and also Azure DevOps deployments. Ideally those two scenarios would use the same approach of course.

One way I was thinking was to have static json documents in our git repo, and to have a dotnet core command line tool that would connect to Cosmos DB and insert one or more docs to a specified DB and container, per invocation of the console app.

I found this tool which seems like a good fit:

However, this targets .NET Framework 4.5, and therefore cannot be used easily by our Mac and Linux developers. So one option would be to have a go at migrating that tool to dotnet core.

I also found these bash scripts that seem relevant:

I.e. Windows users could use WSL to run these.

However, I think a dotnet core console app would be the ideal solution here. It seems like an obvious simple tool to want, so was wondering if there is anything already out there.

Or maybe am I thinking about this problem the wrong way?

1 Answers

There isn't anything out there today but the first link you referenced there to the DMT running on .NET 4.5 is being transitioned to a new maintainer, Solliance, who is going to be ported over to .NET Core but there is no ETA as of yet.

The only thing I can suggest is to roll your own app to read from blob storage and insert into Cosmos. The other possible option too is to use Azure Data Factory and create/update a job with new endpoint and keys when you roll a new environment.

Related