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.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
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:
- https://alessandromoura.azurewebsites.net/2022/04/28/creating-managed-identities-api-connections-for-logic-apps-in-bicep-arm
- https://github.com/Azure/bicep/issues/5516
With a couple of modifications to my Bicep file I was able to get it working.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
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.
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?