0

I'm trying to deploy a service bus api connection using bicep. This connection should auth using managed identity (in my case, Logic Apps). In my DEV environment the api connection was created from a Logic App, and I'm trying to deploy the same to other environment.

I have tried this:

connections module:

param connectionName string
param displayName string
param apiName string
param parameterValues object = {}
param parameterValueSet object = {}

resource connection 'Microsoft.Web/connections@2016-06-01' = {
  name: connectionName
  location: resourceGroup().location
  kind: 'V2'
  properties: {
    api: {
      id: 'subscriptions/${subscription().subscriptionId}/providers/Microsoft.Web/locations/${resourceGroup().location}/managedApis/${apiName}'
    }
    displayName: displayName
    parameterValues: parameterValues
    parameterValueSet: parameterValueSet
  }
}

output connectionRuntimeUrl string = reference(connection.id, connection.apiVersion, 'full').properties.connectionRuntimeUrl

In main.bicep

module servicebusApiConnection 'Modules/connection.bicep' = {
  name: serviceBusApiConnectionName
  params: {
    connectionName: serviceBusApiConnectionName
    displayName: serviceBusApiConnectionName
    apiName: 'servicebus'
    parameterValueSet: {
      name: 'managedIdentityAuth'
      values: {
        namespaceEndpoint: {
          'value': 'sb://${serviceBusNamespace.name}.servicebus.windows.net'
        }
      }
    }
  }
}

But the connection says Status "Error" after deploy.

I can see in my service bus api connection in DEV has the option "Logic Apps Managed Identity" for Authentication Type.

enter image description here

the deployed one look like this. It does not say "This connection can only be used with a managed identity." like the one in DEV.

enter image description here

3

1 Answer 1

0

you have to deploy the access policy as well (after connections are deployed), i dont have bicep for it but here is an ARM example:

    {
  "type": "Microsoft.Web/connections/accessPolicies",
  "apiVersion": "2016-06-01",
  "name": "[concat('servicebus','/',variables('logicAppName'))]",
  "location": "westeurope",
  "dependsOn": [
    "[resourceId('Microsoft.Web/sites', variables('logicAppName'))]"
  ],
  "properties": {
    "principal": {
      "type": "ActiveDirectory",
      "identity": {
        "tenantId": "[subscription().tenantId]",
        "objectId": "[reference(resourceId('Microsoft.Web/sites', variables('logicAppName')), '2018-11-01', 'Full').identity.principalId]"
      }
    }
      }
    }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.