如何将公共静态站点作为Web应用程序托管?

时间:2017-12-18 22:57:30

标签: azure-web-sites

我希望网址www.example.com显示default.html 从这个question我明白,最简单的方法仍然是创建一个网络应用程序。

[怎么不这样做]

我尝试在VS2017中创建解决方案 File-> New - > Project - > .Net Core - > Asp.Net核心Web应用程序 - >空

然后我将静态文件移动到wwwroot并进行部署 我需要更改什么才能在有人访问网站时加载default.html?

目前,如果我删除了Program类,我会收到一条消息

Severity    Code    Description Project File    Line    Suppression State
Error   CS5001  Program does not contain a static 'Main' method suitable for an entry point 

这是可以理解的,因为它是一个Web应用程序,如何将其更改为静态网站?

[更好的方法是在Azure中创建应用。]

我没有使用上述方法,而是创建了一个新的网络应用,并按照this question的建议粘贴到index.html。

我现在可以访问该网站的Azure网址,并显示正确的内容。

接下来我需要让example.com工作。

我使用网站的网址在我的DNS中添加了www的CName记录,我还访问了Azure中的自定义域以添加我的域名。

但是当我访问我的网站时出现以下错误。

Error 404 - Web app not found.
The web app you have attempted to reach is not available in this Microsoft Azure App Service region. This could be due to one of several reasons:

1. The web app owner has registered a custom domain to point to the Microsoft Azure App Service, but has not yet configured Azure to recognize it. Click here to read more.

When an app owner wants to use a custom domain with a Microsoft Azure Web Apps web app, Azure needs to be configured to recognize the custom domain name, so that it can route the request to the appropriate server in the region. After registering the domain with a domain provider and configuring a DNS CNAME record to point to the app's Azurewebsites.net address (for example, contoso.azurewebsites.net), the web app owner also needs to go to the Azure Portal and configure the app for the new domain. Click here to learn more about configuring the custom domains for a web app.

1 个答案:

答案 0 :(得分:0)

我最终得到了它。我一定错过了the documentation

中的一步