How to ignore HTTPS Only Azure Appservice custom domain setting for Always on

483 views Asked by At

I have a ASP.Net Core 2.2 site running as an Azure AppService. As part of the configuration, I have a custom domain with the HTTPS only setting turned on.

I also have the Always on setting turned on on my Appservice.

According to this article https://ruslany.net/2017/11/most-common-deployment-slot-swap-failures-and-how-to-fix-them/ the Always on setting will be ignored when HTTPS only is on and as a result, my site is always doing a cold start with the first call.

According to the same article, a rule condition can be set in the web.config to not process the Redirect to HTTPS rule if a {warmup_request} is processed.

However, my HTTPS only is set on the custom domain in Azure and not as a rule in the web.config.

I am setting RouteOptions in startup.cs with the following code:

services.Configure<RouteOptions>(options =>
{
    options.LowercaseUrls = true;
});

and believe that the rule condition can be done here as well using options.ConstraintMap() but I am unsure as to the syntax or method required to represent the following:

  <match url="(.*)" />
  <conditions>
    <add input="{WARMUP_REQUEST}" pattern="1" negate="true" />
    <add input="{REMOTE_ADDR}" pattern="^100?\." negate="true" />
    <add input="{HTTPS}" pattern="^OFF$" />
  </conditions>
  <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>

Any help on how to do this will be appreciated

Thanks

1

There are 1 answers

1
RuslanY On

From the time this article was written the "https only" has been added as a built-in feature of app services so there is no need to use this rewrite rule anymore.

As to how to minimize the cold start for your application - you may want to consider adding appinit configuration to the web.config as described in App Service Warm-Up Demystified