I'm working on a project using Go microservices connecting to an Azure CosmosDB. On the dev / stage environment I'm using the MongoDB API 3.6, for production 4.0.
The microservices creating indices on the collections. For the dev / stage environment all work's fine. But on production I'm retrieving the following error:
(Unauthorized) Error=13, Details='Response status code does not indicate success, Number of regions attempted:1
I've checked the connection string twice and currently there are no firewall rules for the production db.
My code looks familiar to this:
package repository
import (
"go.mongodb.org/mongo-driver/mongo"
"log"
)
func Collection(db *mongo.Database, c string, indices ...mongo.IndexModel) *mongo.Collection {
col := db.Collection(c)
if indices != nil {
_, err := col.Indexes().CreateMany(ctx, indices)
if err != nil {
log.Fatal(err)
}
}
return col
}
// .....
package service
import (
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"repository"
)
col := repository.Collection(db, "my_col", []mongo.IndexModel{
{
Keys: bson.M{"uuid": 1},
Options: options.Index().SetUnique(true),
},
}...)
Anyone an idea what causes this error?