HttpPlatformHandler と呼ばれる IIS8 機能により、Azure Web Appsでsuave.ioアプリを実行することができます。自己ホスト型の OWIN アプリケーションを同じ方法で実行しようとしましたが、起動時に例外が発生しました。
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
ポート開放が許可されていないようです。私の web.config は次のようになります。
<?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>
私HTTP_PLATFORM_PORT
は右のポートで聞いていました。私の Web アプリは、次のようにサーバーを起動します。
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 は問題ないようですStarting web app at http://127.0.0.1:32880
。
web.config とすべてのバイナリはルート ディレクトリにあり、ローカルの git リポジトリを使用してアプリを公開しました。
OWIN を使用してポートを開くことができないのはなぜですか? suave.io サンプルとの違いは何ですか?
編集:この正確なシナリオをサポートする要求があるのを見たところです: -紺碧のウェブサイト