Using different subdomains of the same domain for different Azure App Services

Richard Barraclough 11 Reputation points
2022-04-26T11:32:08.313+00:00

I have an ASP.NET Core MVC app with the identity model extended to support multiple tenants. The application serves on a subdomain for each tenant.

I have a domain, foo.co.uk say.

I have set up the production environment so that <tenant>.foo.co.uk serves the tenant website.

Now I want to set up some test environments for which I have registered foo-test.co.uk and I want to deploy multiple test environments -- each as an App Service on a corresponding subdomain so that the tenant now becomes a sub-subdomain. For example:
<tenant>.test-a.foo-test.co.uk and
<tenant>.test-b.foo-test.co.uk.

I've tried a number of different permutations of DNS configuration for the Custom Domains of the Azure App Services -- some using A records and some using CNAME records. But I can't get anything to work.

Is this even possible?
If so then how?

I notice that both App Services have the same IP address, but an A record for * pointing at that address gives the blue Azure 404 page on some (but not all) subdomains and sub-subdomains.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,930 questions
{count} votes

1 answer

Sort by: Most helpful
  1. brtrach-MSFT 17,731 Reputation points Microsoft Employee Moderator
    2022-05-02T23:16:14.99+00:00

    @Richard Barraclough Was going through the April threads and saw that this never received a conclusive answer regarding using different subdomains on different app services.

    I created brtrachdomaintestdelete.azurewebsites.net and added the custom subdomain a.test-a.beesphotos.net to it. Used a cname value brtrachdomaintestdelete.azurewebsites.net with a name of a.test-a.

    I then created a second web app in a different resource group but in the same region called brtrachtest.azurewebsites.net and added the subdomain domain b.test-b.beesphotos.net. Used a cname value of brtrachtest.azurewebsites.net with a name of b.test-b.

    It's important to note that I have three domain verification txt records on beesphotos.net.

    1. asuid
    2. asuid.atest-a
    3. asuid.btest-b

    Each above txt record uses the same domain verification ID, which you can read more about here. Also, Microsoft recommends the use of CNAMEs when possible as it removes the issue of your A record IP address changing and bringing down your site. This would be extremely rare to happen but just wanted to share this tip with you that CNAMEs are the safer choice.

    You can use digwebinterface.com on my above domains and compare/contrast with what you have, which if you are unfamiliar, allows you to see the DNS records for a domain. Note: my domains should be active for the next 72 hours before being deleted.

    My domain was purchased in Azure and not a 3rd party provider if that also helps although I do not believe this should make a difference unless your 3rd party hosting provider had an obscure limitation in place.

    Lastly, DNS domain changes can take up to 30-45 minutes to sync across the DNS servers so ensure you are giving your configuration enough time to propagate out before changing it. 75% of the customer issues I have seen over the last 8 years have been due to not enough time being given for propagation.

    I hope the above example helps to reassure you that this is possible along with providing you the ability to cross verify your settings. If you have further questions or concerns, please let us know.

    0 comments No comments

Your answer

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