You are developing a secure background daemon application in C# that runs as an on-premises scheduled task. The application must periodically retrieve records from a secured downstream Azure Web API. The organization's security policy strictly prohibits the use of client secrets (passwords) for authentication. Instead, you must authenticate using a client certificate. You have already registered the daemon application in Microsoft Entra ID.
Which two of the following actions must you perform to configure the application registration and implement the authentication flow using MSAL.NET? (Select two.)
- In the C# application code, retrieve the certificate and instantiate the client using ConfidentialClientApplicationBuilder.Create(clientId).WithCertificate(certificate).WithAuthority(AzureCloudInstance.AzurePublic, tenantId).Build().Answer
- In the Microsoft Entra admin center, select the registered application, navigate to Certificates & secrets, select the Certificates tab, upload the public key file (.cer) of the certificate, and save.Answer
- CIn the C# application code, retrieve the certificate and instantiate the client using PublicClientApplicationBuilder.Create(clientId).WithCertificate(certificate).Build().
- DIn the Microsoft Entra admin center, select the registered application, navigate to API permissions, select Add a permission, select Microsoft Graph, select Delegated permissions, and grant consent for the User.Read.All scope.
Answer
The application must be configured in Microsoft Entra ID by uploading the public key (.cer) to the Certificates tab of the Certificates & secrets page, and implemented in C# by instantiating the client using ConfidentialClientApplicationBuilder.Create(clientId).WithCertificate(certificate).WithAuthority(AzureCloudInstance.AzurePublic, tenantId).Build().
For a daemon application to authenticate securely using a certificate, it must register the public key in Microsoft Entra ID under the application's Certificates & secrets section, and the application code must use the ConfidentialClientApplicationBuilder class with the WithCertificate method to sign the client assertion and acquire tokens.
Step-by-Step Solution
Key Concept
Daemon applications using MSAL.NET and Microsoft Identity Platform must act as confidential client applications and authenticate using client credentials (either client secrets or client certificates). In Entra ID, the public key of the certificate is registered, while the private key is used in C# code with the ConfidentialClientApplicationBuilder to acquire a token.