I have developed an Blazor server app that uses AzureAdB2C to authenticate users. The app is deployed in a kubernetes cluster and is accessible via a subdomain such as myapp.domain.com.
The authentication process works perfectly when there is only one pod running. However, when I increase the number of replicas for the workload, I encounter an HTTP 500 error after the authentication process (from Microsoft redirecting back to my app).
Here is the part of code for the authentication (located in Program.cs) :
builder.Services.AddAuthentication( options =>
{
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
})
.AddMicrosoftIdentityWebApp(options =>
{
configuration.Bind("AzureAd", options);
options.Events ??= new OpenIdConnectEvents();
options.Events.OnTokenValidated += OnTokenValidatedFunc;
})
;
async Task OnTokenValidatedFunc(TokenValidatedContext context) {
// Custom code here
await Task.CompletedTask.ConfigureAwait(false); }
Could you please assist with this issue?
1