从 Azure Functions 和 trouble-shooting 程序集绑定连接到 WCF 服务
Connecting to WCF service from Azure Functions and trouble-shooting assembly bindings
在哪里可以看到 Azure 函数试图加载的程序集? (喜欢 windows 上的 fuslogvw)
更新
根据要求更新标题以更好地反映已接受的答案
更新
将我的代码更改为 'manually' 使用 WebClient 构造 SOAP 请求并且它有效......所以我认为 WCF 服务代理在 Azure Functions 沙箱中的某个地方不能正常运行......不过我仍然希望得到关于如何查看程序集绑定日志视图的答案。
原版Post
我不断收到同样的错误:
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)
目前不支持查看程序集绑定日志。 Enabling diagnostic logs will help debug most of the errors. Also take a look at logging tips and tricks.
这是一个从您的函数连接到 Azure 中托管的 WCF 服务的示例:
- 进入功能应用程序设置 --> 转到 Kudu --> 转到 D:\home\site\wwwroot\YourFunction
- 创建文件夹bin
- 上传System.ServiceModel.dll
上传 WCF 服务合同 IService1.csx。您可以从门户网站上的 Kudu 或查看文件执行此操作
#r "System.ServiceModel.dll"
using System.ServiceModel;
[ServiceContract]
public interface IService1
{
[OperationContract]
string GetData(int value);
[OperationContract]
string WelComeMessage(String name);
}
调用 WCF 端点的示例队列触发器:
#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}");
}
希望对您有所帮助!
在哪里可以看到 Azure 函数试图加载的程序集? (喜欢 windows 上的 fuslogvw)
更新 根据要求更新标题以更好地反映已接受的答案
更新
将我的代码更改为 'manually' 使用 WebClient 构造 SOAP 请求并且它有效......所以我认为 WCF 服务代理在 Azure Functions 沙箱中的某个地方不能正常运行......不过我仍然希望得到关于如何查看程序集绑定日志视图的答案。
原版Post
我不断收到同样的错误:
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)
目前不支持查看程序集绑定日志。 Enabling diagnostic logs will help debug most of the errors. Also take a look at logging tips and tricks.
这是一个从您的函数连接到 Azure 中托管的 WCF 服务的示例:
- 进入功能应用程序设置 --> 转到 Kudu --> 转到 D:\home\site\wwwroot\YourFunction
- 创建文件夹bin
- 上传System.ServiceModel.dll
上传 WCF 服务合同 IService1.csx。您可以从门户网站上的 Kudu 或查看文件执行此操作
#r "System.ServiceModel.dll" using System.ServiceModel; [ServiceContract] public interface IService1 { [OperationContract] string GetData(int value); [OperationContract] string WelComeMessage(String name); }
调用 WCF 端点的示例队列触发器:
#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}"); }
希望对您有所帮助!