I have created variable groups in Azure library and link in Azure pipeline. How to initialize xxx.json
file? Update variables of xxx.json
file in react and .NET project.
I added variables in library group and link this variable group to Azure pipeline. To use a variable from a variable group, you need to add a reference to the group in your YAML file:
variables:
- group: my-variable-group
Thereafter variables from the variable group can be used in your YAML file.
This is the xxx.json
in code:
{
"API_ENDPOINT": "https://api.example.com",
"https://localhost"
}
How to update values for Azure variable group?
2
Answers
You can use Azure DevOps Replace Tokens task in your pipeline and do the token replacement in your configuration files during your Azure Pipeline run.
First define Tokens in your configuration file:
Then your task will search for tokens with the specified prefix in the specified files and replace them with corresponding variable values from your variables.
Here you have an article how to deal with token replacement.
You may add the simple PowerShell script: