-
Notifications
You must be signed in to change notification settings - Fork 52
Labels
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest version
- Search the existing issues.
Summary
I'm trying to reference a property using dot notation dynamically.
Here is a post on a similar issue but the suggestion syntax doesn't work for DSC.
https://stackoverflow.com/questions/43928235/using-arm-parameters-to-select-field-in-object-variable
Steps to reproduce
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
parameters:
id:
type: string
description: The key to use in config
defaultValue: test
variables:
config:
prod: prod config
test: test config
resources:
- type: Microsoft.DSC.Debug/Echo
name: test
properties:
output: "[variables('config').[parameters('id')]"
Static reference works as expected
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
parameters:
id:
type: string
description: The key to use in config
defaultValue: test
variables:
config:
prod: prod config
test: test config
resources:
- type: Microsoft.DSC.Debug/Echo
name: test
properties:
output: "[variables('config').test]"
Expected behavior
Dynamic dot notation works
Actual behavior
Parser errror
Error details
2025-10-13T15:24:45.793681Z DEBUG dsc::subcommand: 337: No parameters specified
2025-10-13T15:24:45.793811Z DEBUG dsc_lib::configure: 823: Processing parameter 'id'
2025-10-13T15:24:45.793911Z DEBUG dsc_lib::configure: 825: Set default parameter 'id'
2025-10-13T15:24:45.794006Z DEBUG dsc_lib::parser: 48: Parsing statement: test
2025-10-13T15:24:45.794113Z DEBUG dsc_lib::parser: 77: Parsing string literal: test
2025-10-13T15:24:45.794204Z INFO dsc_lib::configure: 875: Set variable 'config' to '{"prod":"I'm a prod config","test":"I'm a test config"}'
2025-10-13T15:24:45.794301Z DEBUG dsc_lib::configure::depends_on: 27: Getting resource invocation order
2025-10-13T15:24:45.794386Z DEBUG dsc_lib::configure::depends_on: 90: Resource invocation order: [Resource { condition: None, resource_type: "Microsoft.DSC.Debug/Echo", api_version: None, name: "test", comments: None, location: None, depends_on: None, tags: None, identity: None, sku: None, kind: None, scope: None, copy: None, plan: None, properties: Some({"output": String("[variables('config').[parameters('id')]")}), resources: None, metadata: None }]
2025-10-13T15:24:45.794560Z DEBUG dsc_lib::parser: 48: Parsing statement: test
2025-10-13T15:24:45.794683Z DEBUG dsc_lib::parser: 77: Parsing string literal: test
2025-10-13T15:24:45.795069Z DEBUG dsc_lib::configure: 1018: Invoke property expressions
2025-10-13T15:24:45.795247Z TRACE dsc_lib::configure: 1026: Invoke property expression for output: "[variables('config').[parameters('id')]"
2025-10-13T15:24:45.795418Z DEBUG dsc_lib::parser: 48: Parsing statement: [variables('config').[parameters('id')]
2025-10-13T15:24:45.795623Z DEBUG dsc_lib::parser: 89: Parsing expression
2025-10-13T15:24:45.795831Z DEBUG dsc_lib::parser::expressions: 44: Parsing function '{Node function (0, 1) - (0, 20)}'
2025-10-13T15:24:45.796010Z DEBUG dsc_lib::parser::functions: 57: Function name: 'variables'
2025-10-13T15:24:45.796190Z DEBUG dsc_lib::parser::expressions: 48: Parsing accessor '{Node accessor (0, 21) - (0, 39)}'
2025-10-13T15:24:45.796378Z DEBUG dsc_lib::parser::expressions: 68: Parsing index accessor '{Node index (0, 21) - (0, 39)}'
2025-10-13T15:24:45.796578Z DEBUG dsc_lib::parser::expressions: 44: Parsing function '{Node function (0, 22) - (0, 38)}'
2025-10-13T15:24:45.796772Z DEBUG dsc_lib::parser::functions: 57: Function name: 'parameters'
2025-10-13T15:24:45.797012Z DEBUG dsc_lib::parser::functions: 80: Argument is a value: 'String("config")'
2025-10-13T15:24:45.797289Z DEBUG dsc_lib::functions::variables: 35: variables function
2025-10-13T15:24:45.797532Z TRACE dsc_lib::parser::expressions: 119: Function results: {"prod":"I'm a prod config","test":"I'm a test config"}
2025-10-13T15:24:45.797758Z DEBUG dsc_lib::parser::expressions: 127: Evaluating accessors
2025-10-13T15:24:45.798052Z DEBUG dsc_lib::parser::functions: 80: Argument is a value: 'String("id")'
2025-10-13T15:24:45.798285Z DEBUG dsc_lib::functions::parameters: 31: parameters function
2025-10-13T15:24:45.798541Z TRACE dsc_lib::functions::parameters: 33: parameters key: id
2025-10-13T15:24:45.798879Z TRACE dsc_lib::parser::expressions: 119: Function results: "test"
2025-10-13T15:24:45.799153Z TRACE dsc_lib::parser::expressions: 167: Expression result: %{result}
2025-10-13T15:24:45.799716Z ERROR dsc::subcommand: 76: Parser: Invalid index type
Environment data
7.6-preview4
Version
dsc 3.2.0-preview.6
Visuals
No response