locked
OWIN self-hosted access is denied RRS feed

  • Question

  • Hello.

    I am trying to run Topshelf-based windows service as OWIN self-hosted Web API in Azure App Service.

    But I always get recycling on startup with the following error:

    [06/17/2016 14:58:52 > 0ae556: INFO] Topshelf.Hosts.ConsoleRunHost Error: 0 : An exception occurred, System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Net.HttpListenerException: Access is denied
    [06/17/2016 14:58:52 > 0ae556: INFO]    at System.Net.HttpListener.SetupV2Config()
    [06/17/2016 14:58:52 > 0ae556: INFO]    at System.Net.HttpListener.Start()
    [06/17/2016 14:58:52 > 0ae556: INFO]    at Microsoft.Owin.Host.HttpListener.OwinHttpListener.Start(HttpListener listener, Func`2 appFunc, IList`1 addresses, IDictionary`2 capabilities, Func`2 loggerFactory)
    [06/17/2016 14:58:52 > 0ae556: INFO]    at Microsoft.Owin.Host.HttpListener.OwinServerFactory.Create(Func`2 app, IDictionary`2 properties)
    [06/17/2016 14:58:52 > 0ae556: INFO]    --- End of inner exception stack trace ---
    [06/17/2016 14:58:52 > 0ae556: INFO]    at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
    [06/17/2016 14:58:52 > 0ae556: INFO]    at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
    [06/17/2016 14:58:52 > 0ae556: INFO]    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    [06/17/2016 14:58:52 > 0ae556: INFO]    at Microsoft.Owin.Hosting.ServerFactory.ServerFactoryAdapter.Create(IAppBuilder builder)
    [06/17/2016 14:58:52 > 0ae556: INFO]    at Microsoft.Owin.Hosting.Engine.HostingEngine.StartServer(StartContext context)
    [06/17/2016 14:58:52 > 0ae556: INFO]    at Microsoft.Owin.Hosting.Engine.HostingEngine.Start(StartContext context)
    [06/17/2016 14:58:52 > 0ae556: INFO]    at Microsoft.Owin.Hosting.WebApp.StartImplementation(IServiceProvider services, StartOptions options, Action`1 startup)
    [06/17/2016 14:58:52 > 0ae556: INFO]    at TestTopshelfAzure.SampleService.Start(HostControl hostControl)
    [06/17/2016 14:58:52 > 0ae556: INFO]    at TestTopshelfAzure.Program.<>c.<Main>b__1_3(SampleService srv, HostControl hostControl)
    [06/17/2016 14:58:52 > 0ae556: INFO]    at Topshelf.Builders.DelegateServiceBuilder`1.DelegateServiceHandle.Start(HostControl hostControl)
    [06/17/2016 14:58:52 > 0ae556: INFO]    at Topshelf.Hosts.ConsoleRunHost.Run()
    [06/17/2016 14:58:52 > 0ae556: SYS ERR ] Job failed due to exit code 1
    [06/17/2016 14:58:52 > 0ae556: SYS INFO] Process went down, waiting for 60 seconds
    [06/17/2016 14:58:52 > 0ae556: SYS INFO] Status changed to PendingRestart
    I understand the the problem caused by OWIN engine when it tries to listen custom port. 

    Is there any way to grant an access right for the service? If not then which Azure solution should I use for my needs?

    Thank in advance.

    Friday, June 17, 2016 3:34 PM

Answers

All replies

  • See this section of the sandbox document which discusses this limitation.

    David

    Friday, June 17, 2016 3:48 PM
  • Thank you, David.

    Now I see the point.

    But which alternatives Azure provides for hosting windows services?

    Friday, June 17, 2016 3:53 PM
  • I would think it should work on Web Apps using HttpPlatformHandler, though I haven't tried.

    Otherwise, you can do it on an Azure VM or Cloud Service.

    • Proposed as answer by David Ebbo Friday, June 17, 2016 4:00 PM
    Friday, June 17, 2016 4:00 PM