mondoDBを使いたいのでcosmosDBを作成する

azure cloud shell

az cosmosdb create --name nacosmosdb --resource-group myResourceGroup --kind MongoDB

さーどうしましょう

{
  "additionalProperties": {},
  "capabilities": [],
  "consistencyPolicy": {
    "additionalProperties": {},
    "defaultConsistencyLevel": "Session",
    "maxIntervalInSeconds": 5,
    "maxStalenessPrefix": 100
  },
  "databaseAccountOfferType": "Standard",
  "documentEndpoint": "https://nacosmosdb.documents.azure.com:443/",
  "enableAutomaticFailover": false,
  "failoverPolicies": [
    {
      "additionalProperties": {},
      "failoverPriority": 0,
      "id": "nacosmosdb-westeurope",
      "locationName": "West Europe"
    }
  ],
  "id": "/subscriptions/hoge/resourceGroups/myResourceGroup/providers/Microsoft.DocumentDB/databaseAccounts/nacosmosdb",
  "ipRangeFilter": "",
  "kind": "MongoDB",
  "location": "West Europe",
  "name": "nacosmosdb",
  "provisioningState": "Succeeded",
  "readLocations": [
    {
      "additionalProperties": {},
      "documentEndpoint": "https://nacosmosdb-westeurope.documents.azure.com:443/",
      "failoverPriority": 0,
      "id": "nacosmosdb-westeurope",
      "locationName": "West Europe",
      "provisioningState": "Succeeded"
    }
  ],
  "resourceGroup": "myResourceGroup",
  "tags": {},
  "type": "Microsoft.DocumentDB/databaseAccounts",
  "writeLocations": [
    {
      "additionalProperties": {},
      "documentEndpoint": "https://nacosmosdb-westeurope.documents.azure.com:443/",
      "failoverPriority": 0,
      "id": "nacosmosdb-westeurope",
      "locationName": "West Europe",
      "provisioningState": "Succeeded"
    }
  ]
}

primary master keyを発行する

az cosmosdb list-keys --name nacosmosdb --resource-group myResourceGroup --query "primaryMasterKey"

接続

'use strict';

module.exports = {
  db: {
    uri: 'mongodb://:@.documents.azure.com:10255/mean-dev?ssl=true&sslverifycertificate=false'
  }
};

ん?