Skip to content

Disable local auth for Cosmos db #245

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

Merged
merged 1 commit into from
Jun 20, 2024

Conversation

msftrubengu
Copy link
Contributor

@msftrubengu msftrubengu commented Jun 20, 2024

Disable local authentication for Cosmos DB and use managed identities for authentication in Azure functions.

There is no built-in role for read/write operations in Cosmos DB. A custom role needs to be created (defined in passwordlessRole.json). To create and assign the role these commands must be executed:

az cosmosdb sql role definition create --account-name <cosmos db account> --resource-group <resource group> --body @passwordlessRole.json
az cosmosdb sql role assignment create --account-name <cosmos db account> --resource-group <resource group> --scope "/" --principal-id <principal id> --role-definition-id <role definition id>

Where <role definition id> can be obtained from name property of the output of the az cosmosdb sql role definition create command and <principal id> is the principal id of the azure function. Easiest way to get it is via Get-AzADServicePrincipal -DisplayName <az func name>

@msftrubengu msftrubengu requested a review from a team as a code owner June 20, 2024 02:47
@msftrubengu msftrubengu changed the title Disable local auth for C Disable local auth for Cosmos db Jun 20, 2024
@msftrubengu
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@msftrubengu msftrubengu merged commit 7847f0a into microsoft:main Jun 20, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants