简体   繁体   English

使用Azure App Service中托管的WCF服务时出现凭据错误

[英]Credential Error while consuming the WCF Service hosted in Azure App Service

I have created a WCF Service using "Cloud Service >> WCF Web Role" (as shown below). 我已经使用“云服务>> WCF Web角色”创建了WCF服务(如下所示)。 ( This is just a test exercise that I have been conducting to ensure that WCF can be hosted in Azure App Service and connection via External App created with C# works. ) 这只是我进行的一项测试练习,以确保可以将WCF托管在Azure App Service中并通过使用C#作品创建的外部应用程序进行连接。

[enter image description here] 1 [在此处输入图像描述] 1

My WebConfig is as below: 我的WebConfig如下:

 <?xml version="1.0"?> <configuration> <system.diagnostics> <trace> <listeners> <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics"> <!--<filter type="" />--> </add> </listeners> </trace> </system.diagnostics> <system.web> <compilation debug="true" targetFramework="4.6.1" /> <authentication mode="None"/> </system.web> <system.serviceModel> <!--DECLARE BINDINGS--> <bindings> <wsHttpBinding> <binding name="CustomBinding" openTimeout="00:20:00" receiveTimeout="00:20:00" closeTimeout="00:20:00" sendTimeout="00:20:00" > <security mode="None"> <transport clientCredentialType="None" proxyCredentialType="None" realm=""/> <message algorithmSuite="Default" clientCredentialType="None"/> </security> </binding> </wsHttpBinding> </bindings> <!--DECLARE BEHAVIOUR--> <behaviors> <serviceBehaviors> <behavior name="CustomBehaviour"> <!-- To avoid disclosing metadata information, set the value below to false before deployment --> <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/> <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> <serviceDebug includeExceptionDetailInFaults="true"/> </behavior> </serviceBehaviors> </behaviors> <!--CREATE SERVICE WITH ENDPOINTS--> <services> <!-- Service For Main Implementation--> <service name="DolphinBimUserRegistration.Service1" behaviorConfiguration="CustomBehaviour"> <endpoint address="DBWsHttp" binding="wsHttpBinding" bindingConfiguration="CustomBinding" contract="DBIMInterface.IDBIMService"/> </service> </services> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> <!-- 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="true"/> </system.webServer> </configuration> 

After publishing the WCF Service to Azure App Service, I am able to create a service reference. 将WCF服务发布到Azure App Service之后,我可以创建服务引用。 Everything works perfect till here.. 一切正常,直到这里。

During debugging, when I try to call the basic "GetData" Function inside the WCF Service, it frequently requests for the User Credential (as shown in below image). 在调试期间,当我尝试在WCF服务中调用基本的“ GetData”功能时,它经常会请求用户凭据(如下图所示)。

enter image description here 在此处输入图片说明

I need to find a way to access my azure web app service without entering the credentials manually. 我需要找到一种无需手动输入凭据即可访问我的Azure Web应用程序服务的方法。 I have been trying to sort this out for long time. 我一直在努力解决这个问题。 Nothing seems to be working. 似乎没有任何作用。

  • I read somewhere that we can enter the credentials obtained by using "Get Publish Profile" inside Azure can be used to log in. But, that doesn't seem like a good approach. 我读到某个地方,我们可以输入通过使用Azure内的“获取发布配置文件”获得的凭据可以登录。但是,这似乎不是一个好方法。 We cannot enter such confidential information inside the client application. 我们无法在客户端应用程序中输入此类机密信息。 When the Client Application is used by different people, they should not be entering the credentials to reach Azure Web App. 当客户端应用程序由其他人使用时,他们不应输入凭据以访问Azure Web App。 How do I avoid entering the credentials? 如何避免输入凭据? How does visual studio (or client application) make connection to the Azure Web app? Visual Studio(或客户端应用程序)如何建立与Azure Web应用程序的连接?

I must ask - why are you opting to use WCF over ASP.NET Web API (or any other modern RESTFul framework) for your services? 我必须问-您为什么选择在ASP.NET Web API(或任何其他现代RESTFul框架)上使用WCF? OAuth/JWT is what modern services in the cloud use for security. OAuth / JWT是云中现代服务用于安全性的工具。 APIs are protected by a client ID and secret which can be created in Azure AD. API受可以在Azure AD中创建的客户端ID和密码保护。 I don't think you'll find much support out there for WCF in Azure. 我认为您不会在Azure中为WCF找到很多支持。 Either way, if you must use WCF, here's a reference towards using OAuth for WCF: OAuth and WCF SOAP service 无论哪种方式,如果必须使用WCF,以下是将OAuth用于WCF的参考: OAuth和WCF SOAP服务

To answer your other question, Visual Studio uses a publish profile to deploy a web app to Azure. 为了回答您的其他问题,Visual Studio使用发布配置文件将Web应用程序部署到Azure。 When you first attempt to publish from Visual Studio, it will allow you to import a publish profile. 首次尝试从Visual Studio发布时,它将允许您导入发布配置文件。 You can either obtain this from your Azure App Service's dashboard or you can point Visual Studio to your App Service in Azure. 您可以从Azure App Service的仪表板获取此信息,也可以将Visual Studio指向Azure中的App Service。 This dialog will give you the option to persist your credentials. 该对话框将为您提供保留凭据的选项。

在此处输入图片说明

You will find two types of files for each publish profile, a .pubxml file and a .pubxml.user file. 您将为每种发布配置文件找到两种类型的文件:.pubxml文件和.pubxml.user文件。 For Web Deploy and FTP publishing, the .pubxml.user file contains the password, in encrypted form. 对于Web Deploy和FTP发布,.pubxml.user文件包含加密形式的密码。 The username can be found in the .pubxml file. 用户名可以在.pubxml文件中找到。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM