2

I am trying to deploy Rocket.Chat to an Azure Container Instance. I have the Mongo database running on a virtual machine and am using this command to create the container instance:

az container create  --resource-group <Resource Group> --name rocketchat --image rocket.chat --restart-policy OnFailure --environment-variables MONGO_URL=mongodb:\\<IP Address>:80 --ports 3000

I get the following error from the logs:

/app/bundle/programs/server/node_modules/fibers/future.js:280
                    throw(ex);
                    ^

MongoParseError: Invalid connection string
at parseConnectionString (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/uri_parser.js:573:21)
at connect (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/operations/connect.js:281:3)
at /app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/mongo_client.js:256:5
at maybePromise (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/utils.js:685:3)
at MongoClient.connect (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/mongo_client.js:252:10)
at Function.MongoClient.connect (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/mongo_client.js:476:22)
at new MongoConnection (packages/mongo/mongo_driver.js:208:11)
at new MongoInternals.RemoteCollectionDriver (packages/mongo/remote_collection_driver.js:4:16)
at Object.<anonymous> (packages/mongo/remote_collection_driver.js:38:10)
at Object.defaultRemoteCollectionDriver (packages/underscore.js:784:19)
at new Collection (packages/mongo/collection.js:97:40)
at new AccountsCommon (packages/accounts-base/accounts_common.js:23:18)
at new AccountsServer (packages/accounts-base/accounts_server.js:24:5)
at packages/accounts-base/server_main.js:7:12
at module (packages/accounts-base/server_main.js:19:1)
at fileEvaluate (packages/modules-runtime.js:336:7)

How can I successfully connect my container instance to the database? Thanks in advance!

1 Answers1

0

You can try using the below:

az container create  --resource-group <name of your resource group> --name <nameofyourcontainer>  --image rocket.chat  --restart-policy OnFailure  --environment-variables MONGO_URL=mongodb:\\<YOur MongoDB Url> --ports 3000 -ip-address public

Instead of

az container create  --resource-group <Resource Group> --name rocketchat --image rocket.chat --restart-policy OnFailure --environment-variables MONGO_URL=mongodb:\\<IP Address>:80 --ports 3000

Note:

As per the error you need to specify the correct MongoDB url i.e. connection string .

Example of connection strings:

mongodb://mongodb0.example.com:27017

mongodb://myDBReader:D1fficultP%40ssw0rd@mongodb0.example.com:27017/?authSource=admin

Reference:

Connection String URI Format — MongoDB Manual

Ansuman Bal
  • 9,705
  • 2
  • 10
  • 27