I'm trying to use the lower() function in a YAML template, but do not understand the behavior. I've a variable group named Infra.Environment.ShortName with the value "Dev". In my YAML template, I've defined a variable from a variable group:
variables:
- name: environmentShortName
value: $(Infra.Environment.ShortName)
In a task, I refer to this variable:
- task: AzureResourceGroupDeployment@2
displayName: 'Deploy Storage Account'
inputs:
azureSubscription: ${{ parameters.subscription }}
resourceGroupName: mst-${{ lower(variables.environmentShortName) }}-infra
location: '$(Infra.Environment.Region.Primary)'
csmFile: '$(Pipeline.Workspace)/$(Build.DefinitionName)/Resources/infra-storageAccount.json'
csmParametersFile: '$(Pipeline.Workspace)/$(Build.DefinitionName)/Resources/infra-storageAccount.parameters.json'
deploymentOutputs: ArmOutputs
I've experimented with different expressions, but do not understand why I cannot convert the variable group value to lowercase:
resourceGroupName: mst-${{ lower(variables.environmentShortName) }}-infra
=> mst-Dev-infra (lower does not seem to work)
resourceGroupName: ${{ format('mst-{0}-infra', lower(variables.environmentShortName)) }}
=> mst-Dev-infra (format works, but lower does not)
resourceGroupName: $[format('mst-{0}-infra', lower(variables.environmentShortName))]
=> $[format('mst-{0}-infra', lower(variables.environmentShortName))] (expression not evaluated)
resourceGroupName: mst-${{ lower(variables['Infra.Environment.ShortName']) }}-infra
=> mst--infra (empty value)
resourceGroupName: mst-${{ lower('Dev') }}-infra
=> mst-dev-infra (lower works with a constant value)