Mapping two app service to one DNS in azure - azure

I have two app services. One for UI and one for web api. I need to create a DNS so that I should be able to access like www.example.com/ui and www.example.com/api. Please let me know anyone how to achieve this without virtual directory concept.
Thanks

You cannot achieve this purely with DNS. DNS knows nothing about routes, only domain names. So www.example.com must resolve to one service, which should be your reverse proxy, maybe Application Gateway?
Here's the tutorial on hosting two apps behind Application Gateway: Tutorial: Create an application gateway that hosts multiple web sites using the Azure CLI.
Multiple-site hosting enables you to configure more than one web site on the same application gateway instance. This feature allows you to configure a more efficient topology for your deployments by adding up to 20 web sites to one application gateway. Each web site can be directed to its own pool. For example, application gateway can serve traffic for contoso.com and fabrikam.com from two server pools called ContosoServerPool and FabrikamServerPool.

Related

Azure web app - endpoints depending on domains

I want to host an Angular App in the Azure Cloud.
This app should be accessible via different domains. But for each domain the app should use a different Endpoint.
mycompany1.com -> restserver.company1/rest
mycompany2.com -> restserver.company2/rest
Is this feasible with only one azure static web app, web app or similar?
Thank you in advance.
You can do this by putting a load balancer in front of your Azure Web App. Azure load balancing services can be categorized along two dimensions: global versus regional, and HTTP(S) versus non-HTTP(S).
REF
Regional
A great regional option is Azure Application Gateway. Multiple site hosting enables you to configure more than one web application on the same port of application gateways using public-facing listeners. It allows you to configure a more efficient topology for your deployments by adding up to 100+ websites to one application gateway.
Global
If you are looking to host your sites across multiple regions then consider using Azure Front Door.
https://learn.microsoft.com/en-us/azure/application-gateway/multiple-site-overview
https://learn.microsoft.com/en-us/azure/application-gateway/configure-web-app?tabs=customdomain%2Cazure-portal

How to use Azure App Services domain for Static Web Apps?

I have an Azure App Services instance, which by default goes to https://myappservice.azurewebsites.net (not actually mine, but it's the same format). It's not a bad domain and a lot better than the sporadic randomized domains from Static Web Apps (https://lively-tree-randomletters.azurestaticapps.net).
Is there any way to switch the serverless website running on static web apps to also use the https://myappservice.azurewebsites.net domain?
Or is the only possible solution for hosting (1) react and (2) spring boot on the same domain, to buy one? Or this isn't possible at all?
(I want them to be on the same domain so I don't need to worry about CORS)
I think you could pull this off by using an Application Gateway. With the Application Gateway you can set up path-based rules so that you've got both your app service and your static website, but say yoursite.com/sprintBoot will be routed to your App Service and everything else on yoursite.com, to your static website.
See this article as an example: Create an application gateway with path-based routing rules using the Azure portal
Though it is up for debate if this is easier than worrying about CORS.

Azure - Connecting multiple app service containers with custom domain and ssl

I am getting to the point of my project where I am ready to deploy it online with my custom domain via Azure once I make the upgrade from my Free Subscription.
So a little context, I have 1 web app service and 4 api services and each one is hosted in a separate app service such as:
www.sitename.azurewebsites.net
www.sitename-api1.azurewebsites.net
www.sitename-api2.azurewebsites.net
www.sitename-api3.azurewebsites.net
www.sitename-api4.azurewebsites.net
And the above web app communicates to all 4 api's and some api's may or may not talk to another. (Would have loved an application gateway so hopefully I'll be changing this architecture later down the road).
So as I get ready to associate my domain to the services, the web container seems pretty straight forward to me as it just becomes www.sitename.com, but I am a little confused about the api services. The way I am thinking about this is that each api service will be in it's own subdomain, such as:
www.api1.sitename.net
www.api2.sitename.net
www.api3.sitename.net
www.api4.sitename.net
where I believe I can register my SSL and domain to each app service somehow, but this leaves me with a few questions.
Do I host each api in a subdomain using the same domain as the web
app, or is there a different way preferred like where I host them
all on the same domain with different exposed ports per API and web
listening 80/443, or maybe just use the IP address of the api app
service and allow www.sitename.com as the origin for CORS?
I am assuming that since I am associating my SSL cert to the web
service, I will need to do the following on the api services?
Would it be better (and still affordable) if I just had a VNET
associated to the app services and the domain only registered with
the web app?
Any insight into this would be greatly appreciated on how I can establish communication between my app services with my custom domain and SSL as I am fairly new to this part of the stack, but excited about learning!
As I known, on Azure cloud, there are two services can help to manage your APIs deployed on multiple app service containers: API Management and Application Gateway.
The Premium tier of API Management has the feature for multiple custom domain names, please see the offical document Feature-based comparison of the Azure API Management tiers as the figure below.
You can refer to the quick start tutorial of Create a new Azure API Management service instance and other related documents to kown how to.
"Azure Application Gateway is a web traffic load balancer that enables you to manage traffic to your web applications." said in the introduce What is Azure Application Gateway?. And as the figure of its architecture below, "With Application Gateway, you can make routing decisions based on additional attributes of an HTTP request, such as URI path or host headers. For example, you can route traffic based on the incoming URL. So if /images is in the incoming URL, you can route traffic to a specific set of servers (known as a pool) configured for images. If /video is in the URL, that traffic is routed to another pool that's optimized for videos."
I recommended to use Azure Application Gateway which be a good choice to manage multiple app services and expose the unified urls of APIs.

Can i use the default azure domain from an app service with an Azure Application Gateway?

I have an environment setup with multiple azure web apps across multiple Azure service plans.
I'm now retrospectively trying to add an azure WAF between the wider internet and the websites.
I have created a WAF, but am now struggling to understand whether it is currently possible to continue to use the *.azurewebsites.net app addresses and route traffic through the WAF?
Is it possible to use the built in *.azurewebsites.net app service addresses as the external entry point to the Azure WAF?
I think I understand your question, what you need to do is route the traffic to the application gateway add azure web app as the backend to the application gateway.
https://learn.microsoft.com/en-us/azure/application-gateway/create-web-app
you cannot azure *.azurewebsites.net as an endpoint for application gateway

How to implement different sub domain for different web roles hosted in a single cloud service

We have created an Azure cloud service which has a presentation layer web role and and an API layer web role.We have mobile clients accessing the API layer and hence designed to be scalable by each layer.
As both web roles are hosted in a single cloud service currently we are accessing both roles using port numbers. that is https://xyz.cloudapp.net:44300/ and https://xyz.cloudapp.net:44301/.
We have purchased custom domain and is currently pointing the CNAME to https://xyz.cloudapp.net and it accesses https://xyz.cloudapp.net:44300/.
Lets assume our custom domain name is example.com .Now we would like to access the main site by https://www.example.com and API by https://api.example.com rather than going by ports.
As per my investigation I have found that this is not possible using host header as the Azure load balancer does not examine host header at the network layer it operates. So option is write a URL redirect at the default site.
Do we have a better way to achieve this?

Resources