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):
Extract the zip file to a temporary location;
In the temporary location, delete the parameters.json
file (which currently contains the settings only applicable to local running of the Logic App project). Also rename the parameters.azureenv.json
file to parameters.json
. I used a PowerShell script for all this;
Zip up the modified contents of the temporary location into a new zip file.
Deploy the newly created zip file to the Logic App Standard resource.
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.