2
votes

I have multi tenant MVC application running as an Azure website. Tenants are resolved by using sub domains. So tenant A can be resolved by http://tenanta.myapp.com. This works perfectly well as long as I go and create individual CNAME records on my DNS server for each tenant. However I do not want to have to do this.

So I successfully added a wildcard A record *.myapp.com to my DNS records and in azure I added a custom domain name *.MyApp.com. So now I can use http://anything.myapp.com and it will resolved to my azure website ok. So that was great and I thought I was up and running.

Until I tried to browse to a page that is using AJAX to call a WCF service (the WCF service is internal to the website). There are a bunch of WCF services and they all throw a 500.

System.UriFormatException: The protocol binding '*:80:*.myapp.com' is not valid for 'http'. This might be because the port number is out of range.

If I remove the *.myapp.com from the list of custom domains in Azure then I don't get the error but my wildcard subdomains no longer get directed to the website and I get a 404 from azure.

I've tried a few things with the bindings for the WCF services including trying all of the HostNameComparisonMode options StrongWildcard, WeakWildcard and Exact.

I was hoping someone else had come accross this problem before. There are bunch of posts on getting the wildcard subdomains working but nothing specific to the issue I am having with WCF services.

Thanks in advance

3

3 Answers

1
votes

This might be due to a binding of the shape :80:.myapp.com gets created in the applicaitonHost.config when the wildcard custom domain name is added to the site (in Azure Web Sites service). We will investigate and try to get this fixed.

Meanwhile, it might be worth a try to clear the bindings section in your web.config and recreate a binding of the form

<binding protocol="http" bindinginformation="*:80:"/>

Let me know if this works.

0
votes

To add on Zhe's answer here is how it can be done:

Create an applicationHost.xdt file under your 'site' folder, and copy the content below into it (more info on transform on Kudu site)

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <system.applicationHost>
    <sites>
      <site name="%XDT_SITENAME%" xdt:Locator="Match(name)">
       <bindings>
          <binding protocol="http" bindingInformation="'*:80:*.myapp.com" xdt:Locator="Match(bindingInformation)" xdt:Transform="Remove" />
        </bindings>
      </site>
    </sites>
  </system.applicationHost>
</configuration>
0
votes

In azure, for custom domain name, add * instead of *.myapp.com and that should work.