Search code examples
azureinfrastructure-as-code

Creating an Azure Queue action in a Logic App with bicep results in 'Connector not Found'


I try to create a Logic App with a Azure Queues Operation. I want to use a API connection resource to connect to the storage account. However

The API Connection resource and the Logic App itself are deployed without errors but after deployment the operation cannot find the API connection and the operation does not work.

When I manually create the operation in the portal after deployment it works.

Part of bicep for the action in logic app:

 'Put_a_message_on_a_queue_(V2)' : {
          runafter: {}
          type: 'ApiConnection'
          inputs: {
            body: 'start'
            host: {
              connection: {
                name: azureQueueConnectionId
              }
            }
              method: 'post'
              path: '/v2/storageAccounts/${storageAccountName}/queues/dailymaintenance/messages'
            
          }
        }

The API connection:

resource logicAppConnection 'Microsoft.Web/connections@2016-06-01' = {
  name: name
  location: resourceLocation
  properties: {
    displayName: 'connect-to-${externalResourceName}'
    parameterValues: {
      storageaccount: storageAccountReference.name
      sharedkey: storageAccountReference.listKeys().keys[0].value
}

    api: {
      name: 'azurequeues'
      displayName: 'Azure Queues'
      description: 'Azure Queue storage provides cloud messaging between application components. Queue storage also supports managing asynchronous tasks and building process work flows.'
      iconUri: 'https://connectoricons-prod.azureedge.net/releases/v1.0.1546/1.0.1546.2665/azurequeues/icon.png'
      brandColor: '#0072C6'
      id: '${subscription().id}/providers/Microsoft.Web/locations/${resourceLocation}/managedApis/azurequeues'
      type: 'Microsoft.Web/locations/managedApis'
    }
    testLinks: [ 
      {
        requestUri: '${environment().resourceManager}/subscriptions/${subscription().id}/resourceGroups/${resourceGroup().name}/providers/Microsoft.Web/connections/${name}/extensions/proxy/testConnection?api-version=2016-06-01'
        method: 'get'
      }
    ]
  }
}

output id string = logicAppConnection.id

This is de error I get in the Logic App Designer: "Connector not found"

I am wondering why this is not working as expected and if someone already managed to do this with bicep?

Thanks in advance


Solution

  • It turned out the API connection name must be set as follows to make this work

      actions: {
        'Put_a_message_on_a_queue_(V2)' : {
          runafter: {}
          type: 'ApiConnection'
          inputs: {
            body: 'start'
            host: {
              connection: {
                name: '@parameters(\'$connections\')[\'azurequeues\'][\'connectionId\']'
              }
            }
              method: 'post'
              path: '/v2/storageAccounts/${storageAccountName}/queues/dailymaintenance/messages'
            
          }
        }
      }
    }
    parameters: {
      '$connections': {
        value: {
          azurequeues: {
            connectionId: logicAppConnection.id
            connectionName: 'LogicAppConnection'
            id: '/subscriptions/xxxxxxxxxxx/providers/Microsoft.Web/locations/westeurope/managedApis/azurequeues'
          }
        }
      }
    }
    

    After I deployed this, it worked!