Search code examples
azureazure-resource-managerazure-bicepazure-logic-app-standard

logic app connection to storage account failing


I have created logic app storage connection using below code but unfortunately it is throwing error.

resource blobConnector 'Microsoft.Web/connections@2018-07-01-preview' = {
  name: 'apic-d365-azureblob12345'
  location: Location
  kind: 'V2'
  properties: {
    alternativeParameterValues: {}
    api: {
      id: 'subscriptions/${subscription().subscriptionId}/providers/Microsoft.Web/locations/${Location}/managedApis/azureblob'
    }
    customParameterValues: {}
    displayName: 'azureblob'
    parameterValueSet: {
      name: 'managedIdentityAuth'
      values: {}
    }
  }
}

Role assignment:

resource blobcontributorroleassignment 'Microsoft.Authorization/roleAssignments@2020-10-01-preview' = {
  name: guid(resourceGroup().id, logicappsite.id, blobcontributorroledefination.id)
  properties: {
    roleDefinitionId: blobcontributorroledefination.id
    principalType: 'ServicePrincipal'
    principalId: logicappsite.identity.principalId
  }
}

below is the error it is throwing while making connection

"error": "'Operation not supported with AAD authentication, use Azure Storage Account name/key connection instead

Could someone help me if I am missing something or doing wrong. Thanks in advance.


Solution

  • You also need to create an access policy to allow the logic app to access the connection api:

    // Grant permission to the logic app standard to access the connection api
    resource blobConnectorAccessPolicy 'Microsoft.Web/connections/accessPolicies@2018-07-01-preview' = {
      name: logicappsite.name
      parent: blobConnector
      location: location
      properties: {
        principal: {
          type: 'ActiveDirectory'
          identity: {
            tenantId: subscription().tenantId
            objectId: logicappsite.identity.principalId
          }
        }
      }
    }