Adventures with Logic Apps: Using Bicep to Deploy Logic Apps!

I have a fairly simple Logic App, messages are received from a Service Bus queue and an email is then sent using Send Grid.

Pretty straight forward.

Big believer in IaaC, so I wanted to create a deployment using Bicep for my Logic App and the Api Connections.

My Service Bus connection uses a Managed Identity, while my SendGrid connection uses the SendGrid ApiKey.

The SendGrid connection was no problem, I just passed in the ApiKey to my Bicep template as a parameterValues and all was good.

resource sendGridConnection 'Microsoft.Web/connections@2016-06-01' = {
  name: '${prefix}sndgrdconn'
  location: location
  properties: {
    displayName: '${prefix}sndgrdconn'
    api: {
      id: '${subscription().id}/providers/Microsoft.Web/locations/${location}/managedApis/sendgrid'
    }
    parameterValues: {
      apiKey: sendGridApiKey
    }
  }
}

On to the Service Bus connection, which is where my real struggle began. The documentation is sketchy on how exactly to do this.

I stumbled around for a day or two until I came across the following articles:

With a couple of modifications to my Bicep file I was able to get it working.

resource serviceBus 'Microsoft.ServiceBus/namespaces@2021-11-01' existing = {
  name: '${prefix}sb'
}

resource serviceBusConnection 'Microsoft.Web/connections@2016-06-01' = {
  name: '${prefix}sbconn'
  location: location
  properties: {
    displayName: '${prefix}sb'
    api: {
      id: '${subscription().id}/providers/Microsoft.Web/locations/${location}/managedApis/servicebus'
    }
    parameterValueSet: {
      name: 'managedIdentityAuth'
      values: {
        namespaceEndpoint: {
          value: 'sb://${serviceBus.name}.servicebus.windows.net'
        }
      }
    }
  }
}

Bicep will complain about the parameterValueSet property, but just ignore it and run the script anyways.

You can see the complete Bicep file at Adventures with Logic Apps: Bicep Deployment and API Connections … Ugh! (github.com).

As always, hope this helps a fellow developer!


Discover more from Matt Ruma

Subscribe to get the latest posts sent to your email.

1 Reply to “Adventures with Logic Apps: Using Bicep to Deploy Logic Apps!”

  1. thanks for the blog post. great information! this is very helpful in making the bicep
    template. After I create template, deploy to test, they find a bug or need more features. after I go back into the logic app and update, how do I get the workflow change into the template?

Leave a Reply

Your email address will not be published. Required fields are marked *