Blog Post

Azure Integration Services Blog
2 MIN READ

Connect to Azure Cosmos DB using Managed Identity from Logic App

talsaifi's avatar
talsaifi
Icon for Microsoft rankMicrosoft
Mar 19, 2024

The Azure Cosmos DB managed connector can connect to Azure Cosmos DB using Logic App managed identity on both Logic App Consumption and Standard. The built-in connector does not support using managed identity.

 

In order for the connection to work, you need to assign the required permissions to your Logic App managed identity on Azure Cosmos DB account. Otherwise, you will get the following error message while executing the workflow action:

 

 

Response status code does not indicate success: Forbidden (403); 
Reason: (Request blocked by Auth comos-db-no-sql : Request is blocked because principal logic-app-managed-identity-object-id does not have required RBAC permissions to perform action [Microsoft.DocumentDB/databaseAccounts/readMetadata] on resource [/]
 

To assign the required permissions, you need to add the required role assignment for your Logic App managed identity to Access Control (IAM) of Azure Cosmos DB account.  The Cosmos DB built-in roles are not available on the portal, to achieve this you will need to use Azure PowerShell or Azure CLI to execute the following command after replacing the values in bold with your account details:

 

az cosmosdb sql role assignment create --account-name comos-db-no-sql --resource-group comsos-db-rg --scope "/" --principal-id logic-app-managed-identity-object-id --role-definition-id /subscriptions/sub-id/resourceGroups/comsos-db-rg/providers/Microsoft.DocumentDB/databaseAccounts/comos-db-no-sql/sqlRoleDefinitions/00000000-0000-0000-0000-000000000001

 

 

az cosmosdb sql role assignment create --account-name comos-db-no-sql --resource-group comsos-db-rg --scope "/" --principal-id logic-app-managed-identity-object-id --role-definition-id /subscriptions/sub-id/resourceGroups/comsos-db-rg/providers/Microsoft.DocumentDB/databaseAccounts/comos-db-no-sql/sqlRoleDefinitions/00000000-0000-0000-0000-000000000001

 

 

There are two Cosmos DB built-in roles available:

 

 

For more details about Cosmos DB built-in roles, check the following reference: Configure role-based access control with Microsoft Entra ID - Azure Cosmos Db | Microsoft Learn

Updated Mar 19, 2024
Version 1.0
No CommentsBe the first to comment