Azure WebJob访问被拒绝

所以我有一个问题创build一个服务localy,为我的应用程序作为一个WebJob。 好像我读了所有的谷歌,但我找不到解决scheme。 这个在这里不算我的,因为它是关于authentication的。

所以,我有一个C#控制台应用程序在我的电脑上有许多参考,ddls和大量的计算运行像一个服务。 主要function,如下所示:

static void Main(string[] args) { string baseAddress = "http://127.0.0.1:80"; Console.WriteLine(baseAddress); if (args.Count() > 0 && !string.IsNullOrEmpty(args[0])) baseAddress = args[0]; SelfHostServer server = new SelfHostServer(); //using Microsoft.Owin; server.Start(baseAddress); } 

然后,我在Azure AppService上发布了一个nodeJs应用程序。 基本上,我需要它来调用C#服务,并得到一个响应结果。 出于这个原因,我试图用我的C#应用​​程序创build一个WebJob。 我发布它,并尝试运行它,但我得到(这个错误是flom天青门户控制台):

 Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Net.HttpListenerException: Access is denied at System.Net.HttpListener.SetupV2Config() at System.Net.HttpListener.Start() at Microsoft.Owin.Host.HttpListener.OwinHttpListener.Start(HttpListener listener, Func`2 appFunc, IList`1 addresses, IDictionary`2 capabilities, Func`2 loggerFactory) at Microsoft.Owin.Host.HttpListener.OwinServerFactory.Create(Func`2 app, IDictionary`2 properties) --- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Microsoft.Owin.Hosting.ServerFactory.ServerFactoryAdapter.Create(IAppBuilder builder) at Microsoft.Owin.Hosting.Engine.HostingEngine.StartServer(StartContext context) at Microsoft.Owin.Hosting.Engine.HostingEngine.Start(StartContext context) at Microsoft.Owin.Hosting.Starter.DirectHostingStarter.Start(StartOptions options) at Microsoft.Owin.Hosting.Starter.HostingStarter.Start(StartOptions options) at Microsoft.Owin.Hosting.WebApp.StartImplementation(IServiceProvider services, StartOptions options) at Microsoft.Owin.Hosting.WebApp.Start(StartOptions options) at Microsoft.Owin.Hosting.WebApp.Start[TStartup](StartOptions options) at Avilda.Klevas.Core.Server.SelfHostServer.Start(String baseAddress) at klevas.webapistart.Program.Main(String[] args) 

它看起来像是一个港口问题,但我找不到任何正确的。 我能够运行其他的exe,但不是谁听的人。 我不在乎C#应用程序是不是可以从外面访问,我只是想让这两个人沟通。 有任何想法吗? 或者也许还有其他解决scheme(VM除外)?

如下面的文件指出, 每个应用程序看到一个“私人”回环连接; 应用程序“A”不能监听由应用程序“B”build立的本地回送套接字。

Azure App Service上的操作系统function

由于听取端口是不允许的,我build议你听队列存储。 任何想要将消息发送到WebJobs的应用程序都可以向队列存储插入消息。 WebJobs SDK为您提供了一个简单的方法来做到这一点。 以下代码供您参考。 如果消息已经插入队列1,将触发以下方法。

 public static void ProcessQueueMessage([QueueTrigger("queue1")] string logMessage, TextWriter logger) { logger.WriteLine(logMessage); } 

如果您想从WebJobs发回消息到节点应用程序,也请在您的节点应用程序中监听队列,并将消息插入到队列中。