【发布时间】:2020-05-02 08:16:58
【问题描述】:
问题 我正在尝试在 Azure 上部署一个 Angular 应用程序(Angular 版本 - 8.2.14)。 我用 Kudu 来部署应用程序,代码是从我的 Github Repo 部署的。部署状态为“成功”。
访问已部署 Web 应用程序的 URL 时出错 "您无权查看此目录或页面。"
尝试解决问题的方法 为了获得有关错误的更多详细信息,我尝试在“应用服务日志”部分中启用“详细错误消息”。但我也无法从中获得太多信息。我在“详细错误消息”中找到的唯一信息是“当读取 Web 服务器或 Web 应用程序的配置文件出现问题时会发生此错误。在某些情况下,事件日志可能包含有关是什么导致了这个错误。"
我还检查了事件日志,我找到了以下信息,
Exception: System.IO.IOException
Message: The handle is invalid.
StackTrace: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.__ConsoleStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
at System.IO.StreamWriter.Write(String value)
at System.IO.TextWriter.SyncTextWriter.Write(String value)
at Kudu.Core.Infrastructure.ProgressWriter.IdleWriter(Object state) in C:\Kudu Files\Private\src\master\Kudu.Core\Infrastructure\ProgressWriter.cs:line 109
at System.Threading.TimerQueueTimer.CallCallbackInContext(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.TimerQueueTimer.CallCallback()
at System.Threading.TimerQueueTimer.Fire()
at System.Threading.TimerQueue.FireNextTimers()
at System.Threading.TimerQueue.AppDomainTimerCallback(Int32 id)</Data></EventData></Event><Event><System><Provider Name="HttpPlatformHandler"/><EventID>2000</EventID><Level>4</Level><Task>0</Task><Keywords>Keywords</Keywords><TimeCreated SystemTime="2020-05-01T16:57:34Z"/><EventRecordID>385268109</EventRecordID><Channel>Application</Channel><Computer>RD501AC5040133</Computer><Security/></System><EventData><Data>APPLICATION_MANAGER::~APPLICATION_MANAGER | this=05B6D878 [TID 6180] [PID 5664]</Data></EventData></Event><Event><System><Provider Name=".NET Runtime"/><EventID>1026</EventID><Level>1</Level><Task>0</Task><Keywords>Keywords</Keywords><TimeCreated SystemTime="2020-05-01T16:57:35Z"/><EventRecordID>385269218</EventRecordID><Channel>Application</Channel><Computer>RD501AC5040133</Computer><Security/></System><EventData><Data>Application: w3wp.exe
Framework Version: v4.0.30319
我正在尝试其他选项(主要是查看有关在 Azure 上部署 Angular 应用程序的教程),但还没有幸运地解决此问题。 web.config
<!-- indicates that the index.js file is a node.js application
to be handled by the iisnode module -->
<handlers>
<add name="iisnode" path="index.js" verb="*" modules="iisnode" />
</handlers>
<!-- adds index.js to the default document list to allow
URLs that only specify the application root location,
e.g. http://mysite.antarescloud.com/ -->
<defaultDocument enabled="true">
<files>
<add value="index.js" />
</files>
</defaultDocument>
<system.web>
<customErrors mode="Off" />
</system.web>
</system.webServer>
</configuration>
【问题讨论】:
-
从应用服务发布您的项目目录树和
web.config。很可能 web.config 不知道如何访问您的 index.html。如果您想避免所有这些不必要的 IIS 舞蹈,请改为部署到 Linux 工作者(应用服务两者都有)。 -
@evilSnobu 我添加了目录树和 web.config。同时,我还将研究基于 Linux Worker 的部署。
-
您发布了源项目,而不是您的
dist内容(webpacked 的东西)。您的源使应用服务生成了特定于 Node.js 的 web.config,因此您需要清除 Web 应用并仅重新部署dist中的静态文件。重新部署后,d:\home\site\wwwroot下应该有index.html, main.js, any_other.js。 -
您的意见帮助我解决了这个问题。在配置部分 -- 路径映射下,我将虚拟应用程序的物理路径更改为 'site\wwwroot\dist'