简体   繁体   English

Azure ZC6E190B284633C48E39E55049DA3CCE8 中的主机 static HTML

[英]Host static HTML in Azure Web App Service

I'm azure beginner我是azure初学者

I've created nodejs service and deployed it to Azure Web App service, it works as expected.我已经创建了 nodejs 服务并将其部署到 Azure Web App 服务,它按预期工作。 So, I have resource group mars-app and existing Web App service application my-mars-web-app .所以,我有资源组mars-app和现有的 Web App 服务应用程序my-mars-web-app

Now, I want to add static HTML file, to show it when user goes to root URL https://***.azurewebsites.net/ Now, I want to add static HTML file, to show it when user goes to root URL https://***.azurewebsites.net/

To achieve it,为了实现它,

  1. I have cloned github repo with client side to azure storage with azure cli help我已经使用 azure cli help 将客户端的 github 存储库克隆到 azure 存储
  2. In cliend code folder, I have tried to run az webapp up -g mars-app -n my-mars-web-app --html , but every time I'm receiving:在客户端代码文件夹中,我尝试运行az webapp up -g mars-app -n my-mars-web-app --html ,但每次我收到:

The webapp my-mars-web-app is a Linux app. webapp my-mars-web-app 是一个 Linux 应用程序。 The code detected at '/home/serhii/azure-website' will default to '<module 'os' from '/opt/az/lib/python3.6/os.py'>'.在“/home/serhii/azure-website”中检测到的代码将默认为“/opt/az/lib/python3.6/os.py”中的“<module 'os'>”。 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由于上述错误,我在我的后端应用程序的 dist 目录中添加了 index.html

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

and it works.它有效。 But I'm not sure it is a good solution但我不确定这是一个好的解决方案

What the best practice to add static HTML files to existing Web App service?将 static HTML 文件添加到现有 Web 应用程序服务的最佳实践是什么?

This question may be a dublicate of this question , but it was asked 5 years ago, so maybe something changed.这个问题可能是这个问题的重复,但它是在 5 年前提出的,所以可能发生了一些变化。

PS I know about Static Web Apps , but it is in preview and I'm interested in more generic solutions. PS 我知道Static Web 应用程序,但它是预览版,我对更通用的解决方案感兴趣。

Thanks in advance提前致谢

[UPDATE] Here an article about deploying react app [更新] 这里有一篇关于部署 React 应用的文章

Why you want to add static HTML files to existing web app services, for update or others ?为什么要将 static HTML 文件添加到现有的 web 应用程序服务中,以进行更新或其他

In my opinon, now that you have used git, you can use continuous deployment .在我看来,既然你已经使用了 git,你就可以使用持续部署了。

When you modify your program (add new or modify files), in the Action of github, you will see the program start to deploy again.当你修改程序(添加新文件或修改文件)时,在 github 的 Action 中,你会看到程序再次开始部署。 This should be the best deployment plan.这应该是最好的部署计划。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM