Search code examples
azurecontinuous-integrationazure-logic-apps

CI/CD pipeline for Logic app (consumption) with parameterized connections


I would like to ask if it is possible to deploy LogicApp consumption to azure with parameterized connections, currently im using task:

                - task: AzureResourceManagerTemplateDeployment@3
                  displayName: "Deploy ARM template"
                  inputs:
                    azureResourceManagerConnection: $(connectionName)
                    subscriptionName: $(subscriptionId)
                    resourceGroupName: $(resourceGroupName)
                    location: $(location)
                    csmFile: $(Pipeline.Workspace)/armtemplate/**/workflow.json
                    csmParametersFile: $(Pipeline.Workspace)/armtemplate/**/parameters.json
                    deploymentMode: "Incremental"
                    overrideParameters: -subscriptionId $(subscriptionId) -resourceGroupName $(resourceGroupName) -location $(locationParameter)

this task deploy my logic app correctly, but there are no parameters my workflow.json looks like this: enter image description here Im getting this kind of error: #[error]LinkedAuthorizationFailed: The client has permission to perform action 'Microsoft.Web/connections/join/action' on scope '/subscriptions/xxxxx/resourcegroups/xxxx/providers/Microsoft.Logic/workflows/LogicAppTestDeploy2', however the linked subscription '[parameters('subscriptionId')]' was not found.

Am i doing something wrong? or is it even possible to make connections parameterized?

thank you for your answers


Solution

  • The ARM template is referencing an API Connection resource called "sharepointonline-01" which should exist beforehand, you could also deploy it alongside the Logic App workflow (https://learn.microsoft.com/en-us/azure/templates/microsoft.web/connections?pivots=deployment-language-arm-template).

    You are getting this error because your parameterized string "id" is not valid ARM. To get the desired result you can use the concat function instead.

    But, since you are referencing an existing resource, use one of the resource functions available in ARM for referencing resources:(https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/template-functions-resource#subscriptionresourceid)

    To get something like this:

    "sharepointonline": {
       "connectionId": "[resourceId('Microsoft.Web/connections', 'sharepointonline-1')]",
       "id": "[subscriptionResourceId('Microsoft.Web/locations/managedApis', parameters('location'), 'sharepointonline')]",
     }