@Henry Cruise , Thanks for the great question.
Short Answer:
Firstly, App service support HTTPS on *.azurewebsites.net
domain name and the certificate is provided and owned by Azure.
I understand the requirement of removing the default domain, but there is no way disable it. You could instead accomplish this by adding a rewrite rule
(Or Redirect rule) to the web.config file in your wwwroot folder.
{Yes, by default, http://domain.azurewebsites.net works even with custom domain added, and the site admins aware about the URL can access, but typically end users would not access this URL directly (unless explicitly shared). }
Long Answer:
Essentially, indicating IIS to take any request where the host name matches the RegEx pattern “^yoursite.azurewebsites.net$” and return an HTTP 301 response
.
The response will include the originally requested url, except it’ll be pointing to your custom “www.yoursite.com” domain instead. When the user’s browser reads that 301 response
and the new url, it will automatically load that new url instead. It’ll even change the address the user sees in the address bar.
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect rquests to default azure websites domain" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^yoursite\.azurewebsites\.net$" />
</conditions>
<action type="Redirect" url="http://www.yoursite.com/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
Kindly see this blog for more information. Change the host names to match your site’s host names:
OR:
If your requirement fits, you could add condition to display ‘403
’ error.
<conditions>
<add input="{HTTP_HOST}" pattern="^(.*?).azurewebsites.net$" />
<action type="CustomResponse" statusCode="403" statusReason="Forbidden" />