I have created a new Blazor WebAssembly App with Individual User Accounts, Store user accounts in-app and ASP.NET Core hosted in .NET 5. When deploying my app to Azure App Service I get the following error:

> 
> Object reference not set to an instance of an object.at
> Microsoft.Extensions.DependencyInjection.IdentityServerBuilderConfigurationExtensions
> 
> 
> 

Reading these links I have to provide my own certificate in production for IdentityServer:

[Blazor Web Assembly App .Net Core Hosted: publish runtime error](https://stackoverflow.com/q/64186403/3850405)

<https://stackoverflow.com/a/56904000/3850405>

<https://learn.microsoft.com/en-us/aspnet/core/security/authentication/identity-api-authorization?view=aspnetcore-5.0#example-deploy-to-azure-app-service>

I then created a `.pfx` file like this and I have verified that it works and my password is correct.

<https://stackoverflow.com/a/48790088/3850405>

I then placed the `.pfx` file in my `Server` projects root folder and marked `Copy to Output Directory` as `Copy Always`.

I then updated `appsettings.json` to look like this:

```
  "IdentityServer": {
    "Clients": {
      "BlazorTest.Client": {
        "Profile": "IdentityServerSPA"
      }
    },
    "Key": {
      "Type": "File",
      "FilePath": "localhost.pfx",
      "Password": "MySercurePassword123?"
    }
  },

```

Now the project does not work neither locally or on Azure. It fails on `app.UseIdentityServer();` in `Startup.cs` with the following error:

> 
> Newtonsoft.Json.JsonReaderException: 'Unexpected character encountered
> while parsing number: �. Path '', line 1, position 1.'
> 
> 
> 

According to Microsoft docs my certificate should be valid:

A production certificate to use for signing tokens.

* There are no specific requirements for this certificate; it can be a self-signed certificate or a certificate provisioned through a CA authority.
* It can be generated through standard tools like PowerShell or OpenSSL.
* It can be installed into the certificate store on the target machines or deployed as a .pfx file with a strong password.

<https://learn.microsoft.com/en-us/aspnet/core/security/authentication/identity-api-authorization?view=aspnetcore-5.0#deploy-to-production>

If I load the key like this it works:

```
"Key": {
  "Type": "Store",
  "StoreName": "My",
  "StoreLocation": "CurrentUser",
  "Name": "CN=blazortest"
}

```