Azure App Service does not natively support wildcard subdomains (*.myapp.azurewebsites.net) under the default azurewebsites.net domain. However, you can achieve wildcard subdomains using a custom domain.
To set up wildcard subdomains in Azure App Service:
- Custom Domain Requirement:
- You need to purchase or have access to a custom domain (e.g., myapp.com) since Azure supports wildcard subdomains only under custom domains, not under azurewebsites.net.
- For example, you could create subdomains like sub1.myapp.com, sub2.myapp.com, etc.
- You need to purchase or have access to a custom domain (e.g., myapp.com) since Azure supports wildcard subdomains only under custom domains, not under azurewebsites.net.
- Add a Wildcard DNS Record:
- In your DNS provider’s management console, create a CNAME record or an A record with a wildcard. For instance:
- *.myapp.com → point this to your Azure App Service’s default domain (myapp.azurewebsites.net).
- Ensure that the DNS is properly configured to allow traffic from any subdomain to be routed to your app service.
- Bind the Wildcard Domain to Azure App Service:
- In the Azure portal, go to your Azure App Service.
- Navigate to Custom domains.
- Add your custom domain (*.myapp.com) and verify it. You may need to validate ownership of the domain via DNS records.
- TLS/SSL Configuration
- To secure your wildcard subdomains, you’ll need a wildcard SSL certificate. Azure App Service supports SSL certificates, including wildcards.
- Upload the wildcard certificate in the TLS/SSL settings section of your Azure App Service.
Limitations of azurewebsites.net:
Azure App Service provides subdomains under azurewebsites.net, but wildcard subdomains (e.g., *.myapp.azurewebsites.net) are not supported for this domain. You would need to switch to a custom domain if you require wildcard subdomains for your app.
Workaround for Dynamic Subdomains:
If you can’t use a custom domain, a possible (though probably quite difficult) workaround is to programmatically handle subdomains in your application. You could inspect incoming requests for subdomains and route them accordingly within your application code, but each subdomain would still have to be manually set up or handled dynamically.