我是Windows Azure雲服務新手。我想在一個worker角色上託管一個使用ServiceStack構建的服務。我嘗試了幾種方法,包括下面的方法但沒有成功。使用Windows Azure工作者角色託管ServiceStack
碼我曾嘗試:
public class WorkerRole : RoleEntryPoint
{
public class AppHost : AppHostHttpListenerBase
{
public AppHost()
: base("HttpListener Self-Host", typeof(HelloService).Assembly) { }
public override void Configure(Funq.Container container)
{
Routes
.Add<Hello>("/hello")
.Add<Hello>("/hello/{Name}");
}
}
public override void Run()
{
while (true)
{
Thread.Sleep(10000);
Trace.TraceInformation("Working", "Information");
}
}
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
// For information on handling configuration changes
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
try
{
var endpoint = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["Endpoint1"];
string baseUri = string.Format("{0}://{1}/", endpoint.Protocol, endpoint.IPEndpoint);
var appHost = new AppHost();
appHost.Init();
appHost.Start(baseUri);
}
catch (Exception e)
{
Trace.TraceError("Could not start service host. {0}", e.Message);
}
return base.OnStart();
}
}
服務部署成功,但我無法訪問該服務。
那麼什麼是例外? – Scott
您可能想要觀看[此視頻](http://channel9.msdn.com/Series/Windows-Azure-Cloud-Services-Tutorials/Introduction-to-Windows-Azure-Worker-Roles-Part-1)。雖然不是ServiceStack,但校長是一樣的。確保您已正確配置您的端點訪問。 – Scott
你檢查了操作日誌嗎?有沒有錯誤? – vainolo