Steps to reproduce:
Create an a Web App Service (tested on Linux with Containers) with name dnsissue-webapp.azurewebsites.net
Add a custom domain pointing to this new WebApp. For example mysub.mydomain.com
Check that the redirection is working.
Create a second Web App Service (same configuration) with name dnsissue2-webapp.azurewebsites.net
Stop the first webapp and remove the custom domain from it.
Without changing any configuration in your DNS, add the custom domain to your second WebApp. So add mysub.mydomain.com in dnsissue2-webapp.azurewebsites.net but keep in mind that your DNS will still point to dnsissue-webapp.azurewebsites.net (first WebApp). Here is the first issue, the second WebApp will accept the custom domain eventhough the DNS provider is not point to it.
Here is the second issue: Now delete the first WebApp. You will see that you loose access to the second WebApp.
To restore access to your second WebApp (dnsissue2), create again the first WebApp (dnsissue).
WebApp should not allow to add a custom domain if the DNS is not pointing to it.
Why WebApp allows you to add a custom domain if the DNS is not pointing to it? The CNAME was still pointing to and old WebApp.
Deleting the first WebApp kills access to the second WebApp. It make sense since the CNAME was pointing to it. So how does the routing works? Is this a totally unexpected behaviour or I just did things in the wrong order?