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

回眸只為那壹抹淺笑 提交于 2020-07-23 06:49:06

问题


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?

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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/62810572/node-application-on-azure-web-app-virtual-directory-is-not-shown

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!