Strapi Open Source API CMS using Azure CosmosDB Emulator

Strapi Open Source API CMS using Azure CosmosDB Emulator

I've recently started looking at Strapi. Their default samples look for MongoDB instances. But I wanted to see if it would work with the Azure CosmosDB Emulator - then how it works with Azure CosmosDB.

So far, it's worked flawlessly...

Setup

Once you git clone the samples from the Strapi Samples - you need to edit the database.json file for the environment you're in. For local development, that's going to be development.

In the directory of the sample app hello-world - edit the config\environments\development\database.json file.

For the settings below, run the Azure CosmosDB emulator then launch the Data Explorer - that will show a website with the connection string and key.
explorer

Also, create a new Database called strapi with a collection - call it anything as the tool requires it. It can be deleted later as the sample apps from Strapi will create their own collections.

dbs

  • PORT - examine the Mongo connection string - you'll see the port near the end prefixed by a : -- in mine it was localhost:10255
  • Database - enter strapi as that was used in the create database / collection before.
  • Username: localhost
  • Password: from the "key" - this is also in the mongo connection string but URL encoded.
{
  "defaultConnection": "default",
  "connections": {
    "default": {
      "connector": "strapi-mongoose",
      "settings": {
        "client": "mongo",
        "host": "127.0.0.1",
        "port": 10255,
        "database": "strapi",
        "username": "localhost",
        "password": "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==",
        "authenticationDatabase": "",
        "ssl": true
      },
      "options": {}
    }
  }
}

That's it.