79420421

Date: 2025-02-07 09:53:44
Score: 1.5
Natty:
Report link

I've been having the same problem and I found a workable solution.

Rather than using a managedApiConnection in the connections.json file, in your parameters.json file add this (as per your example):

"webApiAuthentication": {
  "type": "object",
  "value": {
    "type": "ActiveDirectoryOAuth",
    "tenant": "common",
    "audience": "@appsetting('graph-audience')",
    "clientId": "@appsetting('WORKFLOWAPP_AAD_CLIENTID')",
    "credentialType": "Secret",
    "secret": "@appsetting('WORKFLOWAPP_AAD_CLIENTSECRET')"
  }
}

This will be used during local development. For deployment to Azure, create a new file called parameters.azureenv.json and put this in it:

"webApiAuthentication": {
  "type": "object",
  "value": {
    "type": "ManagedServiceIdentity",
    "identity": "@appsetting('logicApp_identity')",
    "audience": "@appsetting('graph-audience')"
  }
}

Note that I've put all the settings into the appsettings; for local development these will be in the local.settings.json file, while the appsettings deployed to the Logic App Standard resource in Azure will be set using your ARM template (or Bicep / Terraform), and will be appropriate to the environment (dev/stage/prod, etc.).

In your Logic App workflow, the HTTP action needs to look like this:

"HTTP_-_GET_NAME": {
  "type": "Http",
  "inputs": {
    "uri": "@{parameters('url')}",
    "method": "GET",
    "headers": {
      "HeaderName": "@{parameters('HeaderValue')}"
    },
    "authentication": "@parameters('webApiAuthentication')"
  },
  "runtimeConfiguration": {
    "contentTransfer": {
      "transferMode": "Chunked"
    }
  }
}

Because the parameter webApiAuthentication is defined as an object, when using the local or deployed version the whole thing is substituted in, and it doesn't matter that they have different shapes.

In addition to the above, the mechanism for deploying this into Azure has to be considered, because the parameters.azureenv.json has to become parameters.json when deployed. Firstly, make sure that all the parameters files end up in the ZIP file used to deploy the Logic App Standard resource. Then, follow these steps in your Azure DevOps pipeline (or whatever other deployment tool you use):

Once all this is done, you should be able to run the Logic App locally, and the deployed version will also work, and the Logic App remains the same. I've seen some other solutions online that require changes to the code in the Logic App during deployment, but my solution avoids that complication.

Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • Me too answer (2.5): having the same problem
  • Low reputation (0.5):
Posted by: grahama