Reputation: 756
Is it possible to connect to Azure cosmos DB using MSI the same way as it is possible for Azure SQL?
That's how it works for Azure SQL Server
using (var connection = new SqlConnection(connectionString))
{
connection.AccessToken = await new AzureServiceTokenProvider().GetAccessTokenAsync("https://database.windows.net/");
await connection.OpenAsync(cancellationToken);
//...
}
I'm not able to find anythig like this for Cosmos DB. While MSI support for it seems to be enabled
Upvotes: 2
Views: 3672
Reputation: 72141
No, not directly. Cosmos DB doesnt support Azure AD auth - hence cant use MSI.
You can use MSI to pull Cosmos DB keys though: https://learn.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/tutorial-windows-vm-access-cosmos-db
Upvotes: 7