Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cosmos DB: Add AAD authentication #17742

Merged
merged 15 commits into from
Apr 27, 2022
Merged

Cosmos DB: Add AAD authentication #17742

merged 15 commits into from
Apr 27, 2022

Conversation

ealsur
Copy link
Member

@ealsur ealsur commented Apr 26, 2022

This PR adds support for azcore.TokenCredential as authentication method to the Cosmos DB SDK.

How to create a client with AAD

Using the default credential:

cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
	panic(err)
}

client, err := azcosmos.NewClient(endpoint, cred, nil)
if err != nil {
	panic(err)
}

Using a client secret:

cred, err := azidentity.NewClientSecretCredential("tenantId", "clientId", "clientSecret")
if err != nil {
	panic(err)
}

client, err := azcosmos.NewClient(endpoint, cred, nil)
if err != nil {
	panic(err)
}

API changes

There is only a single API change, which adds the new client constructor:

func NewClient(endpoint string, cred azcore.TokenCredential, o *ClientOptions) (*Client, error)

APIView https://apiview.dev/Assemblies/Review/ca456a2f7ed64556b3fb57ecebc0b9d2/cc654e57f8044ed8a14c5dbf421ab49b?diffRevisionId=54a33d355ba146cb8e595448aa039540&doc=False&diffOnly=True

(There are other bogus differences due to reordering of existing properties)

Closes #16219

@ealsur ealsur added the Cosmos label Apr 26, 2022
@ealsur ealsur self-assigned this Apr 26, 2022
@ealsur ealsur requested a review from kirankumarkolli as a code owner April 26, 2022 15:48
@ealsur ealsur merged commit 3f7acd2 into Azure:main Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cosmos needs a constructor taking TokenCrendentail
5 participants