Skip to content

Unable to connect to Azure Cosmos DB for MongoDB vCore using pymongoΒ #23

@Harikishore-KA

Description

@Harikishore-KA

I'm trying to setup the connection for my MongoDb vCore cluster using pymongo, here is the code I have used

mongo_conn = "mongodb+srv://"+COSMOS_MONGO_USER+":"+COSMOS_MONGO_PWD+"@"+COSMOS_MONGO_SERVER+"?tls=true&authMechanism=SCRAM-SHA-256&retrywrites=false&maxIdleTimeMS=120000"

mongo_client = pymongo.MongoClient(mongo_conn)

Following is the error I have received.

ConfigurationError: nameserver is not a dns.nameserver.Nameserver instance or text form, IP address, nor a valid https URL

COSMOS_MONGO_SERVER values was in this format :

sample-db.mongocluster.cosmos.azure.com/

Environment:

Python: 3.11.5

Pymongo : 4.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions