Exploring Neon as a Serverless Postgres Alternative for .NET Applications on Azure - Part 1 (Simple ASP.NET Core on App Service)10 lut 2025
Blog | programowanie | .net | c# | azure | IT
Final release of ASP.NET Core 2.2 is getting closer and I've started devoting some time to get familiar with new features and changes. One of new features, which extends ASP.NET Core diagnostics capabilities, are health checks. Health checks aim at providing way to quickly determine application condition by an external monitor (for example container orchestrator). This is valuable and long awaited feature. It's also significantly changing from preview to preview. I wanted to grasp current state of this feature and I couldn't think of better way to do it, than in context of concrete scenario.
One of external resources, which is often a dependency of my applications, is Redis. Most of the time this comes as a result of using distributed cache.
public class Startup
{
public IConfiguration Configuration { get; }
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public void ConfigureServices(IServiceCollection services)
{
services.AddDistributedRedisCache(options =>
{
options.Configuration = Configuration["DistributedRedisCache:Configuration"];
options.InstanceName = Configuration["DistributedRedisCache:InstanceName"];
});
...
}
...
}
In order to make sure that application, which uses Redis backed distributed cache, works as it's supposed to, two things should be checked. One is presence of configuration and second is availability of Redis instance. Those are two health checks I would want to create.
In general health checks are represented by HealthCheckRegistration which requires providing an instance of a health check implementation or a factory of such instances. Working with
noreply@blogger.com (Tomasz Pęczek)