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
Not so long ago my colleague reached out with a question "Are there any known issues with ITelemetryInitializer in Azure Functions?". This question started a discussion about the monitoring configuration for C# Azure Functions in the isolated worker model. At some point in that discussion I stated "Alright, you've motivated me, I'll make a sample". When I sat down to do that, I started wondering which scenario should I cover and my conclusion was that there are several things I should go through... So here I am.
Before I start describing how we can monitor an isolated worker model C# Azure Function, allow me to introduce you to the one we are going to use for this purpose. I want to start with as basic setup as possible. This is why the initial Program.cs will contain only four lines.
var host = new HostBuilder()
.ConfigureFunctionsWebApplication()
.Build();
host.Run();
The host.json will also be minimal.
{
"version": "2.0",
"logging": {
"logLevel": {
"default": "Information"
}
}
}
For the function itself, I've decided to go for the Fibonacci sequence implementation as it can easily generate a ton of logs.
public class FibonacciSequence
{
private readonly ILogger<FibonacciSequence> _logger;
public FibonacciSequence(ILogger<FibonacciSequence> logger)
{
_logger = logger;
}
[Function(nameof(FibonacciSequence))]
public async Task<HttpResponseData> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "fib/{index:int}")]
HttpRequestData request,
int index)
{
_logger.LogInformation(
$"{nameof(FibonacciSequence)} function triggered for {{index}}.",
index
);
var response = request.CreateResponse(HttpStatusCode.OK)noreply@blogger.com (Tomasz Pęczek)