Azure / azure-cli

Azure Command-Line Interface
MIT License
3.99k stars 2.96k forks source link

az webapp create: unable to create web app under ASEv3 app service plan due to duplicate app name error #29083

Open mgillnorthgateps opened 4 months ago

mgillnorthgateps commented 4 months ago

Describe the bug

We are using Azure CLI (v2.61) to provision App Service Environment (v3) in UK South region.

After using Azure CLI to provision the ASE (with Zonal HA) and some app service plans on the ASE, we are running into difficulties creating app services/web apps within the plans on the ASE.

For example:

az webapp create \ --name chat \ --plan [app-service-plan-name] \ --resource-group [rg-name] \ --public-network-access Disabled \ --deployment-container-image-name mcr.microsoft.com/appsvc/staticsite:latest

Produces the error: Unable to retrieve details of the existing app 'chat'. Please check that the app is a part of the current subscription.

However seems to work through the portal.

Running Azure CLI command in debug mode, it seems to be failing when making the call:

https://management.azure.com:443 "POST /subscriptions/[subscription-id]/providers/Microsoft.Web/checknameavailability?api-version=2023-01-01 HTTP/1.1" 200 124

Which returns: {"nameAvailable":false,"reason":"AlreadyExists","message":"Hostname 'chat' already exists. Please select a different name."} cli.azure.cli.command_modules.appservice.custom: Webapp 'chat' already exists. The command will use the existing app's settings.

I would have thought due to the fact that the web app is needed on a plan under an ASEv3, that the web app name should be unique within the ASE as it's a dedicated environment e.g. chat.[ase-name].azurewebsites.net. However, it seems to be trying to check whether chat.azurewebsites.net is available.

Have tried the same command using a randomly generated app name that I don't expect already exists under azurewebsites.net and that works so the command syntax seem's to be okay.

Related command

az webapp create \ --name chat \ --plan [app-service-plan-name] \ --resource-group [rg-name] \ --public-network-access Disabled \ --deployment-container-image-name mcr.microsoft.com/appsvc/staticsite:latest

Errors

Unable to retrieve details of the existing app 'chat'. Please check that the app is a part of the current subscription.

Issue script & Debug output

Not available

Expected behavior

Would have expected web app to be created as should be unique name within isolated app service environment

Environment Summary

{ "azure-cli": "2.61.0", "azure-cli-core": "2.61.0", "azure-cli-telemetry": "1.1.0", "extensions": { "azure-firewall": "0.14.7", "bastion": "0.2.4", "ssh": "1.1.6" } }

Additional context

No response

yonzhan commented 4 months ago

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

madsd commented 3 months ago

I was looking into this issue, and it appears to be a general problem with the name "chat" and not related to CLI. I will also get errors when trying to create a web app with the name "chat" through portal or even a raw ARM request, but not until the request is submitted. Can you please validate. Since this is not a specific CLI problem, but a platform problem, I will need to ask you to create a support ticket to figure out why "chat" specifically is not allowed on the platform.

mgillnorthgateps commented 3 months ago

Thanks for the reply. I will check but am sure we tried through the portal and it allowed it to be created. Can you just confirm you could not create a web app with the name "chat" in an isolated ASEv3 in UK South region and not just a web app on its own without an isolated ASE ?

madsd commented 3 months ago

I tested both with Internal and External ASEv3 - though in a different region (Canada East), but that should not matter. I also checked in our database that there are no sites called chat in any ASE or multitenant stamp in any region. It may be a reserved name, but I do not have the context for that.

madsd commented 3 months ago

I looked more into the matter and App Service do have a list of brands and reserved names that are not allowed - "chat" happens to be one of them. I hope you can find an alternative name that works for you.

madsd commented 3 months ago

Turns out that there is a problem with CLI, but the name used to raise the bug was sending us in a wrong direction. As mentioned there is a list of disallowed words and brands such as "chat" and "api", but variations such as chatservice and restapi should be allowed. Webapp create/up CLI specifically has logic to check for existing names to reuse app settings, but this logic does not consider that apps on ASE only needs to be unique within the ASE. @seligj95 would you mind reassigning this to the webapp create/up team to fix it. @mgillnorthgateps until the team is able to push out a fix, you can use portal, ARM, Bicep to create apps with names that other customers may already have used. If you prefer CLI, you can also use az resource create

mgillnorthgateps commented 3 months ago

@madsd We got around it by trying different app service names until they worked!