Reino Boonstra
Reino Boonstra

Reputation: 63

Azure Functions: Microsoft.Azure.WebJobs.Script: Error building configuration in an external startup class. System.Private.CoreLib

I recently made a new deployment to my Azure Functions app, using a publish profile. Now Azure Functions cannot start the Functions app and throws the below exception:

Microsoft.Azure.WebJobs.Script: Error building configuration in an external startup class. System.Private.CoreLib: Could not load file or assembly 'MyApp.Api, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

The Azure Functions version is v4.

I have tried creating a new Function App with a new publish profile, but the exception persists. The functions app is written in .NET 6 LTS. I have seen a few similar posts, but the situations described in there are different in the fact that my Function app won't even start. Not showing any functions or whatsoever. Locally the Functions app runs, but shows the same message in the Stack Trace Explorer.

Any ideas on what can be the cause of this issue?

Upvotes: 0

Views: 6698

Answers (2)

Reino Boonstra
Reino Boonstra

Reputation: 63

I found the solution. I'm building and deploying my solution in x64 for a while, without any problems. I never realized that you can set your Functions app to x64 in Azure as well. Via the configuration menu by selecting the tab 'General Settings'. After I set it to x64, my Functions started to appear again. For some reason this hasn't been a problem before.

Azure Functions Configuration Page

Upvotes: 3

SiddheshDesai
SiddheshDesai

Reputation: 8195

I created one .Net 6.0 Http Trigger Function and published it to Azure Function app successfully like below:-

enter image description here

My http Function.cs code:-

using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;

namespace FunctionApp32
{
    public static class Function1
    {
        [FunctionName("Function1")]
        public static async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");

            string name = req.Query["name"];

            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            dynamic data = JsonConvert.DeserializeObject(requestBody);
            name = name ?? data?.name;

            string responseMessage = string.IsNullOrEmpty(name)
                ? "This HTTP triggered function executed successfully.Pass name in query string"
                : $"Hello, {name}. This HTTP triggered function executed successfully.";

            return new OkObjectResult(responseMessage);
        }
    }
}

My Function.csproj file:-

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.2.0" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project>

enter image description here

enter image description here

While Publishing, Make sure you have storage account and Application Insights settings added. And make sure the storage account and Application Insights is accessible in Portal Refer below:-

enter image description here

Azure Function running successfully in Portal:-

enter image description here

Make sure to add below settings in your Function App Settings:-

enter image description here

If the issue persists check the Application Insights traces and Function Logs like below:-

enter image description here

enter image description here

Refer this troubleshooting guide on the same error and my SO thread answer to get detailed logging in Azure Function app.

Upvotes: 1

Related Questions