("OrderingApiClient")}
+ };
- if (!context.Clients.Any())
+ if (!await context.Clients.AnyAsync())
{
- foreach (var client in Config.GetClients(clientUrls))
- {
- await context.Clients.AddAsync(client.ToEntity());
- }
- await context.SaveChangesAsync();
+ context.Clients.AddRange(Config.GetClients(clientUrls).Select(client => client.ToEntity()));
}
- if (!context.IdentityResources.Any())
+ if (!await context.IdentityResources.AnyAsync())
{
- foreach (var resource in Config.GetResources())
- {
- await context.IdentityResources.AddAsync(resource.ToEntity());
- }
- await context.SaveChangesAsync();
+ context.IdentityResources.AddRange(Config.GetResources().Select(resource => resource.ToEntity()));
}
- if (!context.ApiResources.Any())
+ if (!await context.ApiResources.AnyAsync())
{
- foreach (var api in Config.GetApis())
- {
- await context.ApiResources.AddAsync(api.ToEntity());
- }
-
- await context.SaveChangesAsync();
+ context.ApiResources.AddRange(Config.GetApis().Select(api => api.ToEntity()));
}
+
+ await context.SaveChangesAsync();
}
}
}
diff --git a/src/Services/Identity/Identity.API/Startup.cs b/src/Services/Identity/Identity.API/Startup.cs
index 58ac0bd10..f16f90965 100644
--- a/src/Services/Identity/Identity.API/Startup.cs
+++ b/src/Services/Identity/Identity.API/Startup.cs
@@ -136,7 +136,12 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API
{
loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'");
app.UsePathBase(pathBase);
- }
+ }
+
+
+#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
+ app.Map("/liveness", lapp => lapp.Run(async ctx => ctx.Response.StatusCode = 200));
+#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
app.UseStaticFiles();
diff --git a/src/Services/Identity/Identity.API/Views/Home/About.cshtml b/src/Services/Identity/Identity.API/Views/Home/About.cshtml
deleted file mode 100644
index 50476d1fb..000000000
--- a/src/Services/Identity/Identity.API/Views/Home/About.cshtml
+++ /dev/null
@@ -1,7 +0,0 @@
-@{
- ViewData["Title"] = "About";
-}
-@ViewData["Title"].
-@ViewData["Message"]
-
-Use this area to provide additional information.
diff --git a/src/Services/Identity/Identity.API/Views/Home/Contact.cshtml b/src/Services/Identity/Identity.API/Views/Home/Contact.cshtml
deleted file mode 100644
index 15c12c6d1..000000000
--- a/src/Services/Identity/Identity.API/Views/Home/Contact.cshtml
+++ /dev/null
@@ -1,17 +0,0 @@
-@{
- ViewData["Title"] = "Contact";
-}
-@ViewData["Title"].
-@ViewData["Message"]
-
-
- One Microsoft Way
- Redmond, WA 98052-6399
- P:
- 425.555.0100
-
-
-
- Support: Support@example.com
- Marketing: Marketing@example.com
-
diff --git a/src/Services/Location/Locations.API/Startup.cs b/src/Services/Location/Locations.API/Startup.cs
index 55e9d52c0..e69180e61 100644
--- a/src/Services/Location/Locations.API/Startup.cs
+++ b/src/Services/Location/Locations.API/Startup.cs
@@ -162,6 +162,10 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API
app.UsePathBase(pathBase);
}
+#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
+ app.Map("/liveness", lapp => lapp.Run(async ctx => ctx.Response.StatusCode = 200));
+#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
+
app.UseCors("CorsPolicy");
ConfigureAuth(app);
diff --git a/src/Services/Marketing/Marketing.API/Startup.cs b/src/Services/Marketing/Marketing.API/Startup.cs
index a5f12b54e..f2dcd1578 100644
--- a/src/Services/Marketing/Marketing.API/Startup.cs
+++ b/src/Services/Marketing/Marketing.API/Startup.cs
@@ -192,8 +192,12 @@
if (!string.IsNullOrEmpty(pathBase))
{
app.UsePathBase(pathBase);
- }
-
+ }
+
+#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
+ app.Map("/liveness", lapp => lapp.Run(async ctx => ctx.Response.StatusCode = 200));
+#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
+
app.UseCors("CorsPolicy");
ConfigureAuth(app);
diff --git a/src/Services/Ordering/Ordering.API/Startup.cs b/src/Services/Ordering/Ordering.API/Startup.cs
index 0c7272f6b..1879175c9 100644
--- a/src/Services/Ordering/Ordering.API/Startup.cs
+++ b/src/Services/Ordering/Ordering.API/Startup.cs
@@ -6,7 +6,6 @@
using global::Ordering.API.Application.IntegrationEvents;
using global::Ordering.API.Application.IntegrationEvents.Events;
using global::Ordering.API.Infrastructure.Filters;
- using global::Ordering.API.Infrastructure.HostedServices;
using global::Ordering.API.Infrastructure.Middlewares;
using Infrastructure.AutofacModules;
using Infrastructure.Filters;
@@ -58,9 +57,6 @@
}).AddControllersAsServices(); //Injecting Controllers themselves thru DI
//For further info see: http://docs.autofac.org/en/latest/integration/aspnetcore.html#controllers-as-services
- // Configure GracePeriodManager Hosted Service
- services.AddSingleton();
-
services.AddTransient();
services.AddHealthChecks(checks =>
@@ -215,8 +211,12 @@
{
loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'");
app.UsePathBase(pathBase);
- }
-
+ }
+
+#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
+ app.Map("/liveness", lapp => lapp.Run(async ctx => ctx.Response.StatusCode = 200));
+#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
+
app.UseCors("CorsPolicy");
ConfigureAuth(app);
diff --git a/src/Services/Ordering/Ordering.BackgroundTasks/Configuration/BackgroundTaskSettings.cs b/src/Services/Ordering/Ordering.BackgroundTasks/Configuration/BackgroundTaskSettings.cs
new file mode 100644
index 000000000..2b42f6084
--- /dev/null
+++ b/src/Services/Ordering/Ordering.BackgroundTasks/Configuration/BackgroundTaskSettings.cs
@@ -0,0 +1,13 @@
+namespace Ordering.BackgroundTasks.Configuration
+{
+ public class BackgroundTaskSettings
+ {
+ public string ConnectionString { get; set; }
+
+ public string EventBusConnection { get; set; }
+
+ public int GracePeriodTime { get; set; }
+
+ public int CheckUpdateTime { get; set; }
+ }
+}
diff --git a/src/Services/Ordering/Ordering.BackgroundTasks/Dockerfile b/src/Services/Ordering/Ordering.BackgroundTasks/Dockerfile
new file mode 100644
index 000000000..391d8c17b
--- /dev/null
+++ b/src/Services/Ordering/Ordering.BackgroundTasks/Dockerfile
@@ -0,0 +1,18 @@
+FROM microsoft/aspnetcore:2.0.3 AS base
+WORKDIR /app
+EXPOSE 80
+
+FROM microsoft/aspnetcore-build:2.0 AS build
+WORKDIR /src
+COPY . .
+RUN dotnet restore -nowarn:msb3202,nu1503
+WORKDIR /src/src/Services/Ordering/Ordering.BackgroundTasks
+RUN dotnet build --no-restore -c Release -o /app
+
+FROM build AS publish
+RUN dotnet publish --no-restore -c Release -o /app
+
+FROM base AS final
+WORKDIR /app
+COPY --from=publish /app .
+ENTRYPOINT ["dotnet", "Ordering.BackgroundTasks.dll"]
\ No newline at end of file
diff --git a/src/Services/Ordering/Ordering.BackgroundTasks/IntegrationEvents/GracePeriodConfirmedIntegrationEvent.cs b/src/Services/Ordering/Ordering.BackgroundTasks/IntegrationEvents/GracePeriodConfirmedIntegrationEvent.cs
new file mode 100644
index 000000000..df008ad90
--- /dev/null
+++ b/src/Services/Ordering/Ordering.BackgroundTasks/IntegrationEvents/GracePeriodConfirmedIntegrationEvent.cs
@@ -0,0 +1,12 @@
+using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
+
+namespace Ordering.BackgroundTasks.IntegrationEvents
+{
+ public class GracePeriodConfirmedIntegrationEvent : IntegrationEvent
+ {
+ public int OrderId { get; }
+
+ public GracePeriodConfirmedIntegrationEvent(int orderId) =>
+ OrderId = orderId;
+ }
+}
diff --git a/src/Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj b/src/Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj
new file mode 100644
index 000000000..731d6df06
--- /dev/null
+++ b/src/Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj
@@ -0,0 +1,32 @@
+
+
+
+ netcoreapp2.0
+ $(AssetTargetFallback);portable-net45+win8+wp8+wpa81;
+ ..\..\..\..\docker-compose.dcproj
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Services/Ordering/Ordering.BackgroundTasks/Program.cs b/src/Services/Ordering/Ordering.BackgroundTasks/Program.cs
new file mode 100644
index 000000000..23d0a5e42
--- /dev/null
+++ b/src/Services/Ordering/Ordering.BackgroundTasks/Program.cs
@@ -0,0 +1,25 @@
+using Microsoft.AspNetCore;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Logging;
+
+namespace Ordering.BackgroundTasks
+{
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ BuildWebHost(args).Run();
+ }
+
+ public static IWebHost BuildWebHost(string[] args) =>
+ WebHost.CreateDefaultBuilder(args)
+ .UseStartup()
+ .UseHealthChecks("/hc")
+ .ConfigureLogging((hostingContext, builder) =>
+ {
+ builder.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
+ builder.AddDebug();
+ builder.AddConsole();
+ }).Build();
+ }
+}
diff --git a/src/Services/Ordering/Ordering.BackgroundTasks/Properties/launchSettings.json b/src/Services/Ordering/Ordering.BackgroundTasks/Properties/launchSettings.json
new file mode 100644
index 000000000..6d60a7d28
--- /dev/null
+++ b/src/Services/Ordering/Ordering.BackgroundTasks/Properties/launchSettings.json
@@ -0,0 +1,29 @@
+{
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:5161/",
+ "sslPort": 0
+ }
+ },
+ "profiles": {
+ "IIS Express": {
+ "commandName": "IISExpress",
+ "launchBrowser": true,
+ "launchUrl": "api/values",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ },
+ "Ordering.BackgroundTasks": {
+ "commandName": "Project",
+ "launchBrowser": true,
+ "launchUrl": "api/values",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ },
+ "applicationUrl": "http://localhost:5162/"
+ }
+ }
+}
diff --git a/src/Services/Ordering/Ordering.BackgroundTasks/Startup.cs b/src/Services/Ordering/Ordering.BackgroundTasks/Startup.cs
new file mode 100644
index 000000000..bb7ae0902
--- /dev/null
+++ b/src/Services/Ordering/Ordering.BackgroundTasks/Startup.cs
@@ -0,0 +1,161 @@
+using Autofac;
+using Autofac.Extensions.DependencyInjection;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Azure.ServiceBus;
+using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
+using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
+using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
+using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.HealthChecks;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging;
+using Ordering.BackgroundTasks.Configuration;
+using Ordering.BackgroundTasks.Tasks;
+using RabbitMQ.Client;
+using System;
+
+namespace Ordering.BackgroundTasks
+{
+ public class Startup
+ {
+ public Startup(IConfiguration configuration)
+ {
+ Configuration = configuration;
+ }
+
+ public IConfiguration Configuration { get; }
+
+ // This method gets called by the runtime. Use this method to add services to the container.
+ public IServiceProvider ConfigureServices(IServiceCollection services)
+ {
+ //add health check for this service
+ services.AddHealthChecks(checks =>
+ {
+ var minutes = 1;
+
+ if (int.TryParse(Configuration["HealthCheck:Timeout"], out var minutesParsed))
+ {
+ minutes = minutesParsed;
+ }
+ checks.AddSqlCheck("OrderingDb", Configuration["ConnectionString"], TimeSpan.FromMinutes(minutes));
+ });
+
+ //configure settings
+
+ services.Configure(Configuration);
+ services.AddOptions();
+
+ //configure background task
+
+ services.AddSingleton();
+
+ //configure event bus related services
+
+ if (Configuration.GetValue("AzureServiceBusEnabled"))
+ {
+ services.AddSingleton(sp =>
+ {
+ var logger = sp.GetRequiredService>();
+
+ var serviceBusConnectionString = Configuration["EventBusConnection"];
+ var serviceBusConnection = new ServiceBusConnectionStringBuilder(serviceBusConnectionString);
+
+ return new DefaultServiceBusPersisterConnection(serviceBusConnection, logger);
+ });
+ }
+ else
+ {
+ services.AddSingleton(sp =>
+ {
+ var logger = sp.GetRequiredService>();
+
+
+ var factory = new ConnectionFactory()
+ {
+ HostName = Configuration["EventBusConnection"]
+ };
+
+ if (!string.IsNullOrEmpty(Configuration["EventBusUserName"]))
+ {
+ factory.UserName = Configuration["EventBusUserName"];
+ }
+
+ if (!string.IsNullOrEmpty(Configuration["EventBusPassword"]))
+ {
+ factory.Password = Configuration["EventBusPassword"];
+ }
+
+ var retryCount = 5;
+ if (!string.IsNullOrEmpty(Configuration["EventBusRetryCount"]))
+ {
+ retryCount = int.Parse(Configuration["EventBusRetryCount"]);
+ }
+
+ return new DefaultRabbitMQPersistentConnection(factory, logger, retryCount);
+ });
+ }
+
+ RegisterEventBus(services);
+
+ //create autofac based service provider
+ var container = new ContainerBuilder();
+ container.Populate(services);
+
+
+ return new AutofacServiceProvider(container.Build());
+ }
+
+
+ // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
+ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
+ {
+
+#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
+ app.Map("/liveness", lapp => lapp.Run(async ctx => ctx.Response.StatusCode = 200));
+#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
+ }
+
+
+ private void RegisterEventBus(IServiceCollection services)
+ {
+ var subscriptionClientName = Configuration["SubscriptionClientName"];
+
+ if (Configuration.GetValue("AzureServiceBusEnabled"))
+ {
+ services.AddSingleton(sp =>
+ {
+ var serviceBusPersisterConnection = sp.GetRequiredService();
+ var iLifetimeScope = sp.GetRequiredService();
+ var logger = sp.GetRequiredService>();
+ var eventBusSubcriptionsManager = sp.GetRequiredService();
+
+ return new EventBusServiceBus(serviceBusPersisterConnection, logger,
+ eventBusSubcriptionsManager, subscriptionClientName, iLifetimeScope);
+ });
+ }
+ else
+ {
+ services.AddSingleton(sp =>
+ {
+ var rabbitMQPersistentConnection = sp.GetRequiredService();
+ var iLifetimeScope = sp.GetRequiredService();
+ var logger = sp.GetRequiredService>();
+ var eventBusSubcriptionsManager = sp.GetRequiredService();
+
+ var retryCount = 5;
+ if (!string.IsNullOrEmpty(Configuration["EventBusRetryCount"]))
+ {
+ retryCount = int.Parse(Configuration["EventBusRetryCount"]);
+ }
+
+ return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
+ });
+ }
+
+ services.AddSingleton();
+ }
+ }
+}
diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/HostedServices/BackgroundService.cs b/src/Services/Ordering/Ordering.BackgroundTasks/Tasks/Base/BackgroundTask.cs
similarity index 95%
rename from src/Services/Ordering/Ordering.API/Infrastructure/HostedServices/BackgroundService.cs
rename to src/Services/Ordering/Ordering.BackgroundTasks/Tasks/Base/BackgroundTask.cs
index 205b3c75a..6611fc3ab 100644
--- a/src/Services/Ordering/Ordering.API/Infrastructure/HostedServices/BackgroundService.cs
+++ b/src/Services/Ordering/Ordering.BackgroundTasks/Tasks/Base/BackgroundTask.cs
@@ -1,12 +1,11 @@
-using System;
+using Microsoft.Extensions.Hosting;
+using System;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.Extensions.Hosting;
-
-namespace Ordering.API.Infrastructure.HostedServices
+namespace Ordering.BackgroundTasks.Tasks.Base
{
- // Copyright (c) .NET Foundation. All rights reserved.
+ // Copyright(c) .NET Foundation.All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
///
@@ -19,6 +18,7 @@ namespace Ordering.API.Infrastructure.HostedServices
public abstract class BackgroundService : IHostedService, IDisposable
{
private Task _executingTask;
+
private readonly CancellationTokenSource _stoppingCts = new CancellationTokenSource();
///
@@ -78,6 +78,4 @@ namespace Ordering.API.Infrastructure.HostedServices
_stoppingCts.Cancel();
}
}
-
-
}
diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/HostedServices/GracePeriodManagerService.cs b/src/Services/Ordering/Ordering.BackgroundTasks/Tasks/GracePeriodManagerTask.cs
similarity index 59%
rename from src/Services/Ordering/Ordering.API/Infrastructure/HostedServices/GracePeriodManagerService.cs
rename to src/Services/Ordering/Ordering.BackgroundTasks/Tasks/GracePeriodManagerTask.cs
index 52b1b2da7..c89b8cbf3 100644
--- a/src/Services/Ordering/Ordering.API/Infrastructure/HostedServices/GracePeriodManagerService.cs
+++ b/src/Services/Ordering/Ordering.BackgroundTasks/Tasks/GracePeriodManagerTask.cs
@@ -1,51 +1,53 @@
-namespace Ordering.API.Infrastructure.HostedServices
+using Dapper;
+using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
+using Ordering.BackgroundTasks.Configuration;
+using Ordering.BackgroundTasks.IntegrationEvents;
+using Ordering.BackgroundTasks.Tasks.Base;
+using System;
+using System.Collections.Generic;
+using System.Data.SqlClient;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Ordering.BackgroundTasks.Tasks
{
- using Dapper;
- using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
- using Microsoft.eShopOnContainers.Services.Ordering.API;
- using Microsoft.Extensions.Logging;
- using Microsoft.Extensions.Options;
- using Ordering.API.Application.IntegrationEvents.Events;
- using System;
- using System.Collections.Generic;
- using System.Data.SqlClient;
- using System.Threading;
- using System.Threading.Tasks;
-
- public class GracePeriodManagerService : BackgroundService
+ public class GracePeriodManagerService
+ : BackgroundService
{
- private readonly OrderingSettings _settings;
private readonly ILogger _logger;
+ private readonly BackgroundTaskSettings _settings;
private readonly IEventBus _eventBus;
- public GracePeriodManagerService(IOptions settings,
- IEventBus eventBus,
- ILogger logger)
+ public GracePeriodManagerService(IOptions settings,
+ IEventBus eventBus,
+ ILogger logger)
{
- _logger = logger ?? throw new ArgumentNullException(nameof(logger));
- _eventBus = eventBus ?? throw new ArgumentNullException(nameof(eventBus));
_settings = settings?.Value ?? throw new ArgumentNullException(nameof(settings));
+ _eventBus = eventBus ?? throw new ArgumentNullException(nameof(eventBus));
+ _logger = logger ?? throw new ArgumentNullException(nameof(logger));
+
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
- _logger.LogDebug($"GracePeriod background task is starting.");
+ _logger.LogDebug($"GracePeriodManagerService is starting.");
- stoppingToken.Register(() => _logger.LogDebug($"#1 GracePeriod background task is stopping."));
+ stoppingToken.Register(() => _logger.LogDebug($"#1 GracePeriodManagerService background task is stopping."));
while (!stoppingToken.IsCancellationRequested)
{
- _logger.LogDebug($"GracePeriod background task is doing background work.");
+ _logger.LogDebug($"GracePeriodManagerService background task is doing background work.");
CheckConfirmedGracePeriodOrders();
await Task.Delay(_settings.CheckUpdateTime, stoppingToken);
-
- continue;
}
- _logger.LogDebug($"GracePeriod background task is stopping.");
-
+ _logger.LogDebug($"GracePeriodManagerService background task is stopping.");
+
+ await Task.CompletedTask;
}
private void CheckConfirmedGracePeriodOrders()
@@ -54,11 +56,11 @@
var orderIds = GetConfirmedGracePeriodOrders();
- _logger.LogDebug($"GracePeriod sent a .");
foreach (var orderId in orderIds)
{
- var gracePeriodConfirmedEvent = new GracePeriodConfirmedIntegrationEvent(orderId);
- _eventBus.Publish(gracePeriodConfirmedEvent);
+ var confirmGracePeriodEvent = new GracePeriodConfirmedIntegrationEvent(orderId);
+
+ _eventBus.Publish(confirmGracePeriodEvent);
}
}
diff --git a/src/Services/Ordering/Ordering.BackgroundTasks/appsettings.Development.json b/src/Services/Ordering/Ordering.BackgroundTasks/appsettings.Development.json
new file mode 100644
index 000000000..fa8ce71a9
--- /dev/null
+++ b/src/Services/Ordering/Ordering.BackgroundTasks/appsettings.Development.json
@@ -0,0 +1,10 @@
+{
+ "Logging": {
+ "IncludeScopes": false,
+ "LogLevel": {
+ "Default": "Debug",
+ "System": "Information",
+ "Microsoft": "Information"
+ }
+ }
+}
diff --git a/src/Services/Ordering/Ordering.BackgroundTasks/appsettings.json b/src/Services/Ordering/Ordering.BackgroundTasks/appsettings.json
new file mode 100644
index 000000000..fd26645ab
--- /dev/null
+++ b/src/Services/Ordering/Ordering.BackgroundTasks/appsettings.json
@@ -0,0 +1,27 @@
+{
+ "ConnectionString": "Server=tcp:127.0.0.1,5433;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word;",
+ "Logging": {
+ "IncludeScopes": false,
+ "Debug": {
+ "LogLevel": {
+ "Default": "Debug"
+ }
+ },
+ "Console": {
+ "LogLevel": {
+ "Default": "Debug"
+ }
+ }
+ },
+ "SubscriptionClientName": "BackgroundTasks",
+ "GracePeriodTime": "1",
+ "CheckUpdateTime": "1000",
+ "ApplicationInsights": {
+ "InstrumentationKey": ""
+ },
+ "AzureServiceBusEnabled": false,
+ "EventBusRetryCount": 5,
+ "EventBusConnection": "",
+ "EventBusUserName": "",
+ "EventBusPassword": ""
+}
\ No newline at end of file
diff --git a/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Order.cs b/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Order.cs
index d2e742b33..428d97580 100644
--- a/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Order.cs
+++ b/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Order.cs
@@ -95,8 +95,9 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O
{
if (_orderStatusId == OrderStatus.Submitted.Id)
{
- AddDomainEvent(new OrderStatusChangedToAwaitingValidationDomainEvent(Id, _orderItems));
_orderStatusId = OrderStatus.AwaitingValidation.Id;
+
+ AddDomainEvent(new OrderStatusChangedToAwaitingValidationDomainEvent(Id, _orderItems));
}
}
@@ -104,10 +105,10 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O
{
if (_orderStatusId == OrderStatus.AwaitingValidation.Id)
{
- AddDomainEvent(new OrderStatusChangedToStockConfirmedDomainEvent(Id));
-
_orderStatusId = OrderStatus.StockConfirmed.Id;
_description = "All the items were confirmed with available stock.";
+
+ AddDomainEvent(new OrderStatusChangedToStockConfirmedDomainEvent(Id));
}
}
@@ -115,10 +116,10 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O
{
if (_orderStatusId == OrderStatus.StockConfirmed.Id)
{
- AddDomainEvent(new OrderStatusChangedToPaidDomainEvent(Id, OrderItems));
-
_orderStatusId = OrderStatus.Paid.Id;
_description = "The payment was performed at a simulated \"American Bank checking bank account endinf on XX35071\"";
+
+ AddDomainEvent(new OrderStatusChangedToPaidDomainEvent(Id, OrderItems));
}
}
diff --git a/src/Services/Payment/Payment.API/Startup.cs b/src/Services/Payment/Payment.API/Startup.cs
index e06c7c7f2..02cd4c70e 100644
--- a/src/Services/Payment/Payment.API/Startup.cs
+++ b/src/Services/Payment/Payment.API/Startup.cs
@@ -103,6 +103,10 @@ namespace Payment.API
app.UsePathBase(pathBase);
}
+#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
+ app.Map("/liveness", lapp => lapp.Run(async ctx => ctx.Response.StatusCode = 200));
+#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
+
ConfigureEventBus(app);
}
diff --git a/src/Web/WebMVC/Startup.cs b/src/Web/WebMVC/Startup.cs
index ced47ea67..105b1ed9e 100644
--- a/src/Web/WebMVC/Startup.cs
+++ b/src/Web/WebMVC/Startup.cs
@@ -160,6 +160,11 @@ namespace Microsoft.eShopOnContainers.WebMVC
app.UsePathBase(pathBase);
}
+
+#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
+ app.Map("/liveness", lapp => lapp.Run(async ctx => ctx.Response.StatusCode = 200));
+#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
+
app.UseSession();
app.UseStaticFiles();
diff --git a/src/Web/WebSPA/Startup.cs b/src/Web/WebSPA/Startup.cs
index 3f2354b97..f49eba772 100644
--- a/src/Web/WebSPA/Startup.cs
+++ b/src/Web/WebSPA/Startup.cs
@@ -110,7 +110,12 @@ namespace eShopConContainers.WebSPA
{
loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'");
app.UsePathBase(pathBase);
- }
+ }
+
+
+#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
+ app.Map("/liveness", lapp => lapp.Run(async ctx => ctx.Response.StatusCode = 200));
+#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
app.Use(async (context, next) =>
{
diff --git a/src/Web/WebStatus/Startup.cs b/src/Web/WebStatus/Startup.cs
index 19aedc449..6f32ce5a8 100644
--- a/src/Web/WebStatus/Startup.cs
+++ b/src/Web/WebStatus/Startup.cs
@@ -72,7 +72,12 @@ namespace WebStatus
if (!string.IsNullOrEmpty(pathBase))
{
app.UsePathBase(pathBase);
- }
+ }
+
+
+#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
+ app.Map("/liveness", lapp => lapp.Run(async ctx => ctx.Response.StatusCode = 200));
+#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
app.UseStaticFiles();