Fixed missing env variables in marketing.api in k8s scripts

Added Resource path in webstatus UI when deploying with K8S
Added Liveness healthChecks
Updated k8s healthcheck configuration
This commit is contained in:
Ramón Tomás 2019-01-03 17:11:56 +01:00
parent ffca2da0b3
commit dbf175f913
35 changed files with 191 additions and 93 deletions

View File

@ -16,7 +16,7 @@ $dns = $externalDns
$ingressValuesFile="ingress_values.yaml" $ingressValuesFile="ingress_values.yaml"
if ($ingressValuesFile) { if ($useLocalk8s) {
$ingressValuesFile="ingress_values_dockerk8s.yaml" $ingressValuesFile="ingress_values_dockerk8s.yaml"
$dns="localhost" $dns="localhost"
} }

View File

@ -14,6 +14,8 @@ inf:
db: OrderingDb # Ordering API SQL db name db: OrderingDb # Ordering API SQL db name
identity: identity:
db: IdentityDb # Ordering API SQL db name db: IdentityDb # Ordering API SQL db name
marketing:
db: MarketingDb # Marketing API SQL db name
mongo: mongo:
# host: my-nosql-data # Uncomment to use specify custom mongo host. By default nosql-data is used # host: my-nosql-data # Uncomment to use specify custom mongo host. By default nosql-data is used
locations: locations:

View File

@ -2,6 +2,7 @@
{{- $identity := include "url-of" (list .Values.app.ingress.entries.identity .) -}} {{- $identity := include "url-of" (list .Values.app.ingress.entries.identity .) -}}
{{- $webshoppingapigw := include "url-of" (list .Values.app.ingress.entries.webshoppingapigw .) -}} {{- $webshoppingapigw := include "url-of" (list .Values.app.ingress.entries.webshoppingapigw .) -}}
{{- $mongo := include "mongo-name" . -}} {{- $mongo := include "mongo-name" . -}}
{{- $sqlsrv := include "sql-name" . -}}
apiVersion: v1 apiVersion: v1
kind: ConfigMap kind: ConfigMap
@ -19,6 +20,7 @@ data:
all_EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}" all_EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}"
internalurls__IdentityUrl: http://{{ .Values.app.svc.identity }} internalurls__IdentityUrl: http://{{ .Values.app.svc.identity }}
urls__IdentityUrl: {{ $identity }} urls__IdentityUrl: {{ $identity }}
marketing__ConnectionString: mongodb://{{ $mongo }} marketing__ConnectionString: Server={{ $sqlsrv }};Initial Catalog={{ .Values.inf.sql.marketing.db }};User Id={{ .Values.inf.sql.common.user }};Password={{ .Values.inf.sql.common.pwd }};
marketing__Database: {{ .Values.inf.mongo.marketing.database }} marketing__MongoConnectionString: mongodb://{{ $mongo }}
marketing__MongoDatabase: {{ .Values.inf.mongo.marketing.database }}
marketing__PicBaseUrl: http://{{ $webshoppingapigw }}/api/v1/c/catalog/items/[0]/pic/ marketing__PicBaseUrl: http://{{ $webshoppingapigw }}/api/v1/c/catalog/items/[0]/pic/

View File

@ -44,8 +44,10 @@ env:
key: urls__IdentityUrl key: urls__IdentityUrl
- name: ConnectionString - name: ConnectionString
key: marketing__ConnectionString key: marketing__ConnectionString
- name: Database - name: MongoConnectionString
key: marketing__Database key: marketing__MongoConnectionString
- name: MongoDatabase
key: marketing__MongoDatabase
- name: PicBaseUrl - name: PicBaseUrl
key: marketing__PicBaseUrl key: marketing__PicBaseUrl
# values define environment variables with a fixed value (no configmap involved) (name is name of var, and value is its value) # values define environment variables with a fixed value (no configmap involved) (name is name of var, and value is its value)

View File

@ -13,7 +13,9 @@ service:
ingress: ingress:
enabled: true enabled: true
annotations: {} annotations: {
}
tls: [] tls: []
resources: {} resources: {}
@ -32,73 +34,73 @@ env:
configmap: configmap:
- name: ApplicationInsights__InstrumentationKey - name: ApplicationInsights__InstrumentationKey
key: all__InstrumentationKey key: all__InstrumentationKey
- name: HealthChecks-UI__HealthChecks__1__Name - name: HealthChecks-UI__HealthChecks__0__Name
key: name__mvc__hc key: name__mvc__hc
- name: HealthChecks-UI__HealthChecks__1__Uri - name: HealthChecks-UI__HealthChecks__0__Uri
key: internalurls__mvc__hc key: internalurls__mvc__hc
- name: HealthChecks-UI__HealthChecks__2__Name - name: HealthChecks-UI__HealthChecks__1__Name
key: name__spa__hc key: name__spa__hc
- name: HealthChecks-UI__HealthChecks__2__Uri - name: HealthChecks-UI__HealthChecks__1__Uri
key: internalurls__spa__hc key: internalurls__spa__hc
- name: HealthChecks-UI__HealthChecks__3__Name - name: HealthChecks-UI__HealthChecks__2__Name
key: name__apigwws__hc key: name__apigwws__hc
- name: HealthChecks-UI__HealthChecks__3__Uri - name: HealthChecks-UI__HealthChecks__2__Uri
key: internalurls__apigwws__hc key: internalurls__apigwws__hc
- name: HealthChecks-UI__HealthChecks__4__Name - name: HealthChecks-UI__HealthChecks__3__Name
key: name__apigwwm__hc key: name__apigwwm__hc
- name: HealthChecks-UI__HealthChecks__4__Uri - name: HealthChecks-UI__HealthChecks__3__Uri
key: internalurls__apigwwm__hc key: internalurls__apigwwm__hc
- name: HealthChecks-UI__HealthChecks__5__Name - name: HealthChecks-UI__HealthChecks__4__Name
key: name__apigwms__hc key: name__apigwms__hc
- name: HealthChecks-UI__HealthChecks__5__Uri - name: HealthChecks-UI__HealthChecks__4__Uri
key: internalurls__apigwms__hcç key: internalurls__apigwms__hc
- name: HealthChecks-UI__HealthChecks__6__Name - name: HealthChecks-UI__HealthChecks__5__Name
key: name__apigwmm__hc key: name__apigwmm__hc
- name: HealthChecks-UI__HealthChecks__6__Uri - name: HealthChecks-UI__HealthChecks__5__Uri
key: internalurls__apigwmm__hc key: internalurls__apigwmm__hc
- name: HealthChecks-UI__HealthChecks__7__Name - name: HealthChecks-UI__HealthChecks__6__Name
key: name__apigwwsagg__hc key: name__apigwwsagg__hc
- name: HealthChecks-UI__HealthChecks__7__Uri - name: HealthChecks-UI__HealthChecks__6__Uri
key: internalurls__apigwwsagg__hc key: internalurls__apigwwsagg__hc
- name: HealthChecks-UI__HealthChecks__8__Name - name: HealthChecks-UI__HealthChecks__7__Name
key: name__apigwmsagg__hc key: name__apigwmsagg__hc
- name: HealthChecks-UI__HealthChecks__8__Uri - name: HealthChecks-UI__HealthChecks__7__Uri
key: internalurls__apigwmsagg__hc key: internalurls__apigwmsagg__hc
- name: HealthChecks-UI__HealthChecks__9__Name - name: HealthChecks-UI__HealthChecks__8__Name
key: name__ordering__hc key: name__ordering__hc
- name: HealthChecks-UI__HealthChecks__9__Uri - name: HealthChecks-UI__HealthChecks__8__Uri
key: internalurls__ordering__hc key: internalurls__ordering__hc
- name: HealthChecks-UI__HealthChecks__10__Name - name: HealthChecks-UI__HealthChecks__9__Name
key: name__orderingbackground__hc key: name__orderingbackground__hc
- name: HealthChecks-UI__HealthChecks__10__Uri - name: HealthChecks-UI__HealthChecks__9__Uri
key: internalurls__orderingbackground__hc key: internalurls__orderingbackground__hc
- name: HealthChecks-UI__HealthChecks__11__Name - name: HealthChecks-UI__HealthChecks__10__Name
key: name__signalrhub__hc key: name__signalrhub__hc
- name: HealthChecks-UI__HealthChecks__11__Uri - name: HealthChecks-UI__HealthChecks__10__Uri
key: internalurls__signalrhub__hc key: internalurls__signalrhub__hc
- name: HealthChecks-UI__HealthChecks__12__Name - name: HealthChecks-UI__HealthChecks__11__Name
key: name__basket__hc key: name__basket__hc
- name: HealthChecks-UI__HealthChecks__12__Uri - name: HealthChecks-UI__HealthChecks__11__Uri
key: internalurls__basket__hc key: internalurls__basket__hc
- name: HealthChecks-UI__HealthChecks__13__Name - name: HealthChecks-UI__HealthChecks__12__Name
key: name__catalog__hc key: name__catalog__hc
- name: HealthChecks-UI__HealthChecks__13__Uri - name: HealthChecks-UI__HealthChecks__12__Uri
key: internalurls__catalog__hc key: internalurls__catalog__hc
- name: HealthChecks-UI__HealthChecks__14__Name - name: HealthChecks-UI__HealthChecks__13__Name
key: name__identity__hc key: name__identity__hc
- name: HealthChecks-UI__HealthChecks__14__Uri - name: HealthChecks-UI__HealthChecks__13__Uri
key: internalurls__identity__hc key: internalurls__identity__hc
- name: HealthChecks-UI__HealthChecks__15__Name - name: HealthChecks-UI__HealthChecks__14__Name
key: name__marketing__hc key: name__marketing__hc
- name: HealthChecks-UI__HealthChecks__15__Uri - name: HealthChecks-UI__HealthChecks__14__Uri
key: internalurls__marketing__hc key: internalurls__marketing__hc
- name: HealthChecks-UI__HealthChecks__16__Name - name: HealthChecks-UI__HealthChecks__15__Name
key: name__locations__hc key: name__locations__hc
- name: HealthChecks-UI__HealthChecks__16__Uri - name: HealthChecks-UI__HealthChecks__15__Uri
key: internalurls__locations__hc key: internalurls__locations__hc
- name: HealthChecks-UI__HealthChecks__17__Name - name: HealthChecks-UI__HealthChecks__16__Name
key: name__payment__hc key: name__payment__hc
- name: HealthChecks-UI__HealthChecks__17__Uri - name: HealthChecks-UI__HealthChecks__16__Uri
key: internalurls__payment__hc key: internalurls__payment__hc
# values define environment variables with a fixed value (no configmap involved) (name is name of var, and value is its value) # values define environment variables with a fixed value (no configmap involved) (name is name of var, and value is its value)
values: values:

View File

@ -12,6 +12,7 @@
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.0" /> <PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.0" />
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="2.2.0" /> <PackageReference Include="AspNetCore.HealthChecks.Uris" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" /> <PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
<PackageReference Include="Ocelot" Version="12.0.1" /> <PackageReference Include="Ocelot" Version="12.0.1" />
</ItemGroup> </ItemGroup>

View File

@ -8,6 +8,7 @@ using Ocelot.DependencyInjection;
using Ocelot.Middleware; using Ocelot.Middleware;
using System; using System;
using HealthChecks.UI.Client; using HealthChecks.UI.Client;
using Microsoft.Extensions.Diagnostics.HealthChecks;
namespace OcelotApiGw namespace OcelotApiGw
{ {
@ -26,6 +27,7 @@ namespace OcelotApiGw
var authenticationProviderKey = "IdentityApiKey"; var authenticationProviderKey = "IdentityApiKey";
services.AddHealthChecks() services.AddHealthChecks()
.AddCheck("self", () => HealthCheckResult.Healthy())
.AddUrlGroup(new Uri(_cfg["CatalogUrlHC"]), name: "catalogapi-check", tags: new string[] { "catalogapi" }) .AddUrlGroup(new Uri(_cfg["CatalogUrlHC"]), name: "catalogapi-check", tags: new string[] { "catalogapi" })
.AddUrlGroup(new Uri(_cfg["OrderingUrlHC"]), name: "orderingapi-check", tags: new string[] { "orderingapi" }) .AddUrlGroup(new Uri(_cfg["OrderingUrlHC"]), name: "orderingapi-check", tags: new string[] { "orderingapi" })
.AddUrlGroup(new Uri(_cfg["BasketUrlHC"]), name: "basketapi-check", tags: new string[] { "basketapi" }) .AddUrlGroup(new Uri(_cfg["BasketUrlHC"]), name: "basketapi-check", tags: new string[] { "basketapi" })
@ -93,6 +95,11 @@ namespace OcelotApiGw
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
}); });
app.UseHealthChecks("/liveness", new HealthCheckOptions
{
Predicate = r => r.Name.Contains("self")
});
loggerFactory.AddConsole(_cfg.GetSection("Logging")); loggerFactory.AddConsole(_cfg.GetSection("Logging"));
app.UseCors("CorsPolicy"); app.UseCors("CorsPolicy");

View File

@ -15,6 +15,7 @@
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="2.2.0" /> <PackageReference Include="AspNetCore.HealthChecks.Uris" Version="2.2.0" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.0" /> <PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.App" /> <PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="2.2.0" /> <PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="2.2.0-preview3-35497" /> <PackageReference Include="Microsoft.Extensions.Http.Polly" Version="2.2.0-preview3-35497" />

View File

@ -19,6 +19,7 @@ using Polly.Extensions.Http;
using Swashbuckle.AspNetCore.Swagger; using Swashbuckle.AspNetCore.Swagger;
using HealthChecks.UI.Client; using HealthChecks.UI.Client;
using Microsoft.AspNetCore.Diagnostics.HealthChecks; using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.Diagnostics.HealthChecks;
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator
{ {
@ -35,6 +36,7 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
services.AddHealthChecks() services.AddHealthChecks()
.AddCheck("self", () => HealthCheckResult.Healthy())
.AddUrlGroup(new Uri(Configuration["CatalogUrlHC"]), name: "catalogapi-check", tags: new string[] { "catalogapi" }) .AddUrlGroup(new Uri(Configuration["CatalogUrlHC"]), name: "catalogapi-check", tags: new string[] { "catalogapi" })
.AddUrlGroup(new Uri(Configuration["OrderingUrlHC"]), name: "orderingapi-check", tags: new string[] { "orderingapi" }) .AddUrlGroup(new Uri(Configuration["OrderingUrlHC"]), name: "orderingapi-check", tags: new string[] { "orderingapi" })
.AddUrlGroup(new Uri(Configuration["BasketUrlHC"]), name: "basketapi-check", tags: new string[] { "basketapi" }) .AddUrlGroup(new Uri(Configuration["BasketUrlHC"]), name: "basketapi-check", tags: new string[] { "basketapi" })
@ -65,6 +67,11 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
}); });
app.UseHealthChecks("/liveness", new HealthCheckOptions
{
Predicate = r => r.Name.Contains("self")
});
app.UseCors("CorsPolicy"); app.UseCors("CorsPolicy");
if (env.IsDevelopment()) if (env.IsDevelopment())

View File

@ -20,6 +20,7 @@ using System.IdentityModel.Tokens.Jwt;
using System.Net.Http; using System.Net.Http;
using HealthChecks.UI.Client; using HealthChecks.UI.Client;
using Microsoft.AspNetCore.Diagnostics.HealthChecks; using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.Diagnostics.HealthChecks;
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator
{ {
@ -36,6 +37,7 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
services.AddHealthChecks() services.AddHealthChecks()
.AddCheck("self", () => HealthCheckResult.Healthy())
.AddUrlGroup(new Uri(Configuration["CatalogUrlHC"]), name: "catalogapi-check", tags: new string[] { "catalogapi" }) .AddUrlGroup(new Uri(Configuration["CatalogUrlHC"]), name: "catalogapi-check", tags: new string[] { "catalogapi" })
.AddUrlGroup(new Uri(Configuration["OrderingUrlHC"]), name: "orderingapi-check", tags: new string[] { "orderingapi" }) .AddUrlGroup(new Uri(Configuration["OrderingUrlHC"]), name: "orderingapi-check", tags: new string[] { "orderingapi" })
.AddUrlGroup(new Uri(Configuration["BasketUrlHC"]), name: "basketapi-check", tags: new string[] { "basketapi" }) .AddUrlGroup(new Uri(Configuration["BasketUrlHC"]), name: "basketapi-check", tags: new string[] { "basketapi" })
@ -65,6 +67,11 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
}); });
app.UseHealthChecks("/liveness", new HealthCheckOptions
{
Predicate = r => r.Name.Contains("self")
});
app.UseCors("CorsPolicy"); app.UseCors("CorsPolicy");
if (env.IsDevelopment()) if (env.IsDevelopment())

View File

@ -15,6 +15,7 @@
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="2.2.0" /> <PackageReference Include="AspNetCore.HealthChecks.Uris" Version="2.2.0" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.0" /> <PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="2.2.0-preview3-35497" /> <PackageReference Include="Microsoft.Extensions.Http.Polly" Version="2.2.0-preview3-35497" />
</ItemGroup> </ItemGroup>

View File

@ -21,6 +21,7 @@
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" /> <PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta8" /> <PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta8" />
<PackageReference Include="Microsoft.ApplicationInsights.ServiceFabric" Version="2.1.1-beta1" /> <PackageReference Include="Microsoft.ApplicationInsights.ServiceFabric" Version="2.1.1-beta1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.2.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.2.1" /> <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.2.1" />

View File

@ -25,6 +25,7 @@ using Microsoft.eShopOnContainers.Services.Basket.API.Model;
using Microsoft.eShopOnContainers.Services.Basket.API.Services; using Microsoft.eShopOnContainers.Services.Basket.API.Services;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using RabbitMQ.Client; using RabbitMQ.Client;
@ -194,9 +195,10 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
}); });
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously app.UseHealthChecks("/liveness", new HealthCheckOptions
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 Predicate = r => r.Name.Contains("self")
});
app.UseStaticFiles(); app.UseStaticFiles();
app.UseCors("CorsPolicy"); app.UseCors("CorsPolicy");
@ -322,6 +324,8 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
{ {
var hcBuilder = services.AddHealthChecks(); var hcBuilder = services.AddHealthChecks();
hcBuilder.AddCheck("self", () => HealthCheckResult.Healthy());
hcBuilder hcBuilder
.AddRedis( .AddRedis(
configuration["ConnectionString"], configuration["ConnectionString"],

View File

@ -30,6 +30,7 @@ using System.Data.Common;
using System.Reflection; using System.Reflection;
using HealthChecks.UI.Client; using HealthChecks.UI.Client;
using Microsoft.AspNetCore.Diagnostics.HealthChecks; using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.Diagnostics.HealthChecks;
namespace Microsoft.eShopOnContainers.Services.Catalog.API namespace Microsoft.eShopOnContainers.Services.Catalog.API
{ {
@ -80,9 +81,10 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
}); });
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously app.UseHealthChecks("/liveness", new HealthCheckOptions
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 Predicate = r => r.Name.Contains("self")
});
app.UseCors("CorsPolicy"); app.UseCors("CorsPolicy");
@ -156,6 +158,7 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API
var hcBuilder = services.AddHealthChecks(); var hcBuilder = services.AddHealthChecks();
hcBuilder hcBuilder
.AddCheck("self", () => HealthCheckResult.Healthy())
.AddSqlServer( .AddSqlServer(
configuration["ConnectionString"], configuration["ConnectionString"],
name: "CatalogDB-check", name: "CatalogDB-check",

View File

@ -13,6 +13,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" /> <PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.0" /> <PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.0" />
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="2.2.0" /> <PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="2.2.0" />

View File

@ -21,6 +21,7 @@ using System;
using System.Reflection; using System.Reflection;
using HealthChecks.UI.Client; using HealthChecks.UI.Client;
using Microsoft.AspNetCore.Diagnostics.HealthChecks; using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.Diagnostics.HealthChecks;
namespace Microsoft.eShopOnContainers.Services.Identity.API namespace Microsoft.eShopOnContainers.Services.Identity.API
{ {
@ -67,6 +68,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API
} }
services.AddHealthChecks() services.AddHealthChecks()
.AddCheck("self", () => HealthCheckResult.Healthy())
.AddSqlServer(Configuration["ConnectionString"], .AddSqlServer(Configuration["ConnectionString"],
name: "IdentityDB-check", name: "IdentityDB-check",
tags: new string[] { "IdentityDB" }); tags: new string[] { "IdentityDB" });
@ -138,16 +140,16 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API
app.UsePathBase(pathBase); app.UsePathBase(pathBase);
} }
app.UseHealthChecks("/hc", new HealthCheckOptions() app.UseHealthChecks("/hc", new HealthCheckOptions()
{ {
Predicate = _ => true, Predicate = _ => true,
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
}); });
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously app.UseHealthChecks("/liveness", new HealthCheckOptions
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 Predicate = r => r.Name.Contains("self")
});
app.UseStaticFiles(); app.UseStaticFiles();

View File

@ -15,6 +15,7 @@
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" /> <PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta8" /> <PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta8" />
<PackageReference Include="Microsoft.ApplicationInsights.ServiceFabric" Version="2.1.1-beta1" /> <PackageReference Include="Microsoft.ApplicationInsights.ServiceFabric" Version="2.1.1-beta1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" /> <PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.0" /> <PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.2.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.2.0" />

View File

@ -21,6 +21,7 @@ using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Reposito
using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Services; using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Services;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using RabbitMQ.Client; using RabbitMQ.Client;
using Swashbuckle.AspNetCore.Swagger; using Swashbuckle.AspNetCore.Swagger;
@ -162,9 +163,10 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API
app.UsePathBase(pathBase); app.UsePathBase(pathBase);
} }
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously app.UseHealthChecks("/liveness", new HealthCheckOptions
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 Predicate = r => r.Name.Contains("self")
});
app.UseHealthChecks("/hc", new HealthCheckOptions() app.UseHealthChecks("/hc", new HealthCheckOptions()
{ {
@ -282,6 +284,8 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API
{ {
var hcBuilder = services.AddHealthChecks(); var hcBuilder = services.AddHealthChecks();
hcBuilder.AddCheck("self", () => HealthCheckResult.Healthy());
hcBuilder hcBuilder
.AddMongoDb( .AddMongoDb(
configuration["ConnectionString"], configuration["ConnectionString"],

View File

@ -30,6 +30,7 @@
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.2.1" /> <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.2.1" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" /> <PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta8" /> <PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta8" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" /> <PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.2.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.2.0" />
<PackageReference Include="Microsoft.ApplicationInsights.ServiceFabric" Version="2.1.1-beta1" /> <PackageReference Include="Microsoft.ApplicationInsights.ServiceFabric" Version="2.1.1-beta1" />

View File

@ -28,6 +28,7 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Middlewares; using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Middlewares;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using RabbitMQ.Client; using RabbitMQ.Client;
using Swashbuckle.AspNetCore.Swagger; using Swashbuckle.AspNetCore.Swagger;
using System; using System;
@ -193,9 +194,10 @@
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
}); });
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously app.UseHealthChecks("/liveness", new HealthCheckOptions
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 Predicate = r => r.Name.Contains("self")
});
app.UseCors("CorsPolicy"); app.UseCors("CorsPolicy");
@ -313,6 +315,8 @@
{ {
var hcBuilder = services.AddHealthChecks(); var hcBuilder = services.AddHealthChecks();
hcBuilder.AddCheck("self", () => HealthCheckResult.Healthy());
hcBuilder hcBuilder
.AddSqlServer( .AddSqlServer(
configuration["ConnectionString"], configuration["ConnectionString"],

View File

@ -38,6 +38,7 @@
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" /> <PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta8" /> <PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta8" />
<PackageReference Include="Microsoft.ApplicationInsights.ServiceFabric" Version="2.1.1-beta1" /> <PackageReference Include="Microsoft.ApplicationInsights.ServiceFabric" Version="2.1.1-beta1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" /> <PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.2.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.0" /> <PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.0" />

View File

@ -37,6 +37,7 @@
using System.Reflection; using System.Reflection;
using HealthChecks.UI.Client; using HealthChecks.UI.Client;
using Microsoft.AspNetCore.Diagnostics.HealthChecks; using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.Diagnostics.HealthChecks;
public class Startup public class Startup
{ {
@ -81,14 +82,14 @@
{ {
loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'"); loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'");
app.UsePathBase(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"); app.UseCors("CorsPolicy");
app.UseHealthChecks("/liveness", new HealthCheckOptions
{
Predicate = r => r.Name.Contains("self")
});
app.UseHealthChecks("/hc", new HealthCheckOptions() app.UseHealthChecks("/hc", new HealthCheckOptions()
{ {
@ -185,6 +186,8 @@
{ {
var hcBuilder = services.AddHealthChecks(); var hcBuilder = services.AddHealthChecks();
hcBuilder.AddCheck("self", () => HealthCheckResult.Healthy());
hcBuilder hcBuilder
.AddSqlServer( .AddSqlServer(
configuration["ConnectionString"], configuration["ConnectionString"],

View File

@ -20,6 +20,7 @@
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.2.1" /> <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.2.1" />
<PackageReference Include="Dapper" Version="1.50.4" /> <PackageReference Include="Dapper" Version="1.50.4" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" /> <PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="2.2.0" /> <PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="2.2.0" />
</ItemGroup> </ItemGroup>

View File

@ -17,6 +17,7 @@ using RabbitMQ.Client;
using System; using System;
using HealthChecks.UI.Client; using HealthChecks.UI.Client;
using Microsoft.AspNetCore.Diagnostics.HealthChecks; using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.Diagnostics.HealthChecks;
namespace Ordering.BackgroundTasks namespace Ordering.BackgroundTasks
{ {
@ -110,9 +111,10 @@ namespace Ordering.BackgroundTasks
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
}); });
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously app.UseHealthChecks("/liveness", new HealthCheckOptions
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 Predicate = r => r.Name.Contains("self")
});
} }
@ -162,6 +164,8 @@ namespace Ordering.BackgroundTasks
{ {
var hcBuilder = services.AddHealthChecks(); var hcBuilder = services.AddHealthChecks();
hcBuilder.AddCheck("self", () => HealthCheckResult.Healthy());
hcBuilder hcBuilder
.AddSqlServer( .AddSqlServer(
configuration["ConnectionString"], configuration["ConnectionString"],

View File

@ -14,11 +14,12 @@
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.0" /> <PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.0" />
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="2.2.0" /> <PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="2.2.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.2.1" /> <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.2.1" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0-preview3-35497" /> <PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" /> <PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.1.0-preview3-35497" /> <PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Core" Version="1.1.0-preview3-35497" /> <PackageReference Include="Microsoft.AspNetCore.SignalR.Core" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Redis" Version="1.1.0-preview3-35497" /> <PackageReference Include="Microsoft.AspNetCore.SignalR.Redis" Version="1.1.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.2.1" /> <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.2.1" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" /> <PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta8" /> <PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta8" />

View File

@ -19,6 +19,7 @@ using System;
using System.IdentityModel.Tokens.Jwt; using System.IdentityModel.Tokens.Jwt;
using HealthChecks.UI.Client; using HealthChecks.UI.Client;
using Microsoft.AspNetCore.Diagnostics.HealthChecks; using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.Diagnostics.HealthChecks;
namespace Ordering.SignalrHub namespace Ordering.SignalrHub
{ {
@ -136,6 +137,11 @@ namespace Ordering.SignalrHub
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
}); });
app.UseHealthChecks("/liveness", new HealthCheckOptions
{
Predicate = r => r.Name.Contains("self")
});
app.UseCors("CorsPolicy"); app.UseCors("CorsPolicy");
app.UseAuthentication(); app.UseAuthentication();
@ -227,6 +233,8 @@ namespace Ordering.SignalrHub
{ {
var hcBuilder = services.AddHealthChecks(); var hcBuilder = services.AddHealthChecks();
hcBuilder.AddCheck("self", () => HealthCheckResult.Healthy());
if (configuration.GetValue<bool>("AzureServiceBusEnabled")) if (configuration.GetValue<bool>("AzureServiceBusEnabled"))
{ {
hcBuilder hcBuilder

View File

@ -15,6 +15,7 @@
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" /> <PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta8" /> <PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta8" />
<PackageReference Include="Microsoft.ApplicationInsights.ServiceFabric" Version="2.1.1-beta1" /> <PackageReference Include="Microsoft.ApplicationInsights.ServiceFabric" Version="2.1.1-beta1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.0-preview3-35497" /> <PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.0-preview3-35497" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
</ItemGroup> </ItemGroup>

View File

@ -18,6 +18,7 @@ using RabbitMQ.Client;
using System; using System;
using HealthChecks.UI.Client; using HealthChecks.UI.Client;
using Microsoft.AspNetCore.Diagnostics.HealthChecks; using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.Diagnostics.HealthChecks;
namespace Payment.API namespace Payment.API
{ {
@ -106,9 +107,10 @@ namespace Payment.API
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
}); });
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously app.UseHealthChecks("/liveness", new HealthCheckOptions
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 Predicate = r => r.Name.Contains("self")
});
ConfigureEventBus(app); ConfigureEventBus(app);
} }
@ -184,6 +186,8 @@ namespace Payment.API
{ {
var hcBuilder = services.AddHealthChecks(); var hcBuilder = services.AddHealthChecks();
hcBuilder.AddCheck("self", () => HealthCheckResult.Healthy());
if (configuration.GetValue<bool>("AzureServiceBusEnabled")) if (configuration.GetValue<bool>("AzureServiceBusEnabled"))
{ {
hcBuilder hcBuilder

View File

@ -13,7 +13,7 @@ using Microsoft.eShopOnContainers.WebMVC.Services;
using Microsoft.eShopOnContainers.WebMVC.ViewModels; using Microsoft.eShopOnContainers.WebMVC.ViewModels;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.HealthChecks; using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Polly; using Polly;
using Polly.Extensions.Http; using Polly.Extensions.Http;
@ -78,10 +78,10 @@ namespace Microsoft.eShopOnContainers.WebMVC
app.UsePathBase(pathBase); app.UsePathBase(pathBase);
} }
app.UseHealthChecks("/liveness", new HealthCheckOptions
#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)); Predicate = r => r.Name.Contains("self")
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously });
app.UseSession(); app.UseSession();
app.UseStaticFiles(); app.UseStaticFiles();
@ -138,6 +138,7 @@ namespace Microsoft.eShopOnContainers.WebMVC
public static IServiceCollection AddHealthChecks(this IServiceCollection services, IConfiguration configuration) public static IServiceCollection AddHealthChecks(this IServiceCollection services, IConfiguration configuration)
{ {
services.AddHealthChecks() services.AddHealthChecks()
.AddCheck("self", () => HealthCheckResult.Healthy())
.AddUrlGroup(new Uri(configuration["PurchaseUrlHC"]), name: "purchaseapigw-check", tags: new string[] { "purchaseapigw" }) .AddUrlGroup(new Uri(configuration["PurchaseUrlHC"]), name: "purchaseapigw-check", tags: new string[] { "purchaseapigw" })
.AddUrlGroup(new Uri(configuration["MarketingUrlHC"]), name: "marketingapigw-check", tags: new string[] { "marketingapigw" }) .AddUrlGroup(new Uri(configuration["MarketingUrlHC"]), name: "marketingapigw-check", tags: new string[] { "marketingapigw" })
.AddUrlGroup(new Uri(configuration["IdentityUrlHC"]), name: "identityapi-check", tags: new string[] { "identityapi" }); .AddUrlGroup(new Uri(configuration["IdentityUrlHC"]), name: "identityapi-check", tags: new string[] { "identityapi" });

View File

@ -27,6 +27,7 @@
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" /> <PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta8" /> <PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta8" />
<PackageReference Include="Microsoft.ApplicationInsights.ServiceFabric" Version="2.1.1-beta1" /> <PackageReference Include="Microsoft.ApplicationInsights.ServiceFabric" Version="2.1.1-beta1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" /> <PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="2.2.0-preview3-35497" /> <PackageReference Include="Microsoft.Extensions.Http.Polly" Version="2.2.0-preview3-35497" />
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.0-preview3-35497" /> <PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.0-preview3-35497" />

View File

@ -16,6 +16,7 @@ using System.IO;
using WebSPA.Infrastructure; using WebSPA.Infrastructure;
using HealthChecks.UI.Client; using HealthChecks.UI.Client;
using Microsoft.AspNetCore.Diagnostics.HealthChecks; using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.Diagnostics.HealthChecks;
namespace eShopConContainers.WebSPA namespace eShopConContainers.WebSPA
{ {
@ -44,6 +45,7 @@ namespace eShopConContainers.WebSPA
RegisterAppInsights(services); RegisterAppInsights(services);
services.AddHealthChecks() services.AddHealthChecks()
.AddCheck("self", () => HealthCheckResult.Healthy())
.AddUrlGroup(new Uri(Configuration["PurchaseUrlHC"]), name: "purchaseapigw-check", tags: new string[] { "purchaseapigw" }) .AddUrlGroup(new Uri(Configuration["PurchaseUrlHC"]), name: "purchaseapigw-check", tags: new string[] { "purchaseapigw" })
.AddUrlGroup(new Uri(Configuration["MarketingUrlHC"]), name: "marketingapigw-check", tags: new string[] { "marketingapigw" }) .AddUrlGroup(new Uri(Configuration["MarketingUrlHC"]), name: "marketingapigw-check", tags: new string[] { "marketingapigw" })
.AddUrlGroup(new Uri(Configuration["IdentityUrlHC"]), name: "identityapi-check", tags: new string[] { "identityapi" }); .AddUrlGroup(new Uri(Configuration["IdentityUrlHC"]), name: "identityapi-check", tags: new string[] { "identityapi" });
@ -87,6 +89,11 @@ namespace eShopConContainers.WebSPA
app.UseHsts(); app.UseHsts();
} }
app.UseHealthChecks("/liveness", new HealthCheckOptions
{
Predicate = r => r.Name.Contains("self")
});
app.UseHealthChecks("/hc", new HealthCheckOptions() app.UseHealthChecks("/hc", new HealthCheckOptions()
{ {
Predicate = _ => true, Predicate = _ => true,
@ -115,11 +122,6 @@ namespace eShopConContainers.WebSPA
app.UsePathBase(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) => app.Use(async (context, next) =>
{ {
await next(); await next();

View File

@ -91,6 +91,7 @@
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" /> <PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta8" /> <PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta8" />
<PackageReference Include="Microsoft.ApplicationInsights.ServiceFabric" Version="2.1.1-beta1" /> <PackageReference Include="Microsoft.ApplicationInsights.ServiceFabric" Version="2.1.1-beta1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.0-preview3-35497" /> <PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.0-preview3-35497" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.Redis" Version="2.2.0-preview2-35157" /> <PackageReference Include="Microsoft.AspNetCore.DataProtection.Redis" Version="2.2.0-preview2-35157" />

View File

@ -1,17 +1,22 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace WebStatus.Controllers namespace WebStatus.Controllers
{ {
public class HomeController : Controller public class HomeController : Controller
{ {
public HomeController() private IConfiguration _configuration;
public HomeController(IConfiguration configuration)
{ {
_configuration = configuration;
} }
public IActionResult Index() public IActionResult Index()
{ {
return Redirect("/hc-ui"); var basePath = _configuration["PATH_BASE"];
return Redirect($"{basePath}/hc-ui");
} }
public IActionResult Error() public IActionResult Error()

View File

@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace WebStatus namespace WebStatus
@ -26,6 +27,9 @@ namespace WebStatus
RegisterAppInsights(services); RegisterAppInsights(services);
services.AddOptions(); services.AddOptions();
services.AddHealthChecks()
.AddCheck("self", () => HealthCheckResult.Healthy());
services.AddHealthChecksUI(); services.AddHealthChecksUI();
services.AddMvc() services.AddMvc()
@ -55,11 +59,15 @@ namespace WebStatus
app.UsePathBase(pathBase); app.UsePathBase(pathBase);
} }
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously app.UseHealthChecks("/liveness", new HealthCheckOptions
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 Predicate = r => r.Name.Contains("self")
});
app.UseHealthChecksUI(config => config.UIPath = "/hc-ui"); app.UseHealthChecksUI(config => {
config.ResourcesPath = string.IsNullOrEmpty(pathBase) ? "/ui/resources" : $"{pathBase}/ui/resources";
config.UIPath = "/hc-ui";
});
app.UseStaticFiles(); app.UseStaticFiles();

View File

@ -5,18 +5,22 @@
<DockerComposeProjectPath>..\..\..\docker-compose.dcproj</DockerComposeProjectPath> <DockerComposeProjectPath>..\..\..\docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.UI" Version="2.2.0" /> <Compile Remove="Views\**" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.0" /> <Content Remove="Views\**" />
<EmbeddedResource Remove="Views\**" />
<None Remove="Views\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.UI" Version="2.2.8" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.2" />
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="2.2.0" /> <PackageReference Include="AspNetCore.HealthChecks.Uris" Version="2.2.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.2.1" /> <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.2.1" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" /> <PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta8" /> <PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta8" />
<PackageReference Include="Microsoft.ApplicationInsights.ServiceFabric" Version="2.1.1-beta1" /> <PackageReference Include="Microsoft.ApplicationInsights.ServiceFabric" Version="2.1.1-beta1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.0-preview3-35497" /> <PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.0-preview3-35497" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Views\" />
</ItemGroup>
</Project> </Project>