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

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.
We will have 2 subdomains. For example, api.contoso.com and app.contoso.com
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?

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!).

Related

How to get IP Address on Azure Web App Service

Is there a way to assign an IP to a Azure App Service? I just deployed my application and it's working correctly. But the problem is we need our domain to point to that App Service. Since our domain is website.com and the app service domain is website.azurewebsites.net is there a way to point the website.com to the azure url? We have a reverse proxy where we can just assign the IP and that will load the site. So if the site is website.azurewebsites.net and ip is 123 then in our reverse proxy we just assign 123 to our domain website.com. So whenever someone access website.com they are presented with website.azurewebsites.net. Is there a way to assign an IP to this app service?
Like silent mentioned, use CNAME mapping to map the domain, alternatively Web Apps actually have a list of possible outbound IP addresses, but I dont think thats reasonable, just use CNAME (you also need to verify your domain in Azure).
App Services is a shared servers which means many App Services is behind same IP hence you need to configure Custom Domain on your App Service to get it to work:
https://learn.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-custom-domain
The shared IP can be found under your App Service on the blade Settings->Properties.
The name is "Virtual IP address"

Is an Azure app service plan analogous to an instance of IIS?

I've been struggling with adding a custom domain to one of my sites because it's already in use on another site. I have these:
TMProfile1 tm profile
+EastUSAppServicePlan1 app service plan S2
+eus-x-com.azurewebsites.net app service
+x.com custom domain
+WestUSAppServicePlan1 app service plan S2
+wus-x-com.azurewebsites.net app service
+x.com custom domain
These sites both have a custom domain of x.com set up. Both these sites are in the same traffic manager profile and the DNS points x.com -CNAME-> tmprofile1.trafficmanager.net. All is good
I've created another app service plan (this time an S1) called EastUsAppServicePlan2 and I created a new app service inside of it called eus2-x-com.azurewebsites.net. Even though this new app service is in a different app service plan to the two that already exist, I'm trying to add the same x.com custom domain to this new app service:
x.com custom domain is already assigned to website eus-x-com.azurewebsites.net
I always thought that an app service plan is analogous to an instance of IIS, and that every app service plan would have a unique IP address but it seems not. If I nslookup eus-x-com.azurewebsites.net (a site in EastUsAppServicePlan1) I get an IP of 12.34.56.78 and if I nslookup eus2-x-com.azurewebsites.net (the site in the new EastUSAppServicePlan2) I get the same IP of 12.34.56.78
It seems to be then, that it is region that determines IP; even if I create different app service plans in the same region, they will all have the same IP address? (It might explain some of the other issues I'm having)
By pulling the definition from the Microsoft documentation, we have:
Azure App Service is a multi-tenant service, except for App Service
Environments. Apps that are not in an App Service environment (not in
the Isolated tier) share network infrastructure with other apps. As a
result, the inbound and outbound IP addresses of an app can be
different, and can even change in certain situations.
So, even in same region you may have scenarios that your apps, using different service plans, have same inbound ip addresses, or different. That's managed by Azure, so you have no control over it, unless you have a scenario that you want to use a dedicated static inboud ip address to your apps, then you can leverage the IP-based SSL binding feature to have the same ip address for them.

Pointing same domain to different app service in Azure

I am using Azure App Service to host my NodeExpress application, I am right now stuck at a very strange requirement.
I have 2 different azure app services.
1) myApp
2) sampleApp
I have a domain pointed at myApp. (Added hostname www.myapp.com)
now I want to delete myApp and shift my hostname (www.myapp.com) to sampleApp.
now my Question is,
will it change my IP Address? (This I think it would because I haven't bought any static IP)
if my app service pointing IP is changed, will I have to do anything with the domain DNS manager to move www.myapp.com in hostnames of sample app?
I don't have access to DNS Manager because client has it. I have to tell client to add CNAME to verify domain ownership. I want to point this domain to different app service without adding delay of asking my client to change its cname to verify domain ownership.
You can actually migrate the domainname without downtime by using a verify record. Just create the record:
awverify.www.mydomain.com CNAME mynewnodeapp1.azurewebsites.net
That will enable you to add the hostname www.domain.com to sampleApp in azure (and add an SSL binding).
Source: https://learn.microsoft.com/en-us/azure/app-service/manage-custom-dns-migrate-domain
You have to register the new CNAME from your web application in the DNS server before adding it to Azure App Service. Right now you have something like this:
www.mydomain.com CNAME mynodeapp1.azurewebsites.net
First, change it to your new application address:
www.mydomain.com CNAME mynewnodeapp1.azurewebsites.net
And then add the custom domain to your new web application.
App Service does provide you with a public IP address, but it's not guaranteed to remain the same, although it's unlikely to change. Said that, as long as you keep using CNAME, you shouldn't have any problems. If you delete the original app and recreate using the same Azure FQDN, then you don't need to change anything on customer DNS settings, Azure will be able to verify the domain successfully in this case.

Azure Traffic Manager, custom domain and 404

I got lost with Traffic Manager setup and custom domain name.
First I had two mobile apps in 2 regions (westeuropeapp.azurewebsites.net and brazilapp.azurewebsites.net) as endpoints of Traffic Manager (trafficmanager.trafficmanager.net). It was Working.
Then I wanted to use a custom domain name with subdomains: westeurope.mydomain.com, brazil.mydomain.com and trafficmanager.mydomain.com. So I followed Azure doc instructions and created CNAME for my subdomains pointing to the two mobile apps and to traffic manager. Then I added westeurope.mydomain.com (resp. brazil.mydomain.com) as hostname for my west europe mobile app (resp. brazil mobile app).
But when I navigate to trafficmanager.mydomain.com I got a 404.
I checked the DNS resolution with Dig, I can see that trafficmanager.mydomain.com has a cname to trafficmanager.trafficmanager.net which has a cname to westeuropeapp.azurewebsites.net which resolve to ip xxxx.This looks good.
If I type that ip into my browser I got 404. But if I type westeuropeapp.azurewebsites.net I got my app running. I also checked westeuropeapp.azurewebsites.net in Dig and it resolves to the same ip as above.
What am I missing? (I don't even talk about SSL, it will be next post.)
You also need to add trafficmanager.mydomain.com to the Mobile Apps as a custom domain.
App Service shares IP addresses across apps, so the only way for it to identify which app your request is bound for is the Host header. By adding the custom domain App Service knows to route requests for that domain to that app.
Once you add the mobile apps to the traffic manager, trafficmanager.mydomain.com will automatically gets added to the mobile app, in the host name assigned to site(App->Custom domain). Wait for sometime for the changes to propagate. After the trafficmanager is propogated, You need to add custom domain to both of your mobile apps.
This video has the details for adding custom domain for the traffic manager. https://www.youtube.com/watch?v=1ggz9qZpVHo

Can I map (CNAME) a custom domain to a subdomain that is part of a Wildcard on Azure Web Apps?

I have a website on Azure Cloud Services, and I have enabled a wildcard for my website like: *.mywebsite.com
Then if a customer registers and select as his subdomain: client1.mywebsite.com, I only save the subdomain associated with my customer in the database. I don't need to do anything on the portal. This works as well on Azure Web Apps (Azure Websites).
Now, if my client goes to his domain provider and sets a DNS entry like:
www.client1.com CNAME client1.mywebsite.com
I can handle that correctly in Cloud Services without having to register "www.client1.com" in the Azure Portal. Is that possible in Azure Websites without having to add www.client1.com to the Azure Portal?
Short answer, no, it is not possible.
Explanation.
What you type in the address bar is the name that is presented to a web server in the HTTP request. Regardless of the underlying DNS responses. If a DNS look up of www.example.com provides an IP Address, whether a CNAME or an A record, that is where it will go and get data from. The only way to change that is with a HTTP Redirect.
In Azure the incoming server name is used to direct traffic to the correct web app (On the same set of IP Addresses there might be thousands of other websites registered) The only way it knows how to distinguish where to send the request is from the incoming server name.
Why this worked on Cloud Services.
Behind a cloud service was an IP Address that was unique to your servers behind it. When a cloud service got a HTTP request, it would process it, because there was nowhere else to send it.

Resources