skip to Main Content

Can we define parameters in the azure pipeline yaml file and use those parameter values in workflow.json for Logic apps in VS Code?

Or, is it possible to define value in azure pipeline yaml file that goes and sits into appsettings which I guess should be a once time activity

Please provide a way where I can set a value to appsettings from Visual Studio code

I have a requirement where this has to be done from Visual Studio Code

2

Answers


  1. The Microsoft approach is to have a secondary parameters file for each environment deployment.

    Unfortunately for you, there’s no example of that in the Azure DecOps samples …

    https://github.com/Azure/logicapps/tree/master/azure-devops-sample/.pipelines

    … but there is in the GitHub samples …

    https://github.com/Azure/logicapps/blob/master/github-sample/.github/workflows/logicapp_deploy.yml

    … look at the final step called Swap parameter files.

    That’s the approach you need to take.

    Alternatively, point all of your parameters to appsettings.json and you can manage it that way.

    Login or Signup to reply.
  2. You can use the following approach:

    Instead of using actual values in your files e.g. in the app settings JSON, use placeholders like this:

    [
      {
        "name": "First_setting",
        "value": "__First_setting_value__"
      },
      {
        "name": "__Second_setting__",
        "value": "__Second_setting_value__"
      }
    ]
    

    Set variables with same names as the placeholders (without the __ prefix and suffix) in your YAML pipeline e.g.

    variables:

    • name: First_setting_value
      value: ‘First variable value’
    • name: Second_setting_value
      value: ‘Second variable value’

    Use the Replace tokens task (qetza.replacetokens.replacetokens-task.replacetokens@6) in your YAML pipeline to replace the placeholders in your files with the actual values of YAML variables. It will transform your file like this:

    [
      {
        "name": "First_setting",
        "value": "First variable value"
      },
      {
        "name": "Second_setting",
        "value": "Second variable value"
      }
    ]
    

    Bingo – you’ve just "defined values in the azure pipeline YAML file that went directly into appsettings".

    The same approach can be used with any text files.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search