I want to create a new variable with an existing one inside a json parameter file for bicep
{
"myVNet_name": "test_vnet",
"myVNet_name2": "????",
}
I want myVNet_name2 for example equal as $myVNet_name_2 , how to do that ?
I want to create a new variable with an existing one inside a json parameter file for bicep
{
"myVNet_name": "test_vnet",
"myVNet_name2": "????",
}
I want myVNet_name2 for example equal as $myVNet_name_2 , how to do that ?
2
Answers
find the answer , cannot reuse a variable in json , not a yaml file
This is purely in Bicep.
If you had a Json config file that Bicep was consuming, you could do something like (Json file):
I tend to you use myself the
{{}}
placeholders so that is obvious in the Json what values are dynamic. Naturally give it a meaningful name, rather thanDynamicValueHere
.Within your YAML (assuming you have YAML), you could then call either some inline PowerShell or a ps1 file with code along the following lines:
After the YAML PowerShell task, you could then call your Bicep task which would consume the file with the values replaced.
I often do this with environments (Dev, Test, Prod), where the Json file will often have 99% identical values other than say a resource name that is specific to the enviornment e.g.
mystorage-uks-dev
,mystorage-uks-test
etc