Service Fabric is a distributed systems platform for packaging, deploying, and managing stateless and stateful distributed applications and containers at large scale.
When using the Service Fabric WebAPI template in VS15 (15.7.3) to autheticate to my AAD instance, I receive the following error:
Error:
Microsoft.IdentityModel.Tokens.SecurityTokenInvalidSignatureException: IDX10500: Signature validation failed. No security keys were provided to validate the signature.
After much head-scratching as the stand-alone WebAPI template works and produces the same core WebAPI project, I located the issue - the AzureAD option object was not populating.
Cause:
Startup.cs had:
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
Needs to be similar to below (no doubt there is a neater solution, but this works):
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
Hi,
When using the Service Fabric WebAPI template in VS15 (15.7.3) to autheticate to my AAD instance, I receive the following error:
Error: Microsoft.IdentityModel.Tokens.SecurityTokenInvalidSignatureException: IDX10500: Signature validation failed. No security keys were provided to validate the signature.
After much head-scratching as the stand-alone WebAPI template works and produces the same core WebAPI project, I located the issue - the AzureAD option object was not populating.
Cause:
Startup.cs had: public Startup(IConfiguration configuration) { Configuration = configuration; }
Needs to be similar to below (no doubt there is a neater solution, but this works):
public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
I've attached a working solution bar obsfucating the AAD details. This solution was created from the template. SFApplication.zip
I hope this helps,
Jason