Connecting to WCF service from Azure Functions and trouble-shooting assembly bindings

3

Where can I see the Assembly that Azure functions is trying to load ? (Like fuslogvw on windows)

Update Update the title as requested to better reflect the accepted answer

Update

Changed my code to 'manually' construct the SOAP request using WebClient and it works ... so me thinks somewhere the WCF service proxy is not playing well within the sandbox that is Azure Functions ... Nevertheless I would still like an answer as to how we can see the Assembly binding log views.

Original Post

I keep getting the same error :

2016-11-17T10:32:44.392 System.IO.FileNotFoundException: The filename, directory name, or volume label syntax is incorrect. (Exception from HRESULT: 0x8007007B)

Server stack trace:

at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)

at Microsoft.Win32.Fusion.ReadCache(ArrayList alAssems, String name, UInt32 nFlag)

at System.Reflection.RuntimeAssembly.EnumerateCache(AssemblyName partialName)

at System.Reflection.RuntimeAssembly.LoadWithPartialNameInternal(AssemblyName an, Evidence securityEvidence, StackCrawlMark& stackMark)

at System.Reflection.Assembly.LoadWithPartialName(String partialName, Evidence securityEvidence)

at System.Xml.Serialization.TempAssembly.LoadGeneratedAssembly(Type type, String defaultNamespace, XmlSerializerImplementation& contract)

at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings, Type type)

at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.SerializerGenerationContext.GenerateSerializers()

at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.SerializerGenerationContext.GetSerializer(Int32 handle)

at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.MessageInfo.get_BodySerializer()

at System.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.SerializeBody(XmlDictionaryWriter writer, MessageVersion version, String action, MessageDescription messageDescription, Object returnValue, Object[] parameters, Boolean isRequest)

at System.ServiceModel.Dispatcher.OperationFormatter.SerializeBodyContents(XmlDictionaryWriter writer, MessageVersion version, Object[] parameters, Object returnValue, Boolean isRequest)

at System.ServiceModel.Dispatcher.OperationFormatter.OperationFormatterMessage.OperationFormatterBodyWriter.OnWriteBodyContents(XmlDictionaryWriter writer)

at System.ServiceModel.Channels.BodyWriterMessage.OnWriteBodyContents(XmlDictionaryWriter writer)

at System.ServiceModel.Channels.Message.OnWriteMessage(XmlDictionaryWriter writer)

at System.ServiceModel.Channels.TextMessageEncoderFactory.TextMessageEncoder.WriteMessage(Message message, Stream stream)

at System.ServiceModel.Channels.HttpOutput.WriteStreamedMessage(TimeSpan timeout)

at System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout)

at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.SendRequest(Message message, TimeSpan timeout)

at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)

at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)

at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)

at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)

at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:

at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)

at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

azure
azure-functions
asked on Stack Overflow Nov 17, 2016 by Le Roi Beukes • edited Nov 21, 2016 by Le Roi Beukes

1 Answer

4

Currently, there is no support to view assembly binding logs. Enabling diagnostic logs will help debug most of the errors. Also take a look at logging tips and tricks.

Here is a sample for connecting to a WCF service hosted in Azure from your function:

  1. Got to Function App Settings --> Go to Kudu --> Go to D:\home\site\wwwroot\YourFunction
  2. Create folder bin
  3. Upload System.ServiceModel.dll
  4. Upload WCF service contract IService1.csx. You can do this from either Kudu or View Files on the portal

     #r "System.ServiceModel.dll"
    
     using System.ServiceModel;
    
     [ServiceContract]
     public interface IService1
     {
         [OperationContract]
         string GetData(int value);
    
         [OperationContract]
         string WelComeMessage(String name);
     }
    
  5. Sample queue trigger that invokes WCF endpoint:

    #r "System.ServiceModel.dll"
    #load "IService1.csx"
    
    using System;
    using System.ServiceModel;
    
    public static void Run(string myQueueItem, TraceWriter log)
    {
        log.Info($"C# Queue trigger function processed: {myQueueItem}");
    
        BasicHttpBinding b = new BasicHttpBinding();
        EndpointAddress ea = new  EndpointAddress("http://YourServiceAddress/service1.svc?wsdl");
        var myChannelFactory = new ChannelFactory<IService1>(b, ea);
        IService1 client = myChannelFactory.CreateChannel();
        var msg= client.WelComeMessage("HelloWorld");
        ((ICommunicationObject)client).Close();
        log.Info($"Hello from WCF: {msg}");
     }
    

Hope this helps!

answered on Stack Overflow Nov 17, 2016 by Pragna Gopa • edited Nov 17, 2016 by Pragna Gopa

User contributions licensed under CC BY-SA 3.0