Deploying with Microsoft.Graph sdk to Azure Function App Isolated Worker Net 8.0 causing InternalServerError from host runtime

Alexander Giacobbe 0 Reputation points
2024-12-26T19:18:29.9333333+00:00

I am trying to debug this issue where the inclusion of the Microsoft.Graph SDK is causing the azure function app host run time to fail.

Running the function app in debug mode locally I have no issues using Microsoft Graph to access the data I need. It is only after deploying the app that I receive an error in Azure:
User's image User's image

I am using Azure Identity alongside Microsoft.Graph to access Sharepoint through ClientSecretCredentials. Only one class/project has these dependencies:

<PackageReference Include="Azure.Identity" Version="1.13.1" />
<PackageReference Include="Microsoft.Graph" Version="5.67.0" />

SharepointClient.cs

public class SharepointClient
{
    private GraphServiceClient _graphClient;

    public SharepointClient(string tenantId, string clientId, string clientSecret)
    {
         var clientSecretCredential = new ClientSecretCredential(tenantId, clientId, clientSecret);
         _graphClient = new GraphServiceClient(clientSecretCredential);
    }

    / * ... */
}

I am not using Dependency Injection yet, I have only installed the package and receive this error after deploying.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,256 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,663 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Pinaki Ghatak 5,390 Reputation points Microsoft Employee
    2024-12-27T13:10:19.8766667+00:00

    Hello @Alexander Giacobbe

    This error message you shared indicates that the host runtime is unable to start the function app due to an internal server error.

    To troubleshoot this issue, you can try the following steps:

    1. Check the Azure Function App logs to see if there are any additional error messages that can provide more information about the issue. You can access the logs from the Azure portal by navigating to your Function App, selecting "Functions" from the left-hand menu, selecting your function, and then selecting "Logs" from the top menu.
    2. Check if there are any issues with the Azure Identity or Microsoft.Graph packages. You can try removing these packages and deploying the function app again to see if the issue persists. If the issue goes away, then it is likely that there is an issue with one of these packages.
    3. Check if there are any issues with the Azure Function App Isolated Worker Net 8.0. You can try deploying a simple function app without the Azure Identity or Microsoft.Graph packages to see if the issue persists. If the issue goes away, then it is likely that there is an issue with the Azure Function App Isolated Worker Net 8.0.
    4. Try using Dependency Injection to manage the Azure Identity and Microsoft.Graph packages. This can help to ensure that the packages are properly initialized and configured before they are used in your function app.

    .. Wishing you happy holidays


    I hope that this response has addressed your query and helped you overcome your challenges. If so, please mark this response as Answered. This will not only acknowledge our efforts but also assist other community members who may be looking for similar solutions.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.