Last active
December 30, 2015 02:18
-
-
Save reidperyam/7761407 to your computer and use it in GitHub Desktop.
CloudService's single worker role that starts the OWIN pipeline via Microsoft.Owin.SelfHost
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<configuration> | |
<system.serviceModel> | |
<bindings> | |
<basicHttpBinding> | |
<binding name="BasicHttpBinding_IWCFCustomerService"> | |
<security mode="TransportCredentialOnly"> | |
<transport clientCredentialType="Ntlm"/> | |
</security> | |
</binding> | |
</basicHttpBinding> | |
</bindings> | |
<client> | |
<endpoint address="http://****/****/****.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWCFCustomerService" contract="IWCFCustomerService" name="BasicHttpBinding_IWCFCustomerService"/> | |
</client> | |
</system.serviceModel> | |
<system.diagnostics> | |
<trace> | |
<listeners> | |
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" | |
name="AzureDiagnostics"> | |
<filter type="" /> | |
</add> | |
</listeners> | |
</trace> | |
</system.diagnostics> | |
<system.web> | |
<compilation debug="true" /> | |
</system.web> | |
<runtime> | |
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | |
<dependentAssembly> | |
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" /> | |
<bindingRedirect oldVersion="0.0.0.0-2.0.2.0" newVersion="2.0.2.0" /> | |
</dependentAssembly> | |
</assemblyBinding> | |
</runtime> | |
</configuration> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Owin.Hosting; | |
using Microsoft.WindowsAzure.ServiceRuntime; | |
using Ninject; | |
using SalesApplication.Owin.Startup; | |
using System; | |
using System.Diagnostics; | |
using System.Net; | |
using System.Threading; | |
namespace SalesApplication.Azure.CloudService.Roles.Owin | |
{ | |
public class RoleStartup : RoleEntryPoint | |
{ | |
private IDisposable MyApp = null; | |
private IKernel Kernel { get; set; } | |
public override void Run() | |
{ | |
// this is a sample worker implementation. Replace with your logic. | |
Trace.TraceInformation("WorkerRole1 entry point called", "Information"); | |
while (true) | |
{ | |
Thread.Sleep(10000); | |
Trace.TraceInformation("Working", "Information"); | |
} | |
} | |
public override bool OnStart() | |
{ | |
ServicePointManager.DefaultConnectionLimit = 50; | |
var AppPoint = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["OwinEndpoint"]; | |
string baseUri = string.Format("{0}://{1}", AppPoint.Protocol, AppPoint.IPEndpoint); | |
Trace.TraceInformation(String.Format("OWIN URL is {0}", baseUri), "Information"); | |
// initialize OWIN pipeline | |
// we explicitly invoke our OWIN Startup class instead of configuring it or allowing | |
// discovery | |
MyApp = WebApp.Start<Startup>(new StartOptions(url: baseUri)); | |
return base.OnStart(); | |
} | |
public override void OnStop() | |
{ | |
if (MyApp != null) | |
{ | |
MyApp.Dispose(); | |
} | |
base.OnStop(); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Owin; | |
using Owin; | |
using SalesApplication.Owin; | |
using SalesApplication.Owin.Startup; | |
namespace SalesApplication.Owin.Startup | |
{ | |
public class Startup | |
{ | |
public void Configuration(IAppBuilder app) | |
{ | |
app.UseWelcomePageInDebugMode("/"); | |
app.UseErrorPageInDebugMode(); | |
app.UseNTLM(); | |
app.UseSalesApplicationWebAPI(); | |
app.UseNancy(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment