Azure / azure-cli

Azure Command-Line Interface
MIT License
4.03k stars 3.01k forks source link

"az webapp traffic-routing set" does not set the correct actionHostName based on truncation rules. #26285

Open stevematney opened 1 year ago

stevematney commented 1 year ago

Related command

az webapp traffic-routing set \
            --resource-group MyResourceGroup \
            --name this-app-service-has-a-name-that-is-too-long  \
            --distribution predeploy=0

Describe the bug When running the traffic-routing set command, the actionHostName parameter is set incorrectly, resulting in a 404 when routing via x-ms-routing-name. When running the command above, the result will be:

[
  {
    "actionHostName": "this-app-service-has-a-name-that-is-too-long-predeploy.azurewebsites.net",
    "changeDecisionCallbackUrl": null,
    "changeIntervalInMinutes": null,
    "changeStep": null,
    "maxReroutePercentage": null,
    "minReroutePercentage": null,
    "name": "predeploy",
    "reroutePercentage": 0.0
  }
]

Based on the last paragraph of this documentation section, the real host name for the slot will be truncated. Trying to route to that slot with https://this-app-service-has-a-name-that-is-too-long.azurewebsites.net/?x-ms-routing-name=predeploy will return a 404 because the actionHostName does not exist in Azure's network.

If setting the routing through the portal, we would see that the host name gets set correctly:

[
  {
    "actionHostName": "this-app-service-has-a-name-that-is-too--predeploy.azurewebsites.net",
    "changeDecisionCallbackUrl": null,
    "changeIntervalInMinutes": null,
    "changeStep": null,
    "maxReroutePercentage": null,
    "minReroutePercentage": null,
    "name": "predeploy",
    "reroutePercentage": 0.0
  }
]

After this configuration change via the portal, routing to https://this-app-service-has-a-name-that-is-too-long.azurewebsites.net/?x-ms-routing-name=predeploy will work correctly.

To Reproduce Run the az webapp traffic-routing set command with a slot and an App Service whose hostname is >40 characters.

Expected behavior The traffic would be appropriately routed to the correct hostname for the target slot.

Environment summary

OS: MacOS Ventura 13.3.1 CLI:

azure-cli                         2.48.1

core                              2.48.1
telemetry                          1.0.8

Extensions:
account                            0.2.5

Dependencies:
msal                              1.20.0
azure-mgmt-resource               22.0.0

Python (Darwin) 3.10.11 (main, Apr  7 2023, 07:31:31) [Clang 14.0.0 (clang-1400.0.29.202)]

Shell: zsh

yonzhan commented 1 year ago

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

stevematney commented 3 weeks ago

Hey all! I know this is somewhere on the radar, but I just wanted to let you know that someone else from our org ran into this today. It prevents routing to slots with x-ms-routing-name from working, even though everything appears to be configured correctly. It's only when using something like az webapp traffic-routing show and looking very carefully at the actionHostName that you see the actual problem: your routing configuration is pointing to a non-existent domain.