Skip to content

"--cache-duration" on "az afd rule create" not working as expected #4635

Closed
@dennisjnnh

Description

@dennisjnnh

Type of issue

Code doesn't work

Feedback

I tried executing this command:
az afd rule create --resource-group xxxxxx --profile-name xxxxxxx --rule-set-name xxxxxxx --name xxxxxx --order 1 --match-processing-behavior Continue --match-variable RequestUri --operator BeginsWith --match-values 'xxxxxxxx' --negate-condition false --action-name RouteConfigurationOverride --cache-behavior OverrideAlways --cache-duration '365.23:59:59' --enable-compression true --query-string-caching-behavior IgnoreQueryString --origin-group '/subscriptions/xxxxxxx/resourcegroups/rg-ledger-germanywest-prod/providers/Microsoft.Cdn/profiles/frontdoor-xxxxxxx/origingroups/xxxxxxx' --forwarding-protocol MatchRequest

According to the docs, --cache-duration is in the valid format ([d.]hh:mm:ss)
Still, the following error is printed:

InvalidArgumentValue: --cache-duration: Unable to parse: '365.23:59:59'. Expected format: Format: time (hh:mm:ss.xxxxxx)

Page URL

https://learn.microsoft.com/en-us/cli/azure/afd/rule?view=azure-cli-latest

Content source URL

https://github.com/MicrosoftDocs/azure-docs-cli/blob/main/latest/docs-ref-autogen/afd/rule.yml

Author

@dbradish-microsoft

Document Id

d4e72781-eadc-1f91-46cc-f8f40bb0d7ae

Activity

ManoharLakkoju-MSFT

ManoharLakkoju-MSFT commented on Sep 24, 2024

@ManoharLakkoju-MSFT

@umuel8462
Thanks for your feedback! We will investigate and update as appropriate.

dbradish-microsoft

dbradish-microsoft commented on Sep 24, 2024

@dbradish-microsoft
Collaborator

@umuel8462, the invalid argument error is often due to quoting, an escape character or spacing. Read more about the causes and possible remediations for this error in the Azure CLI troubleshooting guide.

Can you kindly answer two questions?

  1. Are you running the Azure CLI in Bash or PowerShell?
  2. Please rerun the command adding the --debug parameter, and send me the output. This will help me to understand how your environment (aka scripting language) is parsing the Azure CLI command.

In the interim, I've opened a GitHub issue for the ML engineering team. You can see that here: Github issue 29970.

dennisjnnh

dennisjnnh commented on Sep 26, 2024

@dennisjnnh
Author

@umuel8462, the invalid argument error is often due to quoting, an escape character or spacing. Read more about the causes and possible remediations for this error in the Azure CLI troubleshooting guide.

Can you kindly answer two questions?

  1. Are you running the Azure CLI in Bash or PowerShell?
  2. Please rerun the command adding the --debug parameter, and send me the output. This will help me to understand how your environment (aka scripting language) is parsing the Azure CLI command.

In the interim, I've opened a GitHub issue for the ML engineering team. You can see that here: Github issue 29970.

Hi @dbradish-microsoft,
I am running the CLI in Bash on my mac.

here is the output with the --debug parameter:

cli.knack.cli: Command arguments: ['afd', 'rule', 'create', '--resource-group', 'xxxxxxx', '--profile-name', 'xxxxxxx', '--rule-set-name', 'xxxxx', '--name', 'xxxxxx', '--order', '1', '--match-processing-behavior', 'Continue', '--match-variable', 'RequestUri', '--operator', 'BeginsWith', '--match-values', 'xxxxxxxxx', '--negate-condition', 'false', '--action-name', 'RouteConfigurationOverride', '--cache-behavior', 'OverrideAlways', '--cache-duration', '365.23:59:59', '--enable-compression', 'true', '--query-string-caching-behavior', 'IgnoreQueryString', '--origin-group', 'xxxxxxxxxxxx', '--forwarding-protocol', 'MatchRequest', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x10073f2e0>, <function OutputProducer.on_global_arguments at 0x100f70680>, <function CLIQuery.on_global_arguments at 0x100f92160>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'afd': ['azure.cli.command_modules.cdn']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name                  Load Time    Groups  Commands
cli.azure.cli.core: cdn                       0.168        21        58
cli.azure.cli.core: Total (1)                 0.168        21        58
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name                  Load Time    Groups  Commands  Directory
cli.azure.cli.core: Total (0)                 0.000         0         0  
cli.azure.cli.core: Loaded 21 groups, 58 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command  : afd rule create
cli.azure.cli.core: Command table: afd rule create
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x101c8a520>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/Users/xxxxx/.azure/commands/2024-09-26.20-26-43.afd_rule_create.35460.log'.
az_command_data_logger: command args: afd rule create --resource-group {} --profile-name {} --rule-set-name {} --name {} --order {} --match-processing-behavior {} --match-variable {} --operator {} --match-values {} --negate-condition {} --action-name {} --cache-behavior {} --cache-duration {} --enable-compression {} --query-string-caching-behavior {} --origin-group {} --forwarding-protocol {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x101cbbf60>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x101cdf560>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x101cdf6a0>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.azure.cli.core.util: invalid syntax (<unknown>, line 1)
cli.azure.cli.core.aaz._arg_action: Failed to parse string as JSON:
https://xxxxxxx.com/
Error detail: Expecting value: line 1 column 1 (char 0)
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x100f70720>, <function CLIQuery.handle_query_parameter at 0x100f92200>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x101cdf600>]
cli.azure.cli.core.azclierror: Traceback (most recent call last):
  File "/opt/homebrew/Cellar/azure-cli/2.63.0/libexec/lib/python3.11/site-packages/azure/cli/core/aaz/_command_ctx.py", line 53, in format_args
    self.args._schema._fmt(ctx=self, value=self.args)
  File "/opt/homebrew/Cellar/azure-cli/2.63.0/libexec/lib/python3.11/site-packages/azure/cli/core/aaz/_arg_fmt.py", line 402, in __call__
    raise err from err
  File "/opt/homebrew/Cellar/azure-cli/2.63.0/libexec/lib/python3.11/site-packages/azure/cli/core/aaz/_arg_fmt.py", line 399, in __call__
    value[field_name] = field_schema._fmt(ctx, value[field_name])
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.63.0/libexec/lib/python3.11/site-packages/azure/cli/core/aaz/_arg_fmt.py", line 152, in __call__
    raise AAZInvalidArgValueError(
azure.cli.core.aaz.exceptions.AAZInvalidArgValueError: InvalidArgumentValue: --cache-duration: Unable to parse: '365.23:59:59'. Expected format: Format: time (hh:mm:ss.xxxxxx)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Cellar/azure-cli/2.63.0/libexec/lib/python3.11/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.63.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 664, in execute
    raise ex
  File "/opt/homebrew/Cellar/azure-cli/2.63.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 731, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.63.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 701, in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.63.0/libexec/lib/python3.11/site-packages/azure/cli/core/aaz/_command.py", line 155, in __call__
    return self._handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.63.0/libexec/lib/python3.11/site-packages/azure/cli/command_modules/cdn/aaz/latest/afd/rule/_create.py", line 37, in _handler
    super()._handler(command_args)
  File "/opt/homebrew/Cellar/azure-cli/2.63.0/libexec/lib/python3.11/site-packages/azure/cli/core/aaz/_command.py", line 165, in _handler
    self.ctx.format_args()
  File "/opt/homebrew/Cellar/azure-cli/2.63.0/libexec/lib/python3.11/site-packages/azure/cli/core/aaz/_command_ctx.py", line 55, in format_args
    raise InvalidArgumentValueError(str(err))
azure.cli.core.azclierror.InvalidArgumentValueError: InvalidArgumentValue: --cache-duration: Unable to parse: '365.23:59:59'. Expected format: Format: time (hh:mm:ss.xxxxxx)

cli.azure.cli.core.azclierror: InvalidArgumentValue: --cache-duration: Unable to parse: '365.23:59:59'. Expected format: Format: time (hh:mm:ss.xxxxxx)
az_command_data_logger: InvalidArgumentValue: --cache-duration: Unable to parse: '365.23:59:59'. Expected format: Format: time (hh:mm:ss.xxxxxx)
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x101c8a7a0>]
az_command_data_logger: exit code: 1
cli.__main__: Command ran in 0.325 seconds (init: 0.113, invoke: 0.212)
telemetry.main: Begin splitting cli events and extra events, total events: 1
telemetry.client: Accumulated 0 events. Flush the clients.
telemetry.main: Finish splitting cli events and extra events, cli events: 1
telemetry.save: Save telemetry record of length 4183 in cache
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "/opt/homebrew/Cellar/azure-cli/2.63.0/libexec/bin/python /opt/homebrew/Cellar/azure-cli/2.63.0/libexec/lib/python3.11/site-packages/azure/cli/telemetry/__init__.py /Users/xxxxxxxxxx/.azure"
telemetry.process: Return from creating process
telemetry.main: Finish creating telemetry upload process.
dbradish-microsoft

dbradish-microsoft commented on Oct 9, 2024

@dbradish-microsoft
Collaborator

Hello, @umuel8462 , I've heard back from the engineering team, and the correct format for the --cache-duration is hh:mm:ss.xxxxxx. Because of your feedback, the documentation has been updated in PR 29977, and the correction will be seen in the next Azure CLI release. Thank you for helping to make Azure CLI reference content more accurate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @dbradish-microsoft@dennisjnnh@ManoharLakkoju-MSFT

      Issue actions

        "--cache-duration" on "az afd rule create" not working as expected · Issue #4635 · MicrosoftDocs/azure-docs-cli