Robby F
Robby F

Reputation: 407

Map two different subdomains to a one Azure App Service Plan (with two different App Service inside)

Let me get this out of the way, I am not that familiar with DNS setup. But I am wondering if I can have this setup. I cannot test this right now because I control the our Azure portal but not the domain name provider.

  1. We will have 2 subdomains. For example, api.contoso.com and app.contoso.com
  2. We currently have a single Azure App Service Plan with two apps inside. One is the frontend SPA, and the other is the backend.

Checking the IP address and Custom Domain Verification ID of the two services, they are the same! So I am wondering if the setup of the two subdomains is possible. If not I'll consider moving out one of the App Service to its own App Service Plan or maybe Just map a single custom domain to the frontend. Any tips or suggestion?

Upvotes: 2

Views: 1396

Answers (1)

Matt
Matt

Reputation: 13349

Yes this is completely possible and a very standard setup. You will use CNAME records in your DNS setup which means you won’t use the IP address of the VM that your app service plan is on. Instead a CNAME DNS record maps your custom domain to another domain - in this case the domain name of an app service.

You will configure a different custom domain on each app service (and ideally a certificate to protect it).

E.g. your DNS might look like this:

app.contoso.com  CNAME  myapp.azurewebsites.net
api.contoso.com  CNAME  myapi.azurewebsites.net

I.e. when a request is made for a domain on the left it will be forwarded to the domain on the right.

When a request is made for either of your custom domains the custom domain will be in the host header. This request will be routed to the app service gateway which will look at the host header in order to know which VM to route the request to and once on the correct VM which app service to serve the actual request.

Once you have the above setup you can query the DNS system to see the complete route that a request would take, e.g.:

nslookup app.contoso.com

may return:

Name:    waws-prod-xyz-123-1234.uksouth.cloudapp.azure.com
Address:  99.99.99.99
Aliases:  app.contoso.com
      myapp.azurewebsites.net
      waws-prod-xyz-123-1234.uksouth.cloudapp.azure.com

With this command you'll see the actual VM that your app service plan is on (I've made up the IP and VM name here!).

Upvotes: 4

Related Questions