in azure, the generated connection strings don't quite match what the exercise sent by Kaylan sent. and I also wasn't setting some of the options. without the options I get a message "Password contains an illegal unescaped character"
the Primary Connection string and Secondary Connection String add the following:
&retrywrites=false
&maxIdleTimeMS=120000
&appName=@<appNam>@
once I removed that from the connection string AND used the options, things worked.
my final connection example:
//pulled from config for clarity
const config = {'database': process.env.MONGODB_URI || 'mongodb://<user>:<password>@<db>.mongo.cosmos.azure.com:10255/<dbname>?ssl=true&replicaSet=globaldb'
}
mongoose.connect(config.database, //with user and pass inside
{
useNewUrlParser: true,
useUnifiedTopology: true,
retryWrites: false,
useFindAndModify: false,
useCreateIndex: true
})
//.then(() => console.log('Connection to CosmosDB successful'))
.catch((err) => console.error('CosmosDB error:', err))