Registry is not supported on this platform error appears in Azure after changing OS to Linux in environment

i use microsoft graph api, for that i have an implemented method to create a token for the api to use depending on the Azure tennant, this method works when tested loclally and when environment was on Windows OS, this is the method to generate a token

public static string GetAPIToken()
{
    IConfidentialClientApplication appConfidential = ConfidentialClientApplicationBuilder.Create(AppSettingsHelper.GetGraphClientId())
        .WithClientSecret(AppSettingsHelper.GetGraphSecret())
        .WithAuthority(new Uri(String.Format(Constants.GraphAPISettings.authority, AppSettingsHelper.GetGraphTenantId())))
        .Build();

    string[] scopes = new string[] { Constants.GraphAPISettings.resrouce + "/.default" };

    AuthenticationResult result = appConfidential.AcquireTokenForClient(scopes).ExecuteAsync().GetAwaiter().GetResult();
    string apiToken = result.AccessToken;

    return apiToken;
}

this method uses the values from local settings to generate the token , as i mentioned earlier the method works when i test it locally in visual studio but when published i get the error :
Registry is not supported on this platform
after some debugging i found the error is the result variable which returns AuthenticationResult but i can’t seem to figure out a fix for the issue

Leave a Comment