Host static HTML in Web App Service

Serhii Bilyk 1 Reputation point
2020-08-08T18:31:09.767+00:00

Hi, I've created nodejs service and deployed it to Azure Web App service, it works as expected.
So, I have resource group and existing Web App service.

Now, I want to add static HTML file, to show it when user goes to https://my-mars-web-app.azurewebsites.net/

To achieve it, I have tried to run az webapp up -g mars-app -n my-mars-web-app --html, but every time I'm receiving:
The webapp my-mars-web-app is a Linux app. The code detected at '/home/serhii/azure-website' will default to '<module 'os' from '/opt/az/lib/python3.6/os.py'>'. Please create a new app to continue this operation.

Because of above error, I have added index.html to dist diretory in my backend app

app.get('/', function (req, res) {
  res.sendfile('dist/index.html');
}); 

and it works. But it is for sure a bad practice.
My question:
What the best practice to add static HTML files to Web App service?

Thanks in advance

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,930 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. SnehaAgrawal-MSFT 22,706 Reputation points Moderator
    2020-08-10T10:40:50.633+00:00

    Thanks for asking question! There is ongoing discussion on this issue here

    The --html flag defaults to Windows OS and as a workaround, you can add a package.json file the root directory and remove the --html arg. This will tell the CLI to upload as a nodejs runtime.

    You may refer to below blog link for more details on this: https://github.com/Azure/app-service-linux-docs/blob/master/AzWebAppUP/runtime_detection.md


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.