Azure / Azure/azure-cli

Child field reference question in az cli --set using powershell

Open
#16,043 2 comments 0 reactions 1 assignee Claimed by @kairu-ms View on GitHub
act-observability-squad feature-request Monitor UsageProblem
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### Question:
Does anyone know how to reference a nested field in a child object of an array?

For example, I'm using the 'update --set' command with az cli and I'd like to select the rule entity with a color of Red.
**Given**:
```
{
"profiles": [
{
"name": "default",
"rules": [
{
"action": {
"color": "Green",
"enabled": false
}
},
{
"action": {
"color": "Red",
"enabled": false
}
}
]
}
]
},...
```

`az monitor autoscale update -n n1 -g g1 --set profiles[name=default].rules[action.color=Red].enabled=true`

The above command will just fail with a message along the lines of:
**_"item with value 'Red' doesn't exist for key 'action.color' on [action.color=Red]"_**

I believe that the syntax is having an issue with the 'action.color' by using a nested child field in the search comparison. Is there a different way to reference that child field? I don't think that this is using JMESPath under the hood so I'm not sure how to specify the match in a different manner.

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.