def ObtainClient():
    connection_policy = documents.ConnectionPolicy()
    connection_policy.SSLConfiguration = documents.SSLConfiguration()
    # Try to setup the cacert.pem
    # connection_policy.SSLConfiguration.SSLCaCerts = CaCertPath
    # Else, disable verification
    urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
    connection_policy.SSLConfiguration.SSLCaCerts = False

    return cosmos_client.CosmosClient(HOST, MASTER_KEY, "Session", connection_policy=connection_policy)
Exemple #2
0
    def __init__(self,
                 cosmos_account_uri,
                 cosmos_account_key,
                 cosmos_database_id,
                 cosmos_disable_tls=False):
        connection_policy = documents.ConnectionPolicy()
        connection_policy.ConnectionRetryConfiguration = Retry(
            total=5,
            connect=5,
            backoff_factor=0.1,
        )

        if cosmos_disable_tls:
            connection_policy.SSLConfiguration = documents.SSLConfiguration()
            connection_policy.SSLConfiguration.SSLCaCerts = False

        self.cosmos = cosmos_client.CosmosClient(
            cosmos_account_uri, {'masterKey': cosmos_account_key},
            connection_policy)
        self.database_id = cosmos_database_id