Base solution for your next web application
Open Closed

Has anyone managed to get Sub Domains working with ASPNETZERO when hosted on Azure Web App? #11263


User avatar
0
Mitch created

Version 11.3- MVC- Net.Core Multi-tenant

I've successfully purchased a wildcard domain and have configured it with Azure.

I have followed the ASPNetZero documentation and made the changes to the appsettings.json so allow for the subdomain to select the tenant.

"ServerRootAddress": "{TENANCY_NAME}.mydomain.com/",
"ClientRootAddress": "{TENANCY_NAME}.mydomain.com/",
"CorsOrigins": "{TENANCY_NAME}.mydomain.com/"

(Obviously I'm not using mydomain.com in my app!)

However, when I Publish ASPNETZERO to Azure and use my subdomain, it is just ignored and the Tenant selector is always shown.

I've now spent many days trying different approaches but I've run out of ideas to get this working.

So, has anyone managed to use sub domains on an Azure Web App to successfully select the tenant as I'm beginning to wonder if Azure is causing an issue, and if there's a workaround?


6 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @Mitch

    Are you sure that this appsettings.json fiel is used for your app ? Because, when you deploy an app, by default it will use the Production environment and maybe appsettings.Production.json is used in your case.

    You also need to add https:// prefix to URLs you used for ServerRootAddress, ClientRootAddress and CorsOrigins.

  • User Avatar
    0
    Mitch created

    HI @ismcagdas

    I've been trying it with and without the https:// prefix and I've added it to appsettings and appsettings.production.json.

    Nothing seems to work which is why I was asking if anyone had managed to make it work with Azure Web Apps as I was beginning to think there might be a specific issue with Web apps.

    Any suggestions of how what to try next would be appreciated.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I definitely know that some of our customers are using this approach on Azure. Could you check if the below line gets a correct value in MVCModule's PreInitialize method ?

    Configuration.Modules.AbpWebCommon().MultiTenancy.DomainFormat = _appConfiguration["App:WebSiteRootAddress"] ?? "https://localhost:44302/"
    
  • User Avatar
    0
    Mitch created

    BINGO! Thank you so much! I'd correctly set up all the values except for WebSiteRootAddress

    "ServerRootAddress": "https://{TENANCY_NAME}.xxx.cloud/", "ClientRootAddress": "https://{TENANCY_NAME}.xxx.cloud/", "CorsOrigins": "https://{TENANCY_NAME}.xxx.cloud/", "WebSiteRootAddress": THIS WAS INCORRECT!

    Now it's working, is there a simple way of showing the Clients logo on the login screen by using the Tenancy name? i.e. Is it possible to use the TENANCY_NAME to find a matching image that uses the Tenancy name such as {TENANCY_NAME}.jpg

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    There are two ways for this.

    1. Each tenant can upload a logo on their Settings page. This logo must be displayed on Login page automatically.
    2. If you want to setup the tenant logos, you can either upload logo for them (using impersonation from a host account). Or you can get the current tenant's name on login page (using AbpSession.TenantId) and setup the logo url using the tenanctName.
  • User Avatar
    0
    Mitch created

    That's fantastic. Many thanks for all your help.