Logstash mongodb output plugin fails to authenticate

I'm using the logstash mongodb output plugin to write documents to Azure cosmos DB. I am facing the exact same issue as reported here Logstash MongoDB Output Plugin - command insert requires authentication
Here is my configuration

mongodb {
       collection => "mycollection"
        database => "mydatabase"
        isodate => true
        uri => "mongodb://username:password@cosmos-
account.mongo.cosmos.azure.com:10255/?ssl=true&replicaSet=globaldb"
}

This is the error I get

<Mongo::Auth::Unauthorized: User username is not authorized to access .>

Is there some special way that the connection string for cosmos db should be mentioned?
If I try to access this cosmos db instance using the mongo shell and a python script, it works fine. It only fails from logstash