0
votes

Very shortly, I have 2 questions:

  1. how can we setup logic app variable value at realease time (for example)...
  2. Or how can logic app read values from settings file?

My actual environment:

I have 2 azure "environments", in other terms 2 azure resource groups that contain each the identical ressources and configurations.

Azure
|
|__Dev resource group : logic app + api App + .... other resources
|__Prod resource group: prod logic app + prod api App + .... other prod resources

Inside my logic Apps I have http endpoint call steps.

here

Actually both logic apps (prod logic app and dev logic app) are calling the dev api app endpoints (same api app on dev environment) because my problem is that I couldn't find a way to transform the value of the url inside the logic app http calls.

What i am trying to do is to change the base url value underlined in the image above by the adequate api app url of each environment (dev and prod) like following :

Dev api app url is : https://pwfotcapiapp

Prod api app url is : https://pwfprodotwapiapp...

I tried to set up the api app base url in a variable in appsettings.json and transform it at deploy time. It was ok but i couldn't set the base url value because i couldn't find a way to read appsettings.json variables from logic apps.

I Have a Ci/Cd Pipeline that creates or updates adequate resources on each resource group and does variables transformation successfully:

ci cd

So, in other words i have :

2 environments, 2 web apps (api apps), 2 logic apps

==> I want to be able to setup each logic app http calls url values to point a different web app (api app) at release time or to find a way to read appsettings values from logic app.

Any contribution would be appreciated

EDIT:

I Use Visual Studio to Develop My logic app

The trigger for my build is the commit, then the drop (build artifact drop) is the trigger for deploy pipeline.

2

2 Answers

0
votes

We can read appsettings.json from logic app by the steps below:

  1. I set the value of baseurl in appsetting.json and create a azure storage blob and then upload the appsetting.json to the blob.

enter image description here

enter image description here

  1. Use "Get blob content" action in logic app to get the content of appsetting.json. enter image description here

  2. Then initialize a variable named "jsonString" and set the value with the expression shown as below screenshot. enter image description here

  3. After that, we can use "Parse JSON" action to parse the jsonString we got above. enter image description here We can click "Use sample payload to generate schema" in the screenshot above and input the content of appsetting.json into it to generate the schema.

  4. Then we can initialize another variable named "baseurl" and set the value with baseurl get from "Parse JSON". enter image description here

  5. Now we can use the baseurl by the expression shown as below screenshot in your "HTTP" action. enter image description here

Hope it would be helpful to your problem~

0
votes

I just tested logic app with template parameters.

I used the default example for developing logic app with visual studio.

I’ve parameterized both the base URL for the RSS feed and the mail to value. The steps are as follows –

  1. Declare template parameter. The defaultValue is not mandatory. Step1
  2. Replace the strings inside the fields by replacing with the parameter call. Step2
  3. Then you can also override these parameters in parameter file as well. Step3
  4. You can also override the value of parameter in CD pipeline enter image description here

The precedence of the values are “LogicApp.json” < “LogicApp.parameters.json” < “override in CD pipeline”.

For this example you can see that I used “google.com” as default base URL. But I override it in parameter files. Also I have three different email address in different files. So the email address was used as presented in CD pipeline overriding both the default declaration and the parameter file.

But the base url is used as mentioned in the parameter file. So if you have different stage/task for deploying the logic app to development and production environment, you can use either way.