Is it possible to use slots with a custom domain, in this case Cloudflare as the DNS provider and how?

Cliff Cawley 96 Reputation points
2020-03-16T08:33:23.327+00:00

I've recently upgraded my Web App so that I can make use of slots.

I use Azure dev ops to just deploy to the main web app but have now changed it to deploy to a staging slot first and then after approval I call Swap slots.

Both production and staging work fine by themselves ( my-production.com works and my-staging.azurewebsites.net works), but as soon as I swap staging to production and visit my-production.com my web browser reports Too many redirects.
(It's difficult to debug this because it's a live production site and downtime means upset users, so I just quickly swap slots back again to 'fix').

I use Cloudflare to host my dns with an A record and TXT record and I've setup a custom domain for my-production.com to point to my-production.azurewebsites.net

I noticed the staging slot custom domain page doesn't have the domain setup but I'm not sure if it's needed.

The TXT record still points to my-production.azurewebsites.net so I'm wondering if this is part of the problem?

I've been unable to find any documentation on how this should be setup.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,996 questions
{count} votes

Accepted answer
  1. Cliff Cawley 96 Reputation points
    2020-03-24T12:01:22.623+00:00

    Okay, I've figured it out. It had nothing to do with swapping slots and was simply reproduced by accessing through a custom domain name (direct azurewebsites.net access worked fine)

    I had:

    app.UseHsts();
    app.UseHttpsRedirection();
    

    But because I'm using Cloudflare's HTTPS certificates which only does from browser to cloudflare, Azure was receiving an incoming HTTP connection and attempting to redirect to HTTPS, when it was already HTTPS.

    Not sure why this behaviour didn't happen in .Net Core 2.2, but in .Net Core 3.1 it definitely does!

    I've removed this for now till I upgrade and use my own certificate and this has resolved the endless redirect loop


1 additional answer

Sort by: Most helpful
  1. Kamal Kumar Khandelwal 1 Reputation point
    2020-05-03T17:51:41.653+00:00

    Dear Sir,
    It's possible that custom domain is used to map with Azure storeage static web site or not.. ?

    0 comments No comments