Azure / azure-cli

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

[AFD Classic] Can't disable URL rewrite for existing routing rule in Classic Azure Front Door #26791

Closed michasHL closed 1 month ago

michasHL commented 1 year ago

Describe the bug

I can use the azure cli command to update a routing rule with URL rewrite enabled and a custom forwarding path set. The Azure portal allows me disable the URL rewrite option. In the Azure CLI there is no corresponding option to disable the rewrite but to only set a different custom forwarding path. In the documentation found here it says the following:

--custom-forwarding-path
Custom path used to rewrite resource paths matched by this rule. Leave empty to use incoming path.

Not providing a value does not seem to work as there are multiple failure states.

Related command

az network front-door routing-rule update

Errors

argument --custom-forwarding-path: expected one argument

OR

(BadRequest) Property 'FrontdoorEntity.RoutingRules[0].Properties.RouteConfiguration.CustomForwardingPath' cannot be set to ''. Code: BadRequest Message: Property 'FrontdoorEntity.RoutingRules[0].Properties.RouteConfiguration.CustomForwardingPath' cannot be set to ''.

Issue script & Debug output

cli.knack.cli: Command arguments: ['network', 'front-door', 'routing-rule', 'update', '-f', 'xyz', '-g', 'xyz', '-n', 'xyz', '--custom-forwarding-path', '--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 0x01C4A418>, <function OutputProducer.on_global_arguments at 0x01D19BB0>, <function CLIQuery.on_global_arguments at 0x01D37808>] cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate [] cli.azure.cli.core: Modules found from index for 'network': ['azure.cli.command_modules.network', 'azure.cli.command_modules.privatedns', 'azext_front_door'] cli.azure.cli.core: Loading command modules: cli.azure.cli.core: Name Load Time Groups Commands cli.azure.cli.core: network 0.612 112 438 cli.azure.cli.core: privatedns 0.006 14 66 cli.azure.cli.core: Total (2) 0.618 126 504 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: front-door 0.047 19 76 C:\Users\xyz.azure\cliextensions\front-door cli.azure.cli.core: Total (1) 0.047 19 76 cli.azure.cli.core: Loaded 143 groups, 580 commands. cli.azure.cli.core: Found a match in the command table. cli.azure.cli.core: Raw command : network front-door routing-rule update cli.azure.cli.core: Command table: network front-door routing-rule update cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x03FFB340>] cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\xyz.azure\commands\2023-06-29.09-16-54.network_front-door_routing-rule_update.4140.log'. az_command_data_logger: command args: network front-door routing-rule update -f {} -g {} -n {} --custom-forwarding-path --debug cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x04024A48>] cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad [] cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x0404F970>, <function register_cache_arguments..add_cache_arguments at 0x0404FB68>] cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded [] cli.knack.cli: Event: CommandInvoker.OnPreParseArgs [] urllib3.connectionpool: Starting new HTTPS connection (1): app.aladdin.microsoft.com:443 urllib3.connectionpool: https://app.aladdin.microsoft.com:443 "GET /api/v1.0/suggestions?query=%7B%22command%22%3A+%22network+front-door+routing-rule+update%22%2C+%22parameters%22%3A+%22--front-door-name%2C--name%2C--resource-group%2C--custom-forwarding-path%22%7D&clientType=AzureCli&context=%7B%22versionNumber%22%3A+%222.49.0%22%2C+%22errorType%22%3A+%22ExpectedArgument%22%2C+%22correlationId%22%3A+%22dbbe3c98-d442-4658-8d16-251e2f5c38a4%22%2C+%22subscriptionId%22%3A+%22----------------------+%22eventId%22%3A+%22c3c97fe5-a036-43e1-b3a2-6fbe2352c3ac%22%7D HTTP/1.1" 200 None cli.azure.cli.core.azclierror: Traceback (most recent call last): File "argparse.py", line 1859, in parse_known_args File "argparse.py", line 2072, in _parse_known_args File "argparse.py", line 2002, in consume_optional File "argparse.py", line 2167, in _match_argument argparse.ArgumentError: argument --custom-forwarding-path: expected one argument

Expected behavior

The behavior would be to allow disabling the custom forwarding path by either passing in an empty string or by passing in $null in PowerShell

Environment Summary

azure-cli 2.49.0

core 2.49.0 telemetry 1.0.8

Extensions: aks-preview 0.5.145 containerapp 0.3.34 front-door 1.0.17

Dependencies: msal 1.20.0 azure-mgmt-resource 22.0.0

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

Python (Windows) 3.10.10 (tags/v3.10.10:aad5f6a, Feb 7 2023, 17:05:00) [MSC v.1929 32 bit (Intel)]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Additional context

No response

yonzhan commented 1 year ago

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

ghost commented 1 year ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @aznetsuppgithub.

Issue Details
### Describe the bug I can use the azure cli command to update a routing rule with URL rewrite enabled and a custom forwarding path set. The Azure portal allows me disable the URL rewrite option. In the Azure CLI there is no corresponding option to disable the rewrite but to only set a different custom forwarding path. In the documentation found [here](https://learn.microsoft.com/en-us/cli/azure/network/front-door/routing-rule?view=azure-cli-latest#az-network-front-door-routing-rule-update) it says the following: ``` --custom-forwarding-path Custom path used to rewrite resource paths matched by this rule. Leave empty to use incoming path. ``` Not providing a value does not seem to work as there are multiple failure states. ### Related command az network front-door routing-rule update ### Errors argument --custom-forwarding-path: expected one argument OR (BadRequest) Property 'FrontdoorEntity.RoutingRules[0].Properties.RouteConfiguration.CustomForwardingPath' cannot be set to ''. Code: BadRequest Message: Property 'FrontdoorEntity.RoutingRules[0].Properties.RouteConfiguration.CustomForwardingPath' cannot be set to ''. ### Issue script & Debug output cli.knack.cli: Command arguments: ['network', 'front-door', 'routing-rule', 'update', '-f', 'xyz', '-g', 'xyz', '-n', 'xyz', '--custom-forwarding-path', '--debug'] cli.knack.cli: __init__ debug log: Enable color in terminal. cli.knack.cli: Event: Cli.PreExecute [] cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [, , ] cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate [] cli.azure.cli.core: Modules found from index for 'network': ['azure.cli.command_modules.network', 'azure.cli.command_modules.privatedns', 'azext_front_door'] cli.azure.cli.core: Loading command modules: cli.azure.cli.core: Name Load Time Groups Commands cli.azure.cli.core: network 0.612 112 438 cli.azure.cli.core: privatedns 0.006 14 66 cli.azure.cli.core: Total (2) 0.618 126 504 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: front-door 0.047 19 76 C:\Users\xyz\.azure\cliextensions\front-door cli.azure.cli.core: Total (1) 0.047 19 76 cli.azure.cli.core: Loaded 143 groups, 580 commands. cli.azure.cli.core: Found a match in the command table. cli.azure.cli.core: Raw command : network front-door routing-rule update cli.azure.cli.core: Command table: network front-door routing-rule update cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [] cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\xyz\.azure\commands\2023-06-29.09-16-54.network_front-door_routing-rule_update.4140.log'. az_command_data_logger: command args: network front-door routing-rule update -f {} -g {} -n {} --custom-forwarding-path --debug cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [.add_subscription_parameter at 0x04024A48>] cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad [] cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [.add_ids_arguments at 0x0404F970>, .add_cache_arguments at 0x0404FB68>] cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded [] cli.knack.cli: Event: CommandInvoker.OnPreParseArgs [] urllib3.connectionpool: Starting new HTTPS connection (1): app.aladdin.microsoft.com:443 urllib3.connectionpool: https://app.aladdin.microsoft.com:443 "GET /api/v1.0/suggestions?query=%7B%22command%22%3A+%22network+front-door+routing-rule+update%22%2C+%22parameters%22%3A+%22--front-door-name%2C--name%2C--resource-group%2C--custom-forwarding-path%22%7D&clientType=AzureCli&context=%7B%22versionNumber%22%3A+%222.49.0%22%2C+%22errorType%22%3A+%22ExpectedArgument%22%2C+%22correlationId%22%3A+%22dbbe3c98-d442-4658-8d16-251e2f5c38a4%22%2C+%22subscriptionId%22%3A+%22----------------------+%22eventId%22%3A+%22c3c97fe5-a036-43e1-b3a2-6fbe2352c3ac%22%7D HTTP/1.1" 200 None cli.azure.cli.core.azclierror: Traceback (most recent call last): File "argparse.py", line 1859, in parse_known_args File "argparse.py", line 2072, in _parse_known_args File "argparse.py", line 2002, in consume_optional File "argparse.py", line 2167, in _match_argument argparse.ArgumentError: argument --custom-forwarding-path: expected one argument ### Expected behavior The behavior would be to allow disabling the custom forwarding path by either passing in an empty string or by passing in $null in PowerShell ### Environment Summary azure-cli 2.49.0 core 2.49.0 telemetry 1.0.8 Extensions: aks-preview 0.5.145 containerapp 0.3.34 front-door 1.0.17 Dependencies: msal 1.20.0 azure-mgmt-resource 22.0.0 Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe' Extensions directory 'C:\Users\xyz\.azure\cliextensions' Python (Windows) 3.10.10 (tags/v3.10.10:aad5f6a, Feb 7 2023, 17:05:00) [MSC v.1929 32 bit (Intel)] Legal docs and information: aka.ms/AzureCliLegal Your CLI is up-to-date. ### Additional context _No response_
Author: michasHL
Assignees: necusjz
Labels: `bug`, `Network`, `Service Attention`, `customer-reported`, `Auto-Assign`, `Azure CLI Team`
Milestone: Backlog
t-bzhan commented 3 months ago

Add @Ptnan7 to take a look.

microsoft-github-policy-service[bot] commented 3 months ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @aznetsuppgithub.

microsoft-github-policy-service[bot] commented 3 months ago

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

t-bzhan commented 3 months ago

It appears that the Azure Front Door service queried the customForwardingPath property to be set to null in order to disable the “URL Rewrite”. However, there seems to be a limitation in either the CLI or Python SDK that prevents emitting null to the service side. As a workaround, you can use the “Generic Update Arguments” to forcefully remove the property. image

The command would be as follows:

az network front-door routing-rule update --front-door-name cdn-sdk-test --name cdn-sdk-test -g cdn-sdk-test --remove routeConfiguration.customForwardingPath

@Ptnan7 , please engage with the CLI team to explore how we can fix this issue. If it is not possible to intuitively pass null to the service side, we could set the property to None in our CLI command when empty content is received, instead of passing it directly to the service side.