2016-09-29 141 views
0

我是WCF的新手。我创建了返回文件的WCF方法。我其部署到Azure应用服务和它的工作时,我把它叫做这样Azure托管的WCF Azure Active Directory身份验证返回404

https://myapp.azurewebsites.net/myService.svc/MyMethod?MyParam=MyValue 

比我开启蔚蓝应用服务Azure的Active Directory身份验证,现在我得到404错误。但是,对AAD进行身份验证的作品 - 我被重定向到登录页面,如果我没有在用户中烧录。

我那么搜索和谷歌,我想不出我做错了什么,或者如果它仅仅是不可能建立这种方式与WCF。

Web配置:

<?xml version="1.0"?> 
<configuration> 

    <appSettings> 
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/> 
    </appSettings> 
    <system.web> 
    <customErrors mode="Off"/> 
    <compilation targetFramework="4.5.2"/> 
    <httpRuntime targetFramework="4.5.2"/> 
    <httpModules> 
     <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/> 
    </httpModules> 
    </system.web> 

    <system.serviceModel> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    <bindings> 
     <webHttpBinding> 
     <binding name="ServiceWebBindingName" transferMode="Streamed" maxReceivedMessageSize="2147483647" > 
      <readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" /> 
     </binding> 
     </webHttpBinding> 
    </bindings> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="DefaultRestServiceBehavior"> 
      <webHttp defaultOutgoingResponseFormat="Json" defaultBodyStyle="Wrapped" automaticFormatSelectionEnabled="false"/> 
     </behavior> 
     </endpointBehaviors> 
     <serviceBehaviors> 
     <behavior name=""> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <services> 
     <service name="My.App.Service"> 
     <endpoint address="myService.svc" 
       binding="webHttpBinding" 
       bindingConfiguration="ServiceWebBindingName" 
       behaviorConfiguration="DefaultRestServiceBehavior" 
       name="FileManagerServiceEndpoint" 
       contract="My.App.IService"/> 
     </service> 
    </services> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"> 
     <remove name="ApplicationInsightsWebTracking"/> 
     <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" 
     preCondition="managedHandler"/> 
    </modules> 
    <!-- 
     To browse web app root directory during debugging, set the value below to true. 
     Set to false before deployment to avoid disclosing web app folder information. 
     --> 
    <directoryBrowse enabled="false"/> 
    <validation validateIntegratedModeConfiguration="false"/> 
    </system.webServer> 

</configuration> 
+0

你检查了这个帖子,谈论wcf + AAD集成https://dzone.com/articles/exercise-3-securing-wcf – Aravind

+0

我做了,在文章中,他们没有使用设置认证的azure主机,但是如果我正确地理解了这些内容,就可以在代码中做所有事情 – Evlo

+0

啊,认证部分的代码做.. – Aravind

回答

0

所以我发现我没有注意到,那我原来的服务URL是

http://myapp.azurewebsites.net/myService.svc/MyMethod?MyParam=MyValue 

和一个我是加入蔚蓝广告验证后重定向到了

https://myapp.azurewebsites.net/myService.svc/MyMethod?MyParam=MyValue 

因此重定向到HTTPS而不是HTTP。

这可能是可以设置蔚蓝ad应用不强制HTTPS流量,但在安全的精神,避免我添加HTTPS传输到我的WCF在web.config中绑定IE浏览器可以切换区的问题。这里是一个很好的例子,如何做到这一点How to enable HTTPS on WCF RESTful Service?它现在完美无瑕。

相关问题