I'm using Linked Templates in Azure ARM templates. I have a problem trying to use the default value of a sub template but still maintaining in the parent template the reference to a parameter.
parent.json
...
parameters: {
foo: {
type: "string"
}
},
resources: [{
type: "Microsoft.Resources/deployments",
properties: {
templateLink: {
uri: "sub.json",
contentVersion: "1.0.0.0"
},
parameters: {
bar: {
value: "[parameters('foo')]"
}
}
}
}]
...
sub.json
...
parameters: {
bar: {
type: "string",
allowedValues: ["larry", "moe", "curly"],
defaultValue: "curly"
}
}
...
Unfortunately, passing the null value for foo in the parent template will error The value of deployment parameter 'foo' is null
. If I pass an empty string for foo, it will error The provided value '' for the template parameter 'bar' is not valid. The parameter value is not part of the allowed value(s): 'larry,moe,curly'
.
I tried putting in parent.json
...
resources: [{
type: "Microsoft.Resources/deployments"
properties: {
...
parameters: {
bar: {
value: "[if(empty(parameters('foo')), json('null'), parameters('foo'))]"
}
}
}
}]
...
but it'll just give the same value is null. I know this can be done in AWS nested stacks using value aws::NoValue
but couldn't find any equivalent in azure. Would anyone know anything else to try?