Azure subdomain to handle multiple environments - azure

I have a web app that is relies on a series of azure services. Currently, to handle different environments, we have a subscription and resource groups to handle each environment that we use (dev, test, staging, production).
Right now, every web app site EXCEPT for Prod uses the default url that Azure assigns to the web app upon creation.
This has led to some issues with in house business case testers getting confused about which urls go to what environment.
I wanted to know if it is possible to create subdomains that are named according to the environment (so if prod is https://superglue.com then dev would be https://dev.superglue.com) and if we can, if there are any reasons NOT to do it this way.
THanks in advance for any help!

You could add custom domains to each of your web app service. For example, you could map a subdomain www.contoso.com by using a CNAME record in your DNS provider. Then In the Custom domains page of the web app, add the fully qualified custom DNS name www.contoso.com to the list.
You could follow these steps in the official doc. https://learn.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-custom-domain#map-your-domain
Azure does not support this if you have a free F1 price tier. But if you have shared D1 price tier, you could add custom domains. With a basic price tier and above, you could add custom domains and SSL binding.

Yes, you can use Azure web app deployment slot if you want to distinguish the dev,staging and prod environment of your web app.
Deployment slots are actually live apps with their own host names. And this is a recommended way to do some tests or building up test environment on your web apps .
What's more,if you have ensure that the staging env is ready to online , you can swap it to prod environment directly of course you can swap it back to staging easily too : ).
Hope it helps .

Related

Running same custom domain in different Azure App Services in same region

I need to have the same Azure App Service Custom Domain running in different App Services on the same region. Is that possible?
Custom domians are based in DNS, only one record should be pointing to one App Service, so I think it would not be recommended to have same custom domain in multiple App Services in the same region. Being said that, it works for different regions and it is common to see this deployments for instance behind Traffic Manager or Azure Frontdoor.
In order to do this in the same region is a bit more challenging as the only way is to make sure your App Service goes to a different webspace (https://learn.microsoft.com/en-us/azure/app-service/app-service-plan-manage#move-an-app-to-another-app-service-plan). So basically to make sure it goes to a different webspace you need to create a new Resource Group and a new App service Plan, then you can create the specific App Service and add the custom domain. In order to make sure they are in different webspaces, check if the Inbound IP is different.

azure VM staging to production

I am currently trying to figure out the best architecture for my Azure VMs.
I have a production website that is hosted in IIS in 2 VMs with a load-balancer over them, this is called Prod1 and for now is the live site.
I also have the exact same setup as my "staging" (called Prod2) environment, obviously this is not live .
I wish to deploy to Prod2, test and when happy switch it to live. Thereby making Prod1 not live.
Now i can simply drop the TTL and re-point the A record on the sites Domain name to the public IP of Prod2s load balancer.
But is there a better way of doing this to enable faster switching between these?
Azure Traffic Manager would be my suggestion for a seamless blue-green deployment.
For your workloads that are running in Azure, the recommendation is to setup the Blue environment, which has the old code, and Green environment, which has the new code, in separate Azure Resource Groups.
If the endpoint is external, you can use any continuous integration and deployment tool to manage and deploy the two environments.
Once you have the environments ready you can create a Traffic Manager profile using the Azure portal, PowerShell, or CLI, with weighted round-robin as the routing method and add the endpoints corresponding to these environments.
See Dilip's full post here.

Host 2 separate sites, one domain, on one Azure site

I have a wordpress site hosted on Azure. Call it, mysite.com. I'd also like to develop a separate .net app and host it at subsite.mysite.com. How can I do this without having to pay for 2 separate Azure sites?
There are ways to achieve what you require. However, key point here is to understand the Azure App Service. Because, in Azure app service, you never pay (your concern is having to pay, not having to maintain) for a single site!
If you take a closer look at the App Service Pricing model, you will see that even with the free (like in Free lunch) tier, you get to host 10 applications in your hosting plan. But you need custom domain, then you go to Shared plan, you already can host 100 web sites within it, all with your custom domain/s.
Next you will have to learn a bit about what is Top Level Domain, what is Domain, what is Sub Domain, what is A DNS Record and what is C-Name DNS record, because these are all thing you need to understand in order to properly configure your sites.
And finally read the article on how to configure custom domain for Azure App Service.
Remember. With Azure App Service, you are paying for a hosting environment (or service plan), not for a single web site!

Is it possible to move custom domain from one web app to another?

I have a custom domain www.abc.com configured for web app webapp-a, and I'd like to transfer it to webapp-b without downtime.
If I try to add the domain to webapp-b, I am getting
The host name www.abc.com is already assigned to another Azure website: webapp-a
It there a way to let webapp-a continues to serve the requests, until the DNS cache expires?
Edit: The domain has IP based SSL binding, and the DNS is caching the virtual IP.
I faced the same issue, and was able to solve it in a tricky way.
I created new App Service Plan (previously known as Web Hosting Plan), and assigned "new" Web App to it (you can do it via new portal, or you can create Service Plan during Web App creation).
Then, I was able to assign the same host name to Web Apps in different hosting plans.
Thinking about this, I feel it logical: most probably Service Plan is mapped to physical IIS machine, and you cannot have two sites with the same host name in the same IIS for the obvious reason.
After migration from one DNS to another is done, you can remove unused Service Plan (as you basically pay for each separately).
According to a blog post by the Azure App Service Team in June 2017, it would appear that Azure now supports adding the same custom domain to multiple web apps:
There are scenarios where a customer would like to add the same hostname to multiple web apps in the same subscription, having a geo distributed website is one example. Our custom hostname feature allows you to bypass validation for hostnames that have already been validated. You only need to verify domain ownership when you add a hostname for the first time. For all other apps in the same subscription, you can add the same hostname without creating any DNS records.
You can read the entire blog post at https://blogs.msdn.microsoft.com/appserviceteam/2017/06/21/custom-hostnames-with-app-service/. The quote above was taken from the Adding the same custom hostname to multiple web apps section.
This should help in scenarios such as this where you want to transfer a custom domain name from one web app to another. You can simply add the same custom domain name to both web apps, add any required SSL bindings, and then change the DNS to point to the new web app. As the DNS change propagates, traffic should gradually move over to the new web app without any downtime.
I've tested this myself in the North Europe region and had no problems. Both web apps were in different App Service Plans. I have not tested this scenario with both web apps in the same App Service Plan. Bear in mind that if you're using IP addresses/A records in your DNS, you'd need both web apps to have different IP addresses for the DNS to be able to differentiate between your web apps.
Try assigning the domain to Azure Traffic Manager and have the traffic manager forward the request to the second site. Azure Traffic Manager and Web Apps are two different systems so you might be able to assign the same domain name to a web app and a traffic manager.
Once the DNS cache has expired remove the domain from the old Azure web app and add it to the new one, then finally delete the Traffic Manager account.
Option 2
Set the TTL to something very small, say 5 seconds (I believe your hostname provider should let you set that up), wait for the new TTL to propagate through all the caches. Then switch the custom domain from one app to another, and set the TTL back to it's original value.
This will result in just a few seconds of downtime for any customers, but if you do it at a low-traffic time the effect shouldn't be too bad.

Windows Azure Multiple Sites under single role - Staging Issue with host header

I have a "web" and "mobile" site that I'm launching within Azure of the same domain. Originally I was going to run each as a separate hosted service but this doubles the cost though it would allow me to scale each independently.
Then I learned that you could run multiple sites under one web role using hostheaders similar to your standard iis site. I love the swap VIP button on Azure that let's you deploy your "staging" site instantly to "production" but I'm not sure how to take advantage of this if I'm using hostheaders; in my set-up, the "staging" site that is using hostheaders is effectively hidden until I push to production.
Any thoughts on how to test the staging site that is using host headers without having to modify the ServiceDefinition.csdef file before pushing to production?
Edit %windir%\system32\drivers\etc\hosts, and map the hosts you want to the IP address of your staging deployment.

Resources