python - 更新 Azure 服务计划后 Flask 应用程序失败

标签 python azure visual-studio-2015 flask

我有一个在 Azure 上运行的 Flask 应用程序。它一直运行得很好,直到我将 Azure 服务计划从“D1 共享”更新为“S1 标准”。

尝试访问该应用程序时,出现以下错误:

Server Error in '/' Application.

Couldn't find type for class Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Configuration.ConfigurationErrorsException: Couldn't find type for class Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[ConfigurationErrorsException: Couldn't find type for class Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.]
System.Diagnostics.TraceUtils.GetRuntimeObject(String className, Type baseType, String initializeData) +6967379
System.Diagnostics.TypedElement.BaseGetRuntimeObject() +45
System.Diagnostics.ListenerElement.GetRuntimeObject() +83
System.Diagnostics.ListenerElementsCollection.GetRuntimeObject() +142 System.Diagnostics.TraceInternal.get_Listeners() +185
System.Diagnostics.TraceInternal.WriteLine(String message) +119
System.Diagnostics.Debug.WriteLine(String message) +9
Microsoft.Web.Compilation.Snapshots.SnapshotHelper.RestoreSnapshot(String options) +359

[TargetInvocationException: Exception has been thrown by the target of an invocation.] System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +160
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +101 System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) +2026
System.Web.Compilation.BuildManager.RestorePortableCompilationOutputSnapshot() +10008589 System.Web.Compilation.BuildManager.ExecutePreAppStart() +18 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +531

[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9963380 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

我尝试将服务计划更改回“D1 Shared”,然后应用程序再次正常运行。

我看过很多帖子都说要确保解决方案引用“Microsoft.Azure.Plugins.Diagnostics.dll”。我尝试通过“右键单击”->“引用”->“添加引用...”->“.NET”->“Microsoft.Azure.Plugins.Diagnostics”来执行此操作。当我再次发布时,我可以在“bin”文件夹中看到该 dll。但我仍然遇到同样的错误。

我是否以错误的方式进行引用?如果是这样,我该如何正确地做到这一点。

我还应该做些什么才能使我的解决方案适用于“S1 Standard”?

最佳答案

这是解决方案:

转到Azure 门户 -> 应用程序设置,然后将'WEBSITE_DYNAMIC_CACHE' 的值设置为“0”(零),即可禁用动态缓存。

完成这些步骤后,尝试将您的定价层从共享扩展到标准。 enter image description here

关于python - 更新 Azure 服务计划后 Flask 应用程序失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43630361/

相关文章:

python - 将函数应用于 MultiIndex pandas.DataFrame 列

python - 如何使用 python 在新数据框中复制当前行和下一行值?

c - 仍然不明白 C 中指向数字数组的指针

python - Pygame 暂停时显示文本

python - 巴士路线 : obtaining multiple routes from only 2 stops per route

azure - 将文件从 Azure VM 复制到 Azure Blob 存储

azure - 以编程方式从 ID 获取 Azure Active Directory 租户名称

azure - Cosmos DB SDK v3 中的首选位置

browser - 发布asp.net应用程序后,如何防止Visual Studio 2015启动浏览器?

visual-studio-2015 - 安装后许可证过期 Microsoft Visual Studio 2015 社区