GCN-AZ-42d458c58299
GCN-AZ-42d458c58299: Unable to start GoCloudNative.Bff. Invalid TenantId. Configure the TenantId in the appsettings.json or program.cs file and try again.
The GoCloudNative BFF is an authentication gateway. As a result, you must configure an identity provider (correctly) for it to start.
To bootstrap the BFF, load the identity provider configuration from the appsettings.json:
//...
var builder = WebApplication.CreateBuilder(args);
var config = builder.Configuration.GetSection("Azure");
builder.Services.AddSecurityBff(o =>
{
o.ConfigureAzureAd(config);
//...
});
How to reproduce this error
To reproduce the error, the ClientId needs to be missing:
"Oidc": {
"CliendId": "{yourClientId}",
"ClientSecret": "{yourClientSecret}",
"Authority": "https://{yourAuthority}",
"Scopes": [
"openid", "profile", "offline_access"
]
},
or empty:
"Oidc": {
...
"TenantId": "",
...
},
or misspelled:
"Oidc": {
...
"TenandId": "",
...
},
or incorrect casing:
"Oidc": {
...
"tenantid": "",
...
},
Solution
Configure the ClientId correctly:
"Oidc": {
"CliendId": "{yourClientId}",
"ClientSecret": "{yourClientSecret}",
"TenantId": "{yourTenantId}",
"Authority": "https://{yourAuthority}",
"Scopes": [
"openid", "profile", "offline_access"
]
},
and restart the BFF.
How to find the ClientId in Azure
To find the correct value for the TenantId variable,
- navigate to the Azure Portal, navigate to Azure Active Directory, and click
App Registrationsin the menu on the left. - Select your app registrations or create one. (If you don’t have an app registration yet, follow the Azure Active Directory Quickstart)
- This is what the overview page of an
App registrationlooks like:
- Copy the
Directory (tenant) IDvalue to theappsettings.jsonfile.