Node application on Azure Web App / Virtual Directory is not shown

Viewed 1743

I have already found an article, but none that matches the current Azure Web App configuration option. I guess something has changed in the new version. I am trying to host an Node application via Azure Web App with Linux App Service Plan.

My problem is, my content of the node application is not displayed. Only the Azure Startup page is displayed. I guess the content can't be found which is completely present in site/wwwroot. Therefore I wanted to configure the virtual directory. This option is no longer visible in my Azure Portal?

enter image description here

Then I automated my deployment via Azure ARM Templates and added my virtual directory there. The deployment runs without problems. The configuration is also visible in the template generated via the Azure Portal, but cannot be seen in the screenshot above.

        {
        "type": "Microsoft.Web/sites",
        "apiVersion": "2018-11-01",
        "name": "[parameters('sites__name')]",
        "location": "West Europe",
        "dependsOn": [
            "[resourceId('Microsoft.Web/serverfarms', parameters('serverfarms_asp_name'))]"
        ],
        "kind": "app,linux",
        "properties": {
            "enabled": true,
            "hostNameSslStates": [
                {
                    "name": "[concat(parameters('sites_name'), '.azurewebsites.net')]",
                    "sslState": "Disabled",
                    "hostType": "Standard"
                },
                {
                    "name": "[concat(parameters('sites_name'), '.scm.azurewebsites.net')]",
                    "sslState": "Disabled",
                    "hostType": "Repository"
                }
            ],
            "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('serverfarms_asp_name'))]",
            "reserved": true,
            "isXenon": false,
            "hyperV": false,
            "siteConfig": {},
            "scmSiteAlsoStopped": false,
            "clientAffinityEnabled": true,
            "clientCertEnabled": false,
            "hostNamesDisabled": false,
            "containerSize": 0,
            "dailyMemoryTimeQuota": 0,
            "httpsOnly": true,
            "redundancyMode": "None"
        }
    },
    {
        "type": "Microsoft.Web/sites/config",
        "apiVersion": "2018-11-01",
        "name": "[concat(parameters('sites_name'), '/web')]",
        "location": "West Europe",
        "dependsOn": [
            "[resourceId('Microsoft.Web/sites', parameters('sites_name'))]"
        ],
        "properties": {
            "numberOfWorkers": 1,
            "defaultDocuments": [
                "Default.htm",
                "Default.html",
                "Default.asp",
                "index.htm",
                "index.html",
                "iisstart.htm",
                "default.aspx",
                "index.php",
                "hostingstart.html"
            ],
            "netFrameworkVersion": "v4.0",
            "linuxFxVersion": "NODE|12-lts",
            "requestTracingEnabled": false,
            "remoteDebuggingEnabled": false,
            "remoteDebuggingVersion": "VS2019",
            "httpLoggingEnabled": false,
            "logsDirectorySizeLimit": 35,
            "detailedErrorLoggingEnabled": false,
            "publishingUsername": "$myuser",
            "scmType": "VSTSRM",
            "use32BitWorkerProcess": true,
            "webSocketsEnabled": false,
            "alwaysOn": false,
            "managedPipelineMode": "Integrated",
            "virtualApplications": [
                {
                    "virtualPath": "/",
                    "physicalPath": "site\\wwwroot",
                    "preloadEnabled": false
                }
            ],
            "loadBalancing": "LeastRequests",
            "experiments": {
                "rampUpRules": []
            },
            "autoHealEnabled": false,
            "localMySqlEnabled": false,
            "ipSecurityRestrictions": [
                {
                    "ipAddress": "Any",
                    "action": "Allow",
                    "priority": 1,
                    "name": "Allow all",
                    "description": "Allow all access"
                }
            ],
            "scmIpSecurityRestrictions": [
                {
                    "ipAddress": "Any",
                    "action": "Allow",
                    "priority": 1,
                    "name": "Allow all",
                    "description": "Allow all access"
                }
            ],
            "scmIpSecurityRestrictionsUseMain": false,
            "http20Enabled": false,
            "minTlsVersion": "1.2",
            "ftpsState": "AllAllowed",
            "reservedInstanceCount": 0
        }
    },

I checked the Azure Web App via Kudu, the files like index.html are present in site/wwwroot. The Azure Web App has as base directory /home, inside is site/wwwroot. How can I configure the Virtual Directory? Where is my fault?

Thanks a lot.

3 Answers

Configuration of virtual directories on Linux App Service isn't done the same way as it is on Windows App Service.

The Virtual Directory configuration for Windows App Service maps directly to IIS' virtual directories feature, as all websites on that platform are hosted by IIS. On Linux App Service, you are free to use whatever web server technology you like and configure it however you want.

For now, the easiest way to implement this is to containerize your application with the settings you want, or fork one of our existing built-in containers.

You can add custom storage for your containerized app. Containerized apps include all Linux apps and also the Windows and Linux custom containers running on App Service.

For more details, you could refer to this article.

For my problem solution I changed my Azure App Service Plan as described because there are differences between Linux App Service Plans and Windows App Service Plans.

Via Windows App Service Plan also the Path mappings available, there the Virtual Path and the Physical Path could be configured.

For my application I have set site\wwwroot, because everything can be found there.

enter image description here

For the Linux App Service you can't use virtual folders but there is another way around. Azure allows you to have multiple App Services per 1 App Service Plan. That means you can deploy multiple applications there without any additional costs.

There is also a disadvantage. You cant simply use your own domain. You either use Azure application-gateway for redirecting traffic (extra money needed) or you simply create subdomain for each of these App services. Example: https://api.website.com, https://blog.website.com

Sources:

Application Gateway:

https://azure.microsoft.com/en-us/services/application-gateway/

https://docs.microsoft.com/en-us/azure/application-gateway/create-url-route-portal#create-a-path-based-routing-rule

Multiple App Services per App Service Plan:

https://stackoverflow.com/a/65406771/6158341

https://stackoverflow.com/a/65918048/6158341

https://www.youtube.com/watch?v=dUdT0UiRKVc&ab_channel=StephenHelwigTalksTech

Related