For a prototype I loaded a pfx certificate from file system of Azure App. It can be done only while test!!And I got the error "Exception Info: System.Security.Cryptography.CryptographicException: The system cannot find the file specified."

The error was
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Security.Cryptography.CryptographicException: The system cannot find the file specified.
at System.Security.Cryptography.X509Certificates.CertificatePal.FilterPFXStore(ReadOnlySpan`1 rawData, SafePasswordHandle password, PfxCertStoreFlags pfxCertStoreFlags)
at System.Security.Cryptography.X509Certificates.CertificatePal.FromBlobOrFile(ReadOnlySpan`1 rawData, String fileName, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags)
at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(Byte[] rawData, String password, X509KeyStorageFlags keyStorageFlags)
at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(Byte[] rawData, String password)

The code was

string certPath = @"c:\home\site\wwwroot\certs\Item.Webhooks.pfx";
var certificate = new X509Certificate2(certPath, "CertPass");

and it worked perfectly in my Windows machine. But not in Azure.

2 hours of troubleshooting and one more parameter for the object and it works! X509KeyStorageFlags.MachineKeySet!

string certPath = @"c:\home\site\wwwroot\certs\Item.Webhooks.pfx";
var certificate = new X509Certificate2(certPath, "CertPass", X509KeyStorageFlags.MachineKeySet);