2015-04-29 18 views
15

It is possible, aby uruchomić aplikację suave.io na Azure Web Apps z powodu funkcji IIS8 o nazwie HttpPlatformHandler. Próbowałem uruchomić self-hosted aplikacja OWIN w ten sam sposób, ale mam wyjątek na starcie:Uruchamiaj samodzielnie hostowaną aplikację OWIN w aplikacji Azure Web Apps

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 Microsoft.Owin.Hosting.WebApp.Start[TStartup](String url) 
    at WebAppSample.Program.Main(String[] args) in c:\Users\egger\Workspace\WebAppSample\WebAppSample\Program.cs:line 14 

Wydaje się, że nie wolno mi się otworzyć port. Moje web.config wygląda następująco:

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <system.webServer> 
     <handlers> 
      <remove name="httpplatformhandler" /> 
      <add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" /> 
     </handlers> 
     <httpPlatform 
      stdoutLogEnabled="true" 
      stdoutLogFile="site.log" 
      startupTimeLimit="20" 
      processPath="%HOME%\site\wwwroot\WebAppSample.exe" 
      arguments="%HTTP_PLATFORM_PORT%"> 
     </httpPlatform> 
    </system.webServer> 
</configuration> 

używam HTTP_PLATFORM_PORT słuchać na prawej portu. Moja aplikacja internetowa uruchamia serwer w następujący sposób:

class Program 
{ 
    static void Main(string[] args) 
    { 
     var port = int.Parse(args[0]); 
     var url = string.Format("http://127.0.0.1:{0}", port); 
     Console.WriteLine("Starting web app at {0}", url); 
     using (WebApp.Start<Startup>(url)) 
     { 
      Console.ReadLine(); 
     } 
    } 
} 
public class Startup 
{ 
    public void Configuration(IAppBuilder app) 
    { 
     app.UseErrorPage(); 
     app.UseWelcomePage("/"); 
    } 
} 

URL wydaje się być OK, bo mam wyjścia tak: Starting web app at http://127.0.0.1:32880.

Pliki web.config i wszystkie pliki binarne znajdują się w katalogu głównym, a ja opublikowałem aplikację za pomocą lokalnego repozytorium git.

Dlaczego nie mogę otworzyć portu przy użyciu OWIN? Czym różni się od próbki suave.io?

EDIT: Widziałem tylko jest wniosek do wspierania dokładnie ten scenariusz: https://feedback.azure.com/forums/169385-web-apps-formerly-websites/suggestions/4606121-support-owin-self-hosting-in-azure-websites

+0

To chyba cichy tutaj z powodu konferencji // Build. Będę cierpliwy przez kilka następnych dni :-) –

+0

Czy kiedykolwiek znalazłeś odpowiedź na to pytanie? Wdrażam kilka aplikacji i usług F #, używając sztuczki HttpPlatformHandler, ale próbuję uruchomić się z serwerem signalr używając OWIN i F # i nic nie działa "po prostu". – tigerswithguitars

+0

Nigdy nie próbowaliśmy ponownie. Aplikacja działa obecnie w roli robota. –

Odpowiedz

5

Miałem ten sam problem. Rozwiązano po prostu, uruchamiając Visual Studio jako administrator.

(Może być konieczne ponowne uruchomienie emulatora Azure).

+1

Nie próbuję uruchamiać aplikacji w emulatorze. Zainstalowałem go bezpośrednio na platformie Azure. –

+0

Bro - właśnie uratowałeś moje życie. –

Powiązane problemy