Azure / azure-cli

Azure Command-Line Interface
MIT License
4.01k stars 2.98k forks source link

az afd rule create fails with valiation message #30142

Open utillity opened 1 week ago

utillity commented 1 week ago

Describe the bug

I am creating a rule:

  az afd rule create --rule-name "RedirectToSPA" --order 1 \
    -g "$tcResGroup" --profile-name "$profName" --rule-set-name "$spaRuleset" \
    --match-variable UrlPath --operator RegEx --negate-condition true \
    --match-values "\\.(svg|js|css|png|jpg|jpeg|json|woff|woff2|ttf|html)" \
    --action-name "UrlRewrite" --source-pattern '/' --destination '/web-client/index.html' --preserve-unmatched-path 0 \
    --match-processing-behavior "Continue"

Related command

az afd rule create

Errors

(BadRequest) SourcePattern must always start with \'/\' and be a single line. The max length of Destination is 260. or (BadRequest) Destination must always start with \'/\' and be a single line. The max length of Destination is 260.

Issue script & Debug output

Parts of my bash script:

  az afd rule create --rule-name "RedirectToSPA" --order 1 \
    -g "$tcResGroup" --profile-name "$profName" --rule-set-name "$spaRuleset" \
    --match-variable UrlPath --operator RegEx --negate-condition true \
    --match-values "\\.(svg|js|css|png|jpg|jpeg|json|woff|woff2|ttf|html)" \
    --action-name "UrlRewrite" --source-pattern '/' --destination '/web-client/index.html' --preserve-unmatched-path 0 \
    --match-processing-behavior "Continue"

Debug output shows the issue:

cli.knack.cli: Command arguments: ['afd', 'rule', 'create', '--rule-name', 'RedirectToSPA', '--order', '1', '-g', 'cree-dev-toolchain-01', '--profile-name', 'cree-toolchain-dev', '--rule-set-name', 'SPArules', '--match-variable', 'UrlFileExtension', '--operator', 'RegEx', '--negate-condition', 'true', '--match-values', '\\\\.(svg|js|css|png|jpg|jpeg|json|woff|woff2|ttf|html)', '--action-name', 'UrlRewrite', '--source-pattern', 'C:/Program Files/Git/', '--destination', 'C:/Program Files/Git/web-client/index.html', '--preserve-unmatched-path', '0', '--match-processing-behavior', 'Continue', '--debug']

for some reason my parameters are expanded to a path, if they begin with a /.

Expected behavior

I expect the parameters to not be expanded into a path. I tried everything on my end to prohibit expansion (set -f, single quoting)

Environment Summary

$ az --version azure-cli 2.65.0

core 2.65.0 telemetry 1.1.0

Dependencies: msal 1.31.0 azure-mgmt-resource 23.1.1

Python location 'C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe' Extensions directory 'C:\Users\utillity.azure\cliextensions'

Python (Windows) 3.11.8 (tags/v3.11.8:db85d51, Feb 6 2024, 22:03:32) [MSC v.1937 64 bit (AMD64)]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Additional context

No response

yonzhan commented 1 week ago

Thank you for opening this issue, we will look into it.

microsoft-github-policy-service[bot] commented 1 week ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @cdnfdsuppgithub, @t-bzhan, @gxue, @TracyYaoYao.