Closed ecuaryan closed 3 years ago
Hi,
Thanks for the response.
If i follow your link I see this: [image: image.png]
I understand if in the ARM output it is doing that, but wouldn't that be a bug considering ^^?
Thanks, Ryan Willmore
On Thu, Mar 18, 2021 at 2:46 AM Steve Webster @.***> wrote:
You can't use the reference function in ARM variable declarations
See here https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-variables?tabs=json#define-variable for an explanation
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Azure/bicep/issues/1917#issuecomment-801742363, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACHPZDPNY5ZSQNRGN2QLYH3TEG4UVANCNFSM4ZLNU3FQ .
You are getting the error because the array functionOptions
that you are using for the loop is using the reference()
function which is not allowed. We happen to be missing it in our type system because you are using the reference()
function directly, which we do not recommend. You can (and should) change your mainAppSetings
var to the following and then we will catch the error:
var mainAppSettings = [
{
name: 'APPINSIGHTS_INSTRUMENTATIONKEY'
value: applicationInsights.properties.InstrumentationKey
}
{
name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
value: 'InstrumentationKey=${applicationInsights.properties.InstrumentationKey}'
}
]
This then correctly catches the error:
Is there an alternative you can use for the loop array that does not depend on a runtime property?
Thanks for the response. Here's how I was able to get things working before I opened this issue:
I was hoping to not have to maintain relationships between resources via ordering in their own arrays by grouping the related resources/values together in an array of wrapper objects and then iterating over that array. Seems as though I'll have to stick with the former though.
Thanks again!
Closing and tracking with #1988
Bicep version Bicep CLI version 0.3.1
Describe the bug I receive the error "The template function 'reference' is not expected at this location." when expecting it to not error out. See below for more details.
To Reproduce Run the following commands using the files defined below:
Comment/uncomment the code towards the bottom of the
root-template.bicep
file to use the code that will work vs the code that doesn't but is expected to.Additional context The main thing to look at is the
mainAppSettings
and how it is being used. Tried to boil this down to the basics to easily reproduce. Let me know if a loom or anything else would be helpful.