I have a requirement where there are several logic apps created in azure portal, I need to move all of them to visual studio code which I have been doing by copying the workflow.json.
So, here is what I need help with: Based on environment specification, I want to pass inputs in my workflow.json. Say, for example, if the environment is dev, then I want to pass empty input, if it is production then I want to pass some value to the input.
I am very new to logic app and hence, no proper idea on how to do this, please guide me in achieving this.
2
Answers
Since you mentioned
workflow.json
, I assume you’re working with Standard Logic Apps. In this case you would typically have to deal with the following sections of the Logic App:The app settings are stored either in the
Environment variables
or in theConfiguration
section. These settings can be either in clear text or a reference to a key vault secret:If the app setting is a clear text value, it would need to be maintained right there in the Logic App. If it is a reference to a key vault secret, such secrets can be updated in the key vault. In this case, no changes in the Logic App would be required.
The app settings can be referenced both in the
Connections
and in theParameters
sections of the Logic App:Finally, the parameters can be used in the Logic App workflows (
workflow.json
):As you can see, you can keep using same
workflow.json
– only app settings and in some cases parameters would hold different values in different environments.Update:
Provided that your Logic App folder has a correct structure (with
connections.json
,parameters.json
, etc.), you only need to zip it and deploy – you can do it using ArchiveFiles@2 and AzureFunctionApp@1 tasks in DevOps pipelines. You can also update the app settings using the AzureAppServiceSettings@1 task, if necessary.The actual implementation of deployments to different environments depends on your deployment strategy. E.g. on our project we make use of the Replace Tokens task by Guillaume Rouchon. We store app setting & parameter values for different environments in different variable groups, and during deployment the Replace Tokens task just populates JSON files with values from the relevant variable group. Then the folder is zipped and deployed. It makes it very convenient to maintain config changes in different environments separately from the code: only variables need to be updated in relevant groups. Different projects can have absolutely different deployment strategies, the possibilities are endless.
We have been following the same pattern. We download the ARM teamplate of the Logic App from Azure and use the Logic App Template Creater code by Jeffhollan. This assembly will provide a template file and parameter file. We create 3 copies of the parameter file and rename it will SUFFIX as
We create 3 stages in the release pipeline namely DEV, TEST and PROD and use the ARM Template Deployment action. The logic app template file will not chnage however In the action setting we use the respective paramter file specific for each environment.