Azure WebJob 访问被拒绝

Azure WebJob access denied

所以我在为我的应用程序作为 WebJob 创建本地服务时遇到了问题。好像我阅读了所有 google,但我找不到解决方案。 This one here 对我来说不算数,因为它是关于身份验证的。

所以,我的电脑上有一个 C# 控制台应用程序,其中包含许多引用、ddls 和大量计算,运行s 就像一个服务。主要功能,如下所示:

    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# 应用程序创建一个 WebJob。我发布它并尝试 运行 它,但我得到(这个错误是 flom azure 门户控制台):

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# 应用程序是否无法从外部访问,我只希望这两个应用程序能够进行通信。有任何想法吗?或者其他解决方案(VM 除外)?

如以下文档所述每个应用程序都会看到一个 "private" 环回连接; app "A" 无法侦听由 app "B".

建立的本地环回套接字

Operating system functionality on Azure App Service

由于监听端口不被允许,建议您改为监听队列存储。任何想要向您的 WebJobs 发送消息的应用程序都可以将消息插入队列存储。 WebJobs SDK 为您提供了一种简单的方法。以下代码供您参考。如果消息已插入队列1,将触发以下方法。

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

如果您想将消息从您的 WebJobs 发送回节点应用程序,还请在您的节点应用程序中收听队列并向队列插入一条消息。