Azure Web App Naming Convention and Hostname Behavior.

Naik, Anilkumar 0 Reputation points
2026-08-16T02:11:27.2233333+00:00

Previously, when creating an Azure Web App, the default hostname was generated in the following format:

test.azurewebsites.net

However, nowadays, to help prevent subdomain takeover attacks, Azure may generate the hostname with an additional hash and region, for example:

test-<hash>.<location>.azurewebsites.net

I noticed an interesting behavior while testing this:

When I tried to create a Web App with the name webapp, Azure showed that the name was not available. However, it did not suggest or append a hash suffix.

When I tried to create a Web App with the name webapptest, Azure automatically generated a hostname with a suffix and showed the name as available.

I would like to understand the logic behind this behavior.

Questions:

What determines whether Azure uses the traditional name.azurewebsites.net format versus the new name-<hash>.<location>.azurewebsites.net format?

Why does Azure add the suffix for some available names but not for others?

Is the suffix related to the availability of the original *.azurewebsites.net hostname, or is there another internal rule/algorithm that determines when it is applied?

  1. Is there any Microsoft documentation that explains the logic behind this hostname generation?Previously, when creating an Azure Web App, the default hostname was generated in the following format: test.azurewebsites.net However, nowadays, to help prevent subdomain takeover attacks, Azure may generate the hostname with an additional hash and region, for example: test-<hash>.<location>.azurewebsites.net I noticed an interesting behavior while testing this:
    • When I tried to create a Web App with the name webapp, Azure showed that the name was not available. However, it did not suggest or append a hash suffix.
    • When I tried to create a Web App with the name webapptest, Azure automatically generated a hostname with a suffix and showed the name as available.
    I would like to understand the logic behind this behavior. Questions:
    1. What determines whether Azure uses the traditional name.azurewebsites.net format versus the new name-<hash>.<location>.azurewebsites.net format?
    2. Why does Azure add the suffix for some available names but not for others?
    3. Is the suffix related to the availability of the original *.azurewebsites.net hostname, or is there another internal rule/algorithm that determines when it is applied?
    4. Is there any Microsoft documentation that explains the logic behind this hostname generation?
Azure App Service
Azure App Service

Azure App Service is a service used to create and deploy scalable, mission-critical web apps.

0 comments No comments

Answer recommended by moderator
TP 163.1K Reputation points Volunteer Moderator
2026-08-18T02:36:34.9266667+00:00

Hi Anilkumar,

Current versions of Azure portal Create Web App wizard always use Secure Unique Default Hostname with TenantReuse option. The important thing to understand is the name you enter must be unique for the region you select. In other words, the name (not including hash) must not currently be in use in that region.

If the name you enter is already in use, you will see error similar to "The app name <name> is not available in <region>" or "The app name <name> is not available" and no hash will be displayed. Obviously the first version of the error text is more clear, but both versions of the text mean that the name is already taken in that region. Please see screenshot below:

User's image

To illustrate let's walk through example:

  1. Someone creates a Web App named "contoso" with Secure Unique Default Hostname in West US, via portal, which results in auto-generated URL of contoso-eh7dcgxrmdkpw9xz-westus-01.azurewebsites.net
  2. Another person (different tenant than #1) attempts to create Web App named "contoso" with Secure Unique Default Hostname in West US, via portal, but gets "The app name contoso is not available in West US". This error is expected since "contoso" has already been taken in region West US by tenant in #1
  3. The first person deletes their contoso web app in West US
  4. The second person again attempts to create Web App named "contoso" with Secure Unique Default Hostname in West US, via portal, which succeeds and results in auto-generated URL of contoso-dg4jcnrush92asxn-westus-01.azurewebsites.net. Notice that the hash is different than the first person's--this is expected behavior.

Below is key excerpt from Unique Default Name article regarding regional uniqueness requirement:

How does the region in the unique default hostname work

The region in the unique default hostname would be based on the region where the site is located. Since the unique default hostname is now regionalized, you will be able to create a site called “test” in different regions. The site name however still must be regionally unique, which means that there can only be one site called “test” in East US regardless if they have different hash values.

...

With the above in mind, answers to your questions below:

Q-(a): What determines whether Azure uses the traditional name.azurewebsites.net format versus the new name-<hash>.<location>.azurewebsites.net format?

A-(a): The portal wizard always uses the new name-<hash>.<location>.azurewebsites.net format, however, if the name you enter is unavailable in the selected region, it doesn't display the generated hash and suffix since deployment would fail anyway. The hash is generated, just not shown in the user interface.

The portal wizard used to give the option to use Secure Unique Default Hostname or original behavior, but that was recently removed.

Q-(b): Why does Azure add the suffix for some available names but not for others?

A-(b): As mentioned above, if the name isn't available in the selected region, it doesn't show the hash and suffix. In terms of clarity, I'm unsure if it would be more/less confusing if they showed hash and suffix along with error message. Either way the result is the same--you can't create the web app since the name is already taken in the region.

Q-(c): Is the suffix related to the availability of the original *.azurewebsites.net hostname, or is there another internal rule/algorithm that determines when it is applied?

A-(c): No, the suffix isn't related to availability of original *.azurewebsite.net hostname.

Q-(d): Is there any Microsoft documentation that explains the logic behind this hostname generation?

A-(d): The article I linked to above explains part of it, but doesn't cover peculiarities of portal wizard.


SPECIAL THANKS to MVP Andreas Baumgarten for helping verify various scenarios and providing technical input.

Please click Accept Answer and upvote if the above was helpful.

Thanks.

-TP

Was this answer helpful?

1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Ajay Rathod 440 Reputation points Microsoft External Staff Moderator
    2026-08-16T06:30:52.13+00:00

    Hi @Naik, Anilkumar

    Greetings for the day, Thanks for reaching out to Q&A.

    Thank you for the clear description of both attempts — that comparison is exactly what's needed to explain the difference.

    Short answer: the two outcomes don't come from one rule. They come from two separate checks that run in sequence in the Create Web App wizard.

    Root cause

    The wizard evaluates app name availability first, and generates the default hostname second.

    The Microsoft.Web/sites resource name must be globally unique across the entire public Azure cloud, and Web Apps, Function Apps, Logic Apps (Standard) and deployment slots all share that namespace.

    • "webapp" is already owned somewhere in that cloud, so it failed the first check and the wizard never reached hostname generation — which is why no hash was offered.
    • "webapptest" passed the first check, so the wizard proceeded and applied the secure unique default hostname.

    The hash secures the hostname; it does not make a taken resource name usable.

    To be transparent on confidence: the name-uniqueness behaviour is documented. The specific evaluation order inside the portal wizard is my assessment based on the output you observed, and is not spelled out in public documentation.

    Steps to confirm and to control the behaviour

    Step 1 — Verify the name status directly against the resource provider

    az rest --method post --url "/providers/Microsoft.Web/checkNameAvailability?api-version=2022-03-01" --body "{\"name\":\"webapp\",\"type\":\"Microsoft.Web/sites\"}"
    

    Why this matters: it separates the name check from the portal UI entirely. How to verify: a response of "nameAvailable": false, with a reason and message, confirms the name is taken or reserved — the same result the portal surfaced.

    Step 2 — If you need the traditional predictable hostname, create the app outside the portal

    For ARM, Bicep or REST, omit AutoGeneratedDomainNameLabelScope from the site properties. To opt in explicitly, set it to TenantReuse, SubscriptionReuse, ResourceGroupReuse or NoReuse:

    "properties": {
      "serverFarmId": "<AppServicePlanResourceId>",
      "AutoGeneratedDomainNameLabelScope": "TenantReuse"
    }
    

    For the CLI:

    az webapp create --name <AppName> --resource-group <ResourceGroup> --plan <AppServicePlan> --domain-name-scope TenantReuse
    

    Why this matters: the portal applies the secure unique hostname automatically with TenantReuse and no longer exposes a toggle, so the API surface is the only place to control this. How to verify:

    az webapp show --name <AppName> --resource-group <ResourceGroup> --query defaultHostName -o tsv
    

    Expect <AppName>.azurewebsites.net when the property is omitted, or <AppName>-<Hash>.<Region>.azurewebsites.net when a scope is set.

    Step 3 — Choose the hash scope deliberately if you deploy the same app name across environments

    • TenantReuse — same hash for the same app name across every subscription in your Entra tenant
    • SubscriptionReuse / ResourceGroupReuse — narrows that to the subscription or resource group
    • NoReuse — a new hash on every creation

    Why this matters: if you promote from a test subscription to production under the same tenant, TenantReuse keeps the hostname stable; NoReuse will change it on every redeployment. How to verify: create the same app name in two scopes and compare the defaultHostName values returned by the command in Step 2.

    Two constraints to note

    1. The feature can only be set at creation time. It cannot be applied to, or removed from, an existing app. The supported paths are Clone or Restore from backup into a new app — both available in the portal.
    2. The region identifier in the hostname (for example eastus-01) may use a different number suffix for future deployments, so please don't take a hard dependency on that exact region-number pairing.

    Documentation references

    Was this answer helpful?

    0 comments No comments

  2. AI answer

    2026-08-16T02:11:58.3033333+00:00

    Azure uses the new hostname format based on how the app is created and whether secure unique default hostnames are enabled at creation time.

    • Traditional format: <AppName>.azurewebsites.net
    • Secure unique format: <AppName>-<Hash>.<Region>.azurewebsites.net

    For new Web Apps created in the Azure portal, secure unique default hostnames are applied automatically on supported SKUs. In that case, the generated hostname includes the hash and region.

    For apps created through Azure CLI, ARM templates, or REST API, the hashed format is used only if the create request explicitly sets the hostname scope:

    • CLI: --domain-name-scope
    • ARM/REST: AutoGeneratedDomainNameLabelScope

    The suffix is not described as something Azure adds only when the original name.azurewebsites.net is unavailable. The documented behavior is that the hash is part of the secure unique default hostname feature, which is chosen at creation time and generated according to a configured scope:

    • TenantReuse
    • SubscriptionReuse
    • ResourceGroupReuse
    • NoReuse

    The documentation states that the 16-character hash is deterministic within the selected scope. For example, with Tenant Reuse, the same app name gets the same hash across subscriptions in the same Microsoft Entra tenant. With No Reuse, a new unique hash is generated every time.

    That means the observed behavior is explained by the provisioning path and hostname-scope setting, not by a documented rule that Azure checks the old hostname first and only then appends a suffix.

    Supported points from Microsoft documentation:

    1. What determines old vs new format
      Whether secure unique default hostnames are enabled when the resource is created.
    2. Why some names get a suffix
      Because those apps are being created with the secure unique default hostname feature enabled. In the Azure portal, this is automatic for new supported resources.
    3. Is the suffix tied to original hostname availability?
      No such rule is documented in the provided Microsoft documentation. The documented rule is that the hash-based hostname is produced by the secure unique default hostname feature and its selected scope.
    4. Is there Microsoft documentation explaining this?
      Yes. Microsoft documents:
      • the old and new hostname formats,
      • the purpose of the feature,
      • the hash scope options,
      • that portal-created apps use it automatically,
      • and that CLI/ARM/REST must opt in explicitly.

    One more related behavior is documented: after an App Service app is deleted, reuse of the corresponding DNS name is temporarily restricted to subscriptions in the same tenant as the original owner. That protection is separate from the secure unique hostname format.

    So for the specific webapp versus webapptest example, the exact internal decision path for why one creation flow showed one result and the other showed another is not documented here beyond these rules:

    • secure unique hostnames are automatic in portal creation,
    • the hash is controlled by scope,
    • and the feature exists to prevent subdomain takeover.

    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.