Change domain for Pull Request environments in Azure Static Web Apps - azure

Is it possible to change the domain for which Pull Request environments are built to? Currently we have our main branch built to a custom domain https://dev.mycompany.com and PR environments are built to the generated domain https://icy-flower-07e440303-{Pull Request ID}.westeurope.azurestaticapps.net. I would like them to be something like https://{Pull Request ID}.dev.mycompany.com so that our CORS rules still applies.

you can apply a custom domain directly to the static app. To do this you need to make a dns entry in the azure dns or any other dns registry then configure the static app to use the custom domain.
Dns registry can be done just by going to the azure dns in the portal click on the + button and fill the required details
Then you can configure the static app by providing the custom domain in the setting under custom domain option.
Refer the following documentation.

Related

Change the URL of a Azure Static Web App from the randomly generated name

I created a Azure Static Web App in Azure. The process saved a workflow file in the Github repository and created a URL https://nice-beach-0253b8b10.azurestaticapps.net. How can I change this URL?
You currently can't change the azurestaticapps.net itself. However, you can configure a custom domain (using your own domain provider) or setup a CNAME record.
See more info: https://learn.microsoft.com/en-us/azure/static-web-apps/custom-domain?tabs=azure-dns
Unfortunately, you cannot pick and choose your app URLs. But if you hate only the nice-beach part, you can always create another Static Web App resource and hope for the best as Azure picks a random two-word phrase every time.
Static web apps are just another Azure app service and you should be able to set up custom domains as you normally do for any other app service.

How to have multiple host names for azure website

I created an web app for a demo website in Azure. The domain name for this website was created when I created the app service "myapp1.azurewebsites.net". I'd like to use additional domain names using the same azurewebsites.net such as myapp2.azurewebsites.net. When I try to add this custom domain it tells me
Failed to add hostname myapp2.azurewebsites.net. Too many (2)
hostnames in the default DNS zone. Limit is 1
Is there no way around this or must I use my own custom DNS name?
For this you need to add custom domain in Azure web app.
For example : when I created the app service "myapp1.azurewebsites.net" and want to have additional domain names , you can go for custom domains like abc.com.
You can not have .azurewebsites.net as the custom domain of already existing web app as it is already owned by Microsoft Azure web app.

How to test Azure Web App that requires custom domain without using public DNS

I have an Azure Webapp on a Standard 1 Small App Service Plan, I deployed my application successfully to the webapp, but now I need to test it using a specific domain name that on client side could be configured using hosts file.
The problem is that the Azure webapp will only "recognize" the custom/specific domain (ex: myapp.mydomain.com) if I configure a Custom Domain that uses public DNS and I can't (at this moment) configure the existing domain name to be a CNAME to the Azure webapp because it is production environment, I can and will make the CNAME after the application is tested not before.
My application requires to be called by the specific domain name.
So how can I test my application on Azure webapp using a custom domain but without using public DNS using only my hosts file client side?
note: this problem doesn't even exist in AWS Beanstalk so why is this so complicated with Azure webapp. Its pretty basic
You can preemptively associate your custom domain name with your web app and test it via a client using the host file. To verify domain ownership, Add a TXT record. The TXT record maps from awverify.<subdomain> to <appname>.azurewebsites.net. Steps to do this are outlined here:
https://learn.microsoft.com/en-us/azure/app-service/manage-custom-dns-migrate-domain
Using App Service, I don't think you can do this.
It configures the underlying app to only listen for domains configured in the Web App.
So if you don't add the domain as a custom domain, requests won't be routed to the app.
The reason is that IP addresses are shared, so Azure relies on the Host header to route your request correctly.
You can add the custom domain without CNAME / A record by using the awverify record mentioned by Ken.

Azure Application Gateway, Azure App Service and Form Based Authentication

I'm migrating a complete infrastructure over to Azure; it's been slow going as there's so much to learn and for every two steps forward, there seems to be one step back.
After what seems like an eternity, I think I've got it all sorted with one exception.
The architecture is as follows:
Azure Traffic Manager ==> 2 Azure Application Gateways (geo separated) ==> Azure App Service
A custom domain is used for the traffic manager and the gateways are listening for the same domain and, when the route matches, passing on the requests down to the app service.
The actual app itself is a ASP.NET MVC application and it uses forms authentication; and this is where the challenge happens.
When navigating to the public address: client.domain.com and hitting the website, it determines that the user is not authenticated and sends the browser to the login page... so far so good but, rather than using client.domain.com/login it uses the web-server dns name, so client.azurewebsites.com/login
How do I go about changing the behaviour so that it uses the external DNS name rather than the website name?
I can't setup custom domains on the app service as the only route into the site is via the gateway as this is also the firewall.
Is there some Web Config setting I can make? I'm looking at the outbound rewrite rules but these seem to only work on tags rather than 302 redirects.
Any thoughts would be most welcome.
You need to setup custom dns names on your webapp (you can use TXT record to verify dns name, so i dont see a reason why you can add it to the webapp). or you can alter the code.
In order to solve this problem, I had to make a code change to the web app itself. Not ideal but it worked.
What I had to do was to extend the code that redirects an unauthenticated request to the login page by sniffing for the X-Original-Host HTTP Header that the App Gateway forwards on. This contains the public facing DNS name. If the header is present and it is on a pre-approved white-list (so as to prevent any hijacking), then redirect the user to the login page for this domain, rather than the one the server is listening on directly (so use client.domain.com rather than client.azurewebsites.com)

Nested Profiles in Azure Traffic Manager not working properly

I had created two Traffic manager profiles naming as Firstprofile, Secondprofile.Firstly Secondprofile configured with app service end point. Now Secondprofile added as Endpoint to Firstprofile (called nested profile) .While browsing the Firstprofile showing the error as follows "Error 404 - Web app not found"
The HTTP request you make to your Web App includes a 'Host' header containing the domain name used in the request. This must be recognized by the Web App. The standard Web App domain name (foo.azurewebsites.net) always works, any other domain names appear in the Web App's custom domains list.
When you add a Web App to Traffic Manager, the Traffic Manager profile's domain name (child.trafficmanager.net) is automatically added to the Web App's custom domains list. So far, so good.
There is a known issue in the Web App / Traffic Manager integration that when using nested Traffic Manager profiles, the domain name of the parent profile (parent.trafficmanager.net) is not added to the Web App custom domain list. This is why you're seeing 404 errors when trying to access the Web App via the parent profile.
As a workaround, you should configure a DNS record in a vanity domain (e.g. www.contoso.com) as a CNAME to parent.trafficmanager.net, and register the vanity domain name as a custom domain in your Web App. Access to the web app via the vanity domain should now work, and this will use the nested Traffic Manager profile as part of the DNS resolution.
Jonathan (Program Manager, Azure Traffic Manager)
The problem is exactly what Jonathan Tuliani mentioned, but there is an alternative solution.
You need to add the parent Traffic Manager profile's domain name to the Web App.
Just go to Custom Domains and SSL -> Bring external domain -> enter the domain name e.g. tmdemo.trafficmanager.net. It will get allowed and everything works.
I just wrote a blog post about it: Nested Traffic Manager profiles

Resources