CosmosDB: Instantiate a CosmosClient using a ClientSecretCredential
Is your feature request related to a problem? Please describe.
Currently, it's not possible to use a client secret credential (tenant id, client id and client secret) to instantiate a CosmosClient.
Describe the solution you'd like
from azure.identity import ClientSecretCredential
from azure.cosmos.cosmos_client import CosmosClient
tenant_id='abcd123'
client_id='efgh456'
secret_id='ijkl789'
credential = ClientSecretCredential(tenant_id, client_id, client_secret)
client = CosmosClient(credential)
Describe alternatives you've considered
It's possible to use ClientSecretCredential to instantiate a CosmosDBManagementClient:
subscription_id='mnop000'
client = CosmosDBManagementClient(credential, subscription_id)
# the management client cannot read documents from a container
Unfortunately, this client does not allow to query or read items (documents) from a container. In other words, the management client is not a superset of the CosmosClient.
Thanks for the feedback, we’ll investigate asap.
Related: #19620
Unfortunately, this does not currently work because the Python SDK for Cosmos DB does not support AAD role based access control. This feature is on our roadmap and we plan to tackle this next year. Please don't hesitate to reach out to check for updates.
Just wanted to re-open and close quickly to mention the fact that this is now an available feature in the newest beta release. Thank you for using our SDK @Mogztter!