Azure / Azure/azure-cli

Unclear docs and error message for --match-conditions format

Open
#29,010 8 comments 2 reactions 2 assignees Assigned to @necusjz View on GitHub
act-quality-productivity-squad Auto-Assign Azure CLI Team customer-reported Network question
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

**Related command**

```
az network application-gateway waf-policy custom-rule create \
--resource-group my-group \
--policy-name my-policy \
--name azuredevopsip \
--priority 10 \
--rule-type MatchRule \
--match-conditions '[{"variables": "RemoteAddr","operator":"IPMatch","values": ["'"$CURRENT_IP"'"]}]' \
--action Allow
```

**Is your feature request related to a problem? Please describe.**
When reading docs / looking at examples, I was not able to find any relevant information about how `--match-conditions` should be formatted.

When I ran this command I got the error `Failed to parse '--match-conditions' argument: Model 'AAZObjectArg' has no field named 'RemoteAddr'`

When running `--match-conditions` with `??` for docs it suggested `variables [Required] Space-separated list of variables to use when matching. Variable values: RemoteAddr, RequestMethod, QueryString, PostArgs, RequestUri, RequestHeaders, RequestBody, RequestCookies. Try "??" to show more.`.

Documentation on [azure-cli docs](https://learn.microsoft.com/en-us/cli/azure/network/application-gateway/waf-policy/custom-rule?view=azure-cli-latest) doesn't present any examples on `--match-conditions`.

Solution to this was to pass variables as an array of objects, where each key should have one of the values from `RemoteAddr, RequestMethod, QueryString, PostArgs, RequestUri, RequestHeaders, RequestBody, RequestCookie`.

Correct format:
```
--match-conditions '[{"variables":[{"variableName":"RemoteAddr"}],"operator":"IPMatch","values": ["'"$CURRENT_IP"'"]}]'
```

**Describe the solution you'd like**
The error message returned did not describe clear enough what the problem was, it suggested the variables key was not correct, but the docs referred to that it should be one of the `RemoteAddr, RequestMethod, QueryString, PostArgs, RequestUri, RequestHeaders, RequestBody, RequestCookie`.

**Describe alternatives you've considered**
Including example payloads of --match-conditions.

**Additional context**

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.