I am trying to call my webapp from Azure function using timer trigger, for which I am using DefaultAzureCredential. I have already enabled a system assigned managed identity for function app. The code for getting the token:
var ledgerName = _config["LEDGER_NAME"];
var defaultCredential = new DefaultAzureCredential();
var ledgerUri = $"https://{ledgerName}.confidential-ledger.azure.com";
var endpoint = new Uri(ledgerUri);
var ledgerClient = new ConfidentialLedgerClient(endpoint, defaultCredential);
When I test the consumption of my function in local it works fine, but when I deploy it to azure and consume it from there is when I get the following error:
ManagedIdentityCredential authentication failed: Service request failed.
Status: 500 (Internal Server Error)
Content:
Headers:
Date: Wed,
03 Jan 2024 05: 13: 11 GMT
Server: Kestrel
Transfer-Encoding: chunked
X-CORRELATION-ID: REDACTED
Content-Type: application/json; charset=utf-8
See the troubleshooting guide for more information. https: //aka.ms/azsdk/net/identity/managedidentitycredential/troubleshoot
Some properties are put in my local configuration file.settings.json, and those same ones I have added in the azure portal variables in my application.
Has anyone else had this happen? Is it necessary to do some extra configuration on the azure side?
Every contribution helps me, thank you very much.
the result I expect from my function is a json, which makes use of confidential ledger, in order to store the hash to create the certificate.
In Portal, Ledger creation there is option to select only users or Certificate as
Administrator.I created using
Azure CLIas it provides option to create with principal id, So I created using of my function's Managed Identity'sPrincipal IDand it worked for me. For Reference check this document#My Code
timefunc.cs:.csproj:OUTPUT: