Closed Divyenth-K closed 3 years ago
Sorry, you can't have dynamic variable names like this in Bicep. For type safety, this is a good thing - if you change your variables a bit you can do something similar with:
@description('description')
param runTimeStack string = 'python'
@description('description')
param runTimeStackVersion string = '3.6'
@description('description')
param runTimeTomcatVersion string = 'jre8'
@description('description')
param webappName string
@description('description')
param OS string = 'Linux'
//empty if not java or tomcat
var suffix = (runTimeStack == 'java') || (runTimeStack == 'tomcat') ? '-java${runTimeTomcatVersion}' : ''
resource webApp 'Microsoft.Web/sites@2020-12-01' existing = {
name: webappName
}
resource webAppConfig 'Microsoft.Web/sites/config@2018-11-01' = {
name: 'web'
parent: webApp
properties: {
linuxFxVersion: (OS == 'Linux') ? '${toUpper(runTimeStack)}|${runTimeStackVersion}${suffix}': any(null)
}
}
Thanks @matsest. @Divyenth-K - let us know if this fix works for you.
Thanks this solution did work for me..
Bicep version Bicep version o.3.255
Desctiption:
i have a arm template that has has a piece of code that looks like
these variables are used to set the property to a resource
runTimeStack is a parameter in which can have values like python, ruby, etc. Based on the runtime stack the property is set using hte respective variable declared above.
Example:
If the runTimeStack is python and OS is linux then LinuxPython variable will property
"property" : LinuxPython This worked fine in my ARM templates.
I 'am trying to convert this arm template to bicep but this scenario does not seem to work in bicep
this is my code in bicep
here iam getting an error saying
"The property "properties" expected a value of type "object" but the provided value is of type "string"."
could u please help me convert this to bicep. Thanks!!