Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Read .pfx certificate file in Azure Function/D365 CRM online

(0) ShareShare
ReportReport
Posted on by 1,825

Hi All,

I am working on azure function and I have to read the .pfx certificate file. Can some one please guide where to store the .pfx certificate and use in azure function?

I tried the below approaches but always I get the error "specified file could not find":
1) Tried uploading the file in KeyValut certificate, It restrict me to upload the .pfx file, it gives the error "Unsupported key size (1024). Supported sizes are [2048, 3072, 4096]".
2) Uploaded the file in AzureBlob and read the file by url in azure function, unfortunately it doesn't help.
3)Reading the file from kudo bin(azure function) doesnt work

 X509Certificate2 cert = new X509Certificate2("certificatepath", "password");


Thanks
Hemant

*This post is locked for comments

  • RE: Read .pfx certificate file in Azure Function/D365 CRM online

    Hello Hemant,

    I have same problem. How you manage this. I created folder inside my project as cert but when i deploy i can't find same in deployed version.

    Can you please help to check this issue

  • Hemant Kumar Sahu Profile Picture
    Hemant Kumar Sahu 1,825 on at
    RE: Read .pfx certificate file in Azure Function/D365 CRM online

    Thanks Ravi, I am able to manage it.

    Regards

    Hemant

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Read .pfx certificate file in Azure Function/D365 CRM online

    No,

    I had that folder in my solution itself. Refer below screenshot. By the way, it does not have to be a same folder structure as long as you provide the correct path while reading the certificate file.

    visual-studio.png

    Hope this helps.

  • Hemant Kumar Sahu Profile Picture
    Hemant Kumar Sahu 1,825 on at
    RE: Read .pfx certificate file in Azure Function/D365 CRM online

    Thanks Ravi for your reply.

    Did you create a folder "Resources" in kudo?

    I can not find the folder 'Resources' in kudo when I open it so I created folder manually in kudo but whenever I build my Azure Function and publish from visual studio , the folder gets removed.

    Regards

    Hemant

  • Verified answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Read .pfx certificate file in Azure Function/D365 CRM online

    Hi,

    I worked on the similar scenario where I wanted run my code recusivly. I used Azure function app and configure a timer trigger. The App was console application which uses the Certificate.  Whithin the console app, I retrieved the certificate path from config. The actual certificate file I stored in in Kudo under the Resource folder and the updated the path in config like this-

    <add key="SigningCertificate" value="D:\home\site\wwwroot\MyAzureFunction\Resources\cert\mycertificatefile.pfx" />

    I referred the below blog for this-

    anthonychu.ca/.../

    Hopefully this will help you as well.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,309 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans