'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 1:[1]

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!

Solution 2:[2]

AFAIK, It is believed that if you deploy the Template, both API Connections will be created, but you will have to manually update the connection inside logic apps by adding your service credentials. This is because, in order to complete the API connection, you must provide consent, which is not available in the template.

This script will retrieve a consent link for an OAuth Logic Apps connector connection. The consent link will then be opened, and authorization will be completed to allow a connection to be established.

For more inforation please refer this blog|BICEP-Create API connections for Logic Apps & Deploy Logic Apps & API Connection with ARM

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rik
Solution 2 AjayKumarGhose-MT