Open slavizh opened 3 years ago
Repro for triage:
works:
var stringArray = [ './policies/policy_1.json' ] var policies = [for i in range(0, length(stringArray)): json(loadTextContent(stringArray[i]))]
doesn't work:
var stringArray = [ './policies/policy_1.json' './policies/policy_2.json' ] var policies = [for i in range(0, length(stringArray)): json(loadTextContent(stringArray[i]))]
The currently supported way for making this work involves duplicating loadTextContent
calls which gets annoying if additional logic is needed like in #10112. This violates Goal-4 i.e. "Code re-use should not require any 'copy/paste'-ing".
P.S: my workaround for this issue is generating a .bicep file before compilation which isn't ideal but gets the job done - Example: https://gist.github.com/nayanshah/7c86cfe6c9882c9e8133cee6ce17c9bb
Any update on this?
I'd love to be able to do:
value: loadTextContent('policies/${environmentName}.xml')
+3 .. really Microsoft, fix this.
Almost can't believe I ran into this limitation. It's really a bugger, because this means redundancy in my Bicep modules. Bicepparam is also not working for my use-case.
The use-case based upon Microsoft his own example for Azure Search setup, found here: https://github.com/Azure-Samples/azure-search-deployment-template/blob/main/bicep/setup-search-service.bicep (row 50)
+1 seriously? this is a deal breaking limitation
Is your feature request related to a problem? Please describe.
I would like for loadTextContent() to support variable or parameter as input parameter. What I would like to offer is for the end user to specify text from file or to use the default file available. Currently if I use the below syntax I get error: The value must be a compile-time constant.bicep(BCP032)
I know that function is being used at compile time so this will probably require some other approach and even changes in template spec for supporting it there as well.