0

I have a .cer file that I have converted into an "App settings" under "Application Settings" on Azure. I then add the setting key value pair in my app.config file with dummy info (and via "programmagic" is supposed to be updated when running on the Azure... The code works on my machine, but it is not getting pulled from my Azure "App settings" when I run it on Azure ... .

My "App Setting" in "Application Settings" on my MVC5 Web App:

Name: MyCER
Value: -----BEGIN CERTIFICATE----- goobledegookthatrunsfor1600charsOrSo -----END CERTIFICATE-----

My app.config reference:

<appSettings>
  <add key="CERFile" value="TEST"/>
</appSettings>

My code call (This works locally but not on Azure):

    Cert cert = new Cert();
    cert.LoadFromBase64(ConfigurationManager.AppSettings["CERFile"]);

Do I need to set permissions to allow this to work? I am also trying to do the same with my connection strings, and have not gotten that to work either.

Danimal111
  • 1,976
  • 25
  • 31
  • What do you mean, when you say you can't access the file? You haven't shown any code you're using to open the file, and you haven't shown any error message. Also, it would really help to show a screenshot from your kudu console, since your examples are using different paths (`wwwroot\data.txt`, `wwwroot\bin\Images\MyIcon.jpg`). Please edit your question accordingly. – David Makogon Feb 07 '17 at 14:15
  • Thanks... turns out I screwed up.. I tracked the error message and this had to do with an encryption... pem file. I found that you cannot access a pem file via the filesystem on Azure. I am trying to do the same with "App settings" under "Application Settings" on Azure, and adding the certificate and just dummy info in the app.config file (and via programmagic it gets updated when running on the site... I will ammend my question... – Danimal111 Feb 07 '17 at 15:41

1 Answers1

0

The correct way of using Certificates in Azure Webapps is https://azure.microsoft.com/en-us/blog/using-certificates-in-azure-websites-applications/

Any other way of constructing X509Certificate2 object will fail on Azure WebApps

Puneet Gupta
  • 2,237
  • 13
  • 17
  • Thanks for this answer... but I don't see that option listed in the link on the site? Maybe I'm missing something and the ssl cert only seems to allow me to upload a pfx file, but I have 2 files - one is a .pem and the other is a .cer ... How can I use these on Azure? – Danimal111 Feb 07 '17 at 23:41
  • You need to convert the .PEM file to PFX. Check this article http://stackoverflow.com/questions/808669/convert-a-cert-pem-certificate-to-a-pfx-certificate – Puneet Gupta Feb 08 '17 at 07:49