public static void Main(string[] args) { if (Environment.GetEnvironmentVariable("ASPNET_ENV") == "Debug") { // Build an ASP.NET 5 web application that serves as the communication listener. var webApp = new WebApplicationBuilder().UseConfiguration(WebApplicationConfiguration.GetDefault()) .ConfigureLogging(factory => { factory.AddConsole(); }) .UseStartup<Startup>() .Build(); // Replace the address with the one dynamically allocated by Service Fabric. webApp.GetAddresses().Clear(); webApp.GetAddresses().Add(ListeningAddress); webApp.Run(); Thread.Sleep(Timeout.Infinite); } else { using (var fabricRuntime = FabricRuntime.Create()) { fabricRuntime.RegisterServiceType("MicroserviceTemplateType", typeof(MicroserviceTemplate)); Thread.Sleep(Timeout.Infinite); } } }
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners() { // Build an ASP.NET 5 web application that serves as the communication listener. var webApp = new WebApplicationBuilder().UseConfiguration(WebApplicationConfiguration.GetDefault()) .UseStartup<Startup>() .Build(); // Replace the address with the one dynamically allocated by Service Fabric. string listeningAddress = AspNetCommunicationListener.GetListeningAddress(ServiceInitializationParameters, "ServiceDeployerTypeEndpoint"); webApp.GetAddresses().Clear(); webApp.GetAddresses().Add(listeningAddress); return new[] { new ServiceInstanceListener(_ => new AspNetCommunicationListener(webApp)) }; }
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners() { // Build an ASP.NET 5 web application that serves as the communication listener. var webApp = new WebApplicationBuilder().UseConfiguration(WebApplicationConfiguration.GetDefault()) .UseStartup<Startup>() .Build(); // Replace the address with the one dynamically allocated by Service Fabric. var endpoint = ServiceInitializationParameters.CodePackageActivationContext.GetEndpoint("GatewayTypeEndpoint"); webApp.GetAddresses().Clear(); webApp.GetAddresses().Add($"{endpoint.Protocol}://+:{endpoint.Port}"); return new[] { new ServiceInstanceListener(_ => new AspNetCommunicationListener(webApp)) }; }
public static void Main(string[] args) { if (Environment.GetEnvironmentVariable("ASPNET_ENV") == "Debug") { try { // Build an ASP.NET 5 web application that serves as the communication listener. var webApp = new WebApplicationBuilder().UseConfiguration(WebApplicationConfiguration.GetDefault()) .ConfigureLogging(factory => { factory.AddConsole(); }) .UseStartup<Startup>() .Build(); webApp.GetAddresses().Clear(); webApp.GetAddresses().Add(LocalListeningAddress); Console.WriteLine(LocalListeningAddress); webApp.Run(); Thread.Sleep(Timeout.Infinite); } catch (Exception ex) { Console.WriteLine("Crashed: {0}", ex); Console.ReadLine(); } } using (var fabricRuntime = FabricRuntime.Create()) { fabricRuntime.RegisterServiceType("ServiceDeployerType", typeof(ServiceDeployer)); Thread.Sleep(Timeout.Infinite); } }