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:
- https://github.com/azure/azure-documentdb-datamigrationtool
- https://learn.microsoft.com/en-us/azure/cosmos-db/import-data
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:
- https://github.com/Krumelur/AzureScripts/blob/master/cosmosdb_create_document.sh
- Use bash, Azure CLI and REST API to access CosmosDB - how to get token and hash right?
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?