Azure WebJob访问被拒绝

时间:2017-02-24 09:41:30

标签: c# node.js azure port azure-webjobs

所以我在创建服务localy时遇到问题,因为我的应用程序是WebJob。好像我读了所有谷歌,但我找不到解决方案。 This one here并不代表我,因为它是关于认证的。

所以,我在我的电脑上有一个C#控制台应用程序,带有许多引用,ddls和许多像服务一样运行的计算。主要功能,如下所示:

    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#app创建一个WebJob。我发布它并尝试运行它,但我得到(这个错误是flom azure portal console):

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#app是否无法从外部访问,我只想让这两个人进行沟通。有任何想法吗?或者其他解决方案(VM除外)?

1 个答案:

答案 0 :(得分:2)

如下面的文档所述 每个应用程序都会看到“私有”环回连接; app“A”无法收听应用“B”建立的本地环回套接字。

Operating system functionality on Azure App Service

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

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

如果要从WebJobs向节点应用程序发回消息,请同时收听节点应用程序中的队列并向队列中插入消息。

相关问题