![](/img/trans.png)
[英]Logging only works localy, but not when deployed to Microsoft Azure App Service
[英]Azure app works on dev fabric but not when deployed
我最近将访问控制服务并入了我们的应用程序。 而且它在开发架构中可以100%正常工作(不会引发任何异常)。 但是,在实际的天蓝色网站上运行此文件时,它无法加载该网站。
我已经在整个网站上记录了调用,并且在OnStart()方法中唯一触发的是WebRole的开始和结束。 我已经添加了登录到应该被点击的控制器的信息,并且从未被调用过。 我还添加了登录到我的自定义WSFederationAuthenticationModule中覆盖的“ InitializePropertiesFromConfiguration”方法的记录,这使我相信它在Web配置(添加自定义STS处理程序等)中执行某些操作时遇到了问题。 下面是我的应用程序的web.config,如果有人知道是什么原因导致此类问题的发生,或者至少可以尝试一下,我将非常感激。 更糟的是,工作防火墙问题意味着我无法远程进入azure计算机,以查看Windows日志中引发了哪些错误。 我不知所措,可能是什么问题。
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=152368
-->
<configuration>
<configSections>
<section name="microsoft.identityModel" type="Microsoft.IdentityModel.Configuration.MicrosoftIdentityModelSection, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</configSections>
<system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>
</system.diagnostics>
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<globalization culture="en" uiCulture="en"/>
<httpRuntime requestValidationMode="2.0" />
<authentication mode="None" />
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
<add namespace="TBX.Common.Web"/>
<add namespace="TBX.Pulse.Web"/>
</namespaces>
</pages>
<httpModules>
<add name="WSFederationAuthenticationModule" type="TBX.Pulse.Web.Authentication.CustomWSFederationAuthenticationModule, TBX.Pulse.Web"/>
<add name="SessionAuthenticationModule" type="Microsoft.IdentityModel.Web.SessionAuthenticationModule, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</httpModules>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<add name="WSFederationAuthenticationModule" type="TBX.Pulse.Web.Authentication.CustomWSFederationAuthenticationModule, TBX.Pulse.Web" preCondition="managedHandler"/>
<add name="SessionAuthenticationModule" type="Microsoft.IdentityModel.Web.SessionAuthenticationModule, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="managedHandler" />
</modules>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="TBX.Pulse.Web.Scripts.ButtonClickAnimationAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false" />
<extensions>
<behaviorExtensions>
<add name="federatedServiceHostConfiguration" type="Microsoft.IdentityModel.Configuration.ConfigureServiceHostBehaviorExtensionElement, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</behaviorExtensions>
</extensions>
<protocolMapping>
<add scheme="http" binding="ws2007FederationHttpBinding" />
</protocolMapping>
<bindings>
</bindings>
</system.serviceModel>
<microsoft.identityModel>
<service>
<claimsAuthorizationManager type="TBX.Pulse.Web.Authorization.CustomClaimsAuthorizationManager" />
<claimsAuthenticationManager type="TBX.Pulse.Web.Authentication.CustomClaimsAuthenticationManager" />
<securityTokenHandlers>
<remove type="Microsoft.IdentityModel.Tokens.Saml2.Saml2SecurityTokenHandler, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add type="TBX.Pulse.Web.Authentication.CustomSecurityTokenHandler, TBX.Pulse.Web"/>
</securityTokenHandlers>
<certificateValidation certificateValidationMode="None" />
<serviceCertificate>
<certificateReference x509FindType="FindBySubjectName" findValue="PulseLoginCert" />
</serviceCertificate>
</service>
</microsoft.identityModel>
</configuration>
编辑:在解决这个问题后,我发现了2个问题,一个我已经解决的问题仍然需要解决:第一个问题是Web配置需要此问题:因为我已经切换到https
第二个问题与证书的加载有关:
注释掉这部分代码,可以正常运行。 它仍然在那里不起作用。 那么,很明显的问题是它无法加载此证书。 我尝试通过指纹加载,但无济于事。 我最好的猜测是,天蓝色的storeLocation或storeName不正确。 我已将证书添加到“证书”文件夹中,但找不到它。 我会把这些弄乱并报告。
EDIT2:找到了第二个问题的起因:我忘记将证书添加到Web角色,此站点对于弄清楚该问题提供了很大帮助: http : //blogs.msdn.com/b/jnak/archive/2009/ 12/01 /如何添加HTTP端点到Windows Azure云服务.aspx
您是否正在使用Windows Identity Foundation?
看看我写的这篇博客文章,它解释了我在访问控制方面遇到的问题。 部署后,您很有可能会在Azure中丢失WIF dll。 WIF的dll必须在GAC中。 您还可以使用Intellitrace找出为什么角色没有启动的原因。
关于您的证书问题,确定要将其添加为服务证书而不是管理证书吗?
您可能还需要签出Identity Developer培训套件。 它有一个名为“ Windows Azure中的Web服务和身份”的分步实验室,该实验室演示了如何创建和部署WIF支持的网站以实现蔚蓝。 您应该查看证书部分,以确保开发架构实例和Azure中的一切都正确无误。
http://www.microsoft.com/download/zh-CN/details.aspx?displaylang=en&id=14347
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.