Solution 1:

After a lot of non-successful attempts we finally managed to find a solution!

With pymongo 3.X.X, we were able to connect to our documentDb instance by adding the parameter tlsInsecure=true to the original URI, which is passed to our MongoClientfunction.

For pymongo 4.X.X we had to add an extra parameter directConnection=true to make things work.

The host variable can be set to localhost or 127.0.0.1 and username and password can be encripted with urlib or not.