Azure / Azure-Functions

1.1k stars 191 forks source link

Calling WCF from Azure function through web relay throw error. #2441

Open linujohn22 opened 5 months ago

linujohn22 commented 5 months ago

We have WCF service deployed on On Premise and it is exposed in Azure through Azure web relay (WCF). Reference :https://learn.microsoft.com/en-us/azure/azure-relay/service-bus-dotnet-hybrid-app-using-service-bus-relay This WCF is created in .Net Framework 4.7.2 version .

Our requirement is to call this WCF service from Azure function . The azure function framework is .Net7.0 .

We use below code in Azure function to call this WCF service through Web Relay.

// Define the service URL and binding string serviceUrl = "sb://URL"; // Create the channel factory // Create shared access signature token credentials for authentication. channelFactory = new ChannelFactory(new BasicHttpBinding(), new EndpointAddress(serviceUrl)); channelFactory.Endpoint.Address.Equals(new TransportClientEndpointBehavior { TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider("RootManageSharedAccessKey", "Key") });

We add Nuget package

Microsoft Azure.service.Bus System.servicemodel.http System.servicemodel.Primitives window.azure.service

We are getting below error while executing lines Code : channelFactory.Endpoint.Address.Equals(new TransportClientEndpointBehavior { TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider("RootManageSharedAccessKey", "Key") });

Error System.Private.CoreLib: Exception while executing function: FunWebRelayCall. AFwcfWebrelayCall: Could not load file or assembly 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.

we are unable to find .net7 code for using TransportClientEndpointBehavior

bhagyshricompany commented 5 months ago

Thanks for reporting will check and confirm the same.pls share the repro steps.and func app name.