azure-sdk-for-python icon indicating copy to clipboard operation
azure-sdk-for-python copied to clipboard

CosmosDB: Instantiate a CosmosClient using a ClientSecretCredential

Open ggrossetie opened this issue 5 years ago • 4 comments

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.

ggrossetie avatar Nov 09 '21 09:11 ggrossetie

Thanks for the feedback, we’ll investigate asap.

xiangyan99 avatar Nov 09 '21 17:11 xiangyan99

Related: #19620

EpicWink avatar Nov 25 '21 02:11 EpicWink

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.

gahl-levy avatar Nov 30 '21 18:11 gahl-levy

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!

simorenoh avatar Apr 11 '22 15:04 simorenoh