Azure / Azure/template-analyzer

[FEATURE REQ] Support objects in parameters.json file

Open
#296 8 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C#
Stars
143
Forks
47
PR merge metrics
No merged PRs in 30d

Description

### Please 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](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/parameter-files#parameter-type-formats), for example:
``` json
{
"$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.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.
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.