[FEATURE REQ] Support objects in parameters.json file
See original GitHub issuePlease describe the feature or suggestion.
We are using quite a lot of objects in our parameters.json files to nicely combine several parameters, also described here, for example:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"infra": {
"value": {
"environment": {
"resourcePrefix": "dummy",
"resourceGroupName": "dummy"
}
}
}
}
}
We can then access that value from our Bicep file like this infra.environment.resourcePrefix
.
When running the Template Analyzer tool this does not seem to be supported as I run into these kind of errors:
The template variable 'appSettings' is not valid: The language expression property 'environment' doesn't exist, available properties are 'property1'..
.
It seems like using objects in the parameters file are not supported, or am I doing something wrong? Searched within the documentation and issues but couldn’t really find anything. Would be great if this could be supported!
Additional context
Entire error:
Warning: An exception occurred when processing the template language expressions
Exception details:
Azure.Deployments.Templates.Exceptions.TemplateValidationException: The template variable 'appSettings' is not valid: The language expression property 'environment' doesn't exist, available properties are 'property1'.. Please see https://aka.ms/arm-template-expressions for usage details.
---> Azure.Deployments.Core.Exceptions.ExpressionException: The language expression property 'environment' doesn't exist, available properties are 'property1'.
at Azure.Deployments.Expression.Expressions.FunctionExpression.SelectObjectProperty(JObject root, JToken token, TemplateErrorAdditionalInfo additionalInfo)
at Azure.Deployments.Expression.Expressions.FunctionExpression.SelectProperty(JToken root, JToken property, TemplateErrorAdditionalInfo additionalInfo)
at Azure.Deployments.Expression.Expressions.FunctionExpression.EvaluateExpression(ExpressionEvaluationContext context, TemplateErrorAdditionalInfo additionalInfo)
at Azure.Deployments.Expression.Expressions.FunctionExpression.<>c__DisplayClass23_0.<EvaluateParameters>b__0(LanguageExpression parameter)
at System.Array.ConvertAll[TInput,TOutput](TInput[] array, Converter`2 converter)
at Microsoft.WindowsAzure.ResourceStack.Common.Extensions.IEnumerableExtensions.SelectArray[TSource,TElement](TSource[] source, Converter`2 elementSelector)
at Azure.Deployments.Expression.Expressions.FunctionExpression.EvaluateParameters(ExpressionEvaluationContext context, TemplateErrorAdditionalInfo additionalInfo)
at Azure.Deployments.Expression.Expressions.FunctionExpression.EvaluateExpression(ExpressionEvaluationContext context, TemplateErrorAdditionalInfo additionalInfo)
at Azure.Deployments.Expression.Engines.ExpressionsEngine.EvaluateLanguageExpressionsInternal(JToken root, ExpressionEvaluationContext evaluationContext, Boolean ignoreExceptions, TemplateErrorAdditionalInfo additionalInfo, InsensitiveHashSet skipEvaluationPaths)
at Azure.Deployments.Expression.Engines.ExpressionsEngine.EvaluateLanguageExpressionsRecursive(JToken root, ExpressionEvaluationContext evaluationContext, TemplateErrorAdditionalInfo additionalInfo, InsensitiveHashSet skipEvaluationPaths)
at Azure.Deployments.Templates.Engines.TemplatePreprocessingEngine.ProcessTemplateVariableLanguageExpressionsRecursive(Template template, String variableName, InsensitiveDictionary`1 recursionState, ExpressionEvaluationContext evaluationContext, TemplateErrorAdditionalInfo additionalInfo)
--- End of inner exception stack trace ---
at Azure.Deployments.Templates.Engines.TemplatePreprocessingEngine.ProcessTemplateVariableLanguageExpressionsRecursive(Template template, String variableName, InsensitiveDictionary`1 recursionState, ExpressionEvaluationContext evaluationContext, TemplateErrorAdditionalInfo additionalInfo)
at Azure.Deployments.Templates.Engines.TemplatePreprocessingEngine.ProcessTemplateVariablesLanguageExpressions(Template template, String apiVersion, InsensitiveDictionary`1 functionEvaluationOverwrites)
at Azure.Deployments.Templates.Engines.TemplatePreprocessingEngine.ProcessTemplateLanguageExpressions(String managementGroupName, String subscriptionId, String resourceGroupName, Template template, String apiVersion, InsensitiveDictionary`1 functionEvaluationOverwrites)
at Azure.Deployments.Templates.Engines.TemplateEngine.ProcessTemplateLanguageExpressions(String managementGroupName, String subscriptionId, String resourceGroupName, Template template, String apiVersion, InsensitiveDictionary`1 functionEvaluationOverwrites)
at Microsoft.Azure.Templates.Analyzer.TemplateProcessor.ArmTemplateProcessor.ParseAndValidateTemplate(InsensitiveDictionary`1 parameters, InsensitiveDictionary`1 metadata) in C:\temp\template-analyzer-0.3.1\src\Analyzer.TemplateProcessor\ArmTemplateProcessor.cs:line 131
Warning: An exception occurred while evaluating the properties of a resource.
Issue Analytics
- State:
- Created a year ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Feature Request - "partial" parameters file support #3274
This would allow for doing things like having a base template (shared publicly), and a default set of parameters that you use locally...
Read more >Add 'Json' export type support (Export pester object - ...
It would be great to have a way to export the PesterObject in a standard way to pesist it to a file. The...
Read more >ARM template best practices - Resource Manager
Describes recommended approaches for authoring Azure Resource Manager templates (ARM templates). Offers suggestions to avoid common problems ...
Read more >Create parameters files for Bicep deployment - Azure
bicepparam file extension or a JSON parameters file that contains the parameter values. This article shows how to create parameters files. Note.
Read more >JSON:API — Latest Specification (v1.1)
The JSON:API specification supports two media type parameters: ext and profile , which are used to specify extensions and profiles, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am indeed using a separate parameters json file. @VeraBE here is an example of a bicep file and a separate parameters json file causing the issue:
When I use the
TemplateAnalyzer.exe analyze-directory
command this fails with the errorThe language expression property 'environment' doesn't exist, available properties are 'property1'..
. When I use theTemplateAnalyzer.exe analyze-template
with the-p
command then it works fine indeed 👍🏻:@JohnathonMohr thanks for the workaround!! Is the auto-discovery of parameters when analyzing a directory on the roadmap?
I believe the issue is when a template doesn’t define a default value for the object. The value used during analysis is a mocked object, which will not have the expected properties during template expansion, and fail to parse.