Azure应用程序适用于开发架构,但不适用于部署

问题描述:

我最近将Access Control Service纳入我们的应用程序。它在开发结构中100%正常工作(没有任何异常被抛出)。但是,在实际的天蓝色网站上运行时,它无法加载网站。Azure应用程序适用于开发架构,但不适用于部署

我已经在整个网站的日志记录调用中添加了,并且只有在FireStart()方法的WebRole的开始和结束时才会触发。我已经将日志记录添加到应该打的控制器中,并且永远不会调用它。我还将日志记录添加到在我的自定义WSFederationAuthenticationModule中重写的“InitializePropertiesFromConfiguration”方法中,这导致我相信它在web配置中执行某些操作时遇到了问题(添加了我的自定义STS处理程序等)。下面是我的应用程序的web.config,如果任何人有任何想法可能会导致这样的问题,甚至至少有东西要尝试,我会非常感激。更糟糕的是,工作防火墙问题意味着我无法远程访问蔚蓝的机器,以查看向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配置需要这样的: 因为我“VE切换到https

第二个问题与证书中装载的事:

注释掉的代码这一部分,它运行良好。它仍然存在,它不起作用。最明显的问题是它无法加载这个证书。我试过用thumbprint加载,而没有用。我最好的猜测是storeLocation或storeName在azure上不正确。我已将证书添加到“证书”文件夹中,但无法找到它。我会惹恼这些并报告回来。

EDIT2: 找到的第二个问题的原因: 我忘了证书添加到Web角色,这个网站是一个很大的帮助,以找出答案: http://blogs.msdn.com/b/jnak/archive/2009/12/01/how-to-add-an-https-endpoint-to-a-windows-azure-cloud-service.aspx

你使用的是Windows身份验证基础在你的角色?

看看这个博客文章我写了这解释了我使用Access Control时遇到的问题。部署之后,您很可能错过了Azure中的WIF dll。 WIF的dll需要在GAC中。您也可以使用Intellitrace来找出角色未启动的原因。

http://blog.cloudish.net/the-cloudish-blog/2012/3/28/how-to-install-the-windows-identity-foundation-runtime-on-de.html

+0

我也想指出的是,最好的方法来诊断Azure中的一个问题是使用的IntelliTrace VS试图RDP到虚拟服务器。 – Zoltan 2012-03-30 16:46:59

+0

我以前从来没有听说过Intellitrace,我得仔细研究一下。感谢那! – 2012-03-30 20:11:57

+0

Intellitrace在VS2010中出现,它非常甜! – Zoltan 2012-04-02 14:14:06

关于你的证书问题,你确定你添加它作为一个服务证书,而不是一个管理证书?

您可能还想查看身份开发人员培训工具包。它有一个分步实验室,名为“Windows Azure中的Web服务和身份”,它演示了如何创建和部署由WIF支持的网站。您应该查看证书部分,以确保您的一切都是正确的,无论是在开发结构实例中还是在天蓝色中。

http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=14347