Linux Function app does not start with WEBSITE_RUN_FROM_PACKAGE = 1

David Sun 20 Reputation points
2023-10-16T03:37:54.39+00:00

Update I deployed the most rudimentary of functions, the HttpTrigger ping test. I used the barebones of required configurations, same dotnet version and all, and it appear to be working fine and returns a 200. So this leads me to believe it has to do with my Program.cs file. There's something in there causing this issue. So I believe my best bet is to simply deploy a chunk of the HostBuilder at a time until I can cause this issue.

Hello,

I'm at a lost at this point. I've read most if not all of the documentation and examples of deploying a Linux Function App. But none of them have been any help in resolving my current issue. Once my Function App is published I see this error message:

User's image

Microsoft.Azure.WebJobs.Script: Error building configuration in an external startup class. Microsoft.Azure.WebJobs.Extensions.FunctionMetadataLoader: The file '/home/site/wwwroot/PGO.PowerBI.Export' was not found.

From what I've read my Function App is running from the mounted zip in User's image

So why is the FunctionMetadataLoader looking in the /home/site/wwwroot/ directory?

I did notice that this host.json was created in wwwroot and it the only file there:

enter image description here

Below are my ARM and project files if this helps:

"resources": [
    {
      "apiVersion": "2021-04-01",
      "type": "Microsoft.Resources/deployments",
      "name": "[concat(parameters('appServiceName'), '-deployment','-', uniqueString(guid('any')))]",
      "dependsOn": [],
      "resourceGroup": "[parameters('appServiceResourceGroup')]",
      "properties": {
        "mode": "Incremental",
        "template": {
          "$schema": "http://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
          "contentVersion": "1.0.0.0",
          "variables": {},
          "resources": [
            {
              "apiVersion": "2018-11-01",
              "name": "[parameters('appServiceName')]",
              "type": "Microsoft.Web/sites",
              "location": "[parameters('location')]",
              "kind": "functionapp,linux",
              "tags": {
                "environment": "[parameters('environmentTag')]",
                "monitor": "[parameters('monitorTag')]",
                "owner": "[parameters('ownerTag')]",
                "workload": "[parameters('workloadTag')]",
                "serviceLine": "[parameters('serviceLineTag')]",
                "system": "[parameters('systemTag')]",
                "initiatingEpic": "[parameters('initiatingEpicTag')]",
                "dr": "[parameters('drTag')]",
                "notes": "[parameters('notesTag')]"
              },
              "identity": {
                "type": "UserAssigned",
                "userAssignedIdentities": {
                  "[resourceId(parameters('appServiceResourceGroup'),'Microsoft.ManagedIdentity/userAssignedIdentities/',parameters('managedIdentityName'))]": {}
                }
              },
              "properties": {
                "name": "[parameters('appServiceName')]",
                "httpsOnly": true,
                "reserved": true,
                "isXenon": false,
                "hyperV": false,
                "siteConfig": {
                  "use32BitWorkerProcess": false,
                  "minTlsVersion": "1.2",
                  "ftpsState": "Disabled",
                  "http20Enabled": true,
                  "netFrameworkVersion": "v6.0",
                  "linuxFxVersion": "DOTNET-ISOLATED|6.0",
                  "appSettings": [
                    {
                      "name": "APPINSIGHTS_INSTRUMENTATIONKEY",
                      "value": "[reference(variables('appInsightsResourceId'), variables('appInsightsApiVersion'), '2016-03-01').instrumentationKey]"
                    },
                    {
                      "name": "APPLICATIONINSIGHTS_CONNECTION_STRING",
                      "value": "[reference(variables('appInsightsResourceId'), variables('appInsightsApiVersion'), '2016-03-01').ConnectionString]"
                    },
                    {
                      "name": "ApplicationInsightsAgent_EXTENSION_VERSION",
                      "value": "~2"
                    },
                    {
                      "name": "FUNCTIONS_EXTENSION_VERSION",
                      "value": "~4"
                    },
                    {
                      "name": "FUNCTIONS_WORKER_RUNTIME",
                      "value": "dotnet-isolated"
                    },
                    {
                      "name": "AzureWebJobsStorage",
                      "value": "[parameters('storageAccountConnection')]"
                    },
                    {
                      "name": "AzureFunctionsWebHost__hostId",
                      "slotSetting": false,
                      "value": ""
                    },
                    {
                      "name": "WEBSITE_RUN_FROM_PACKAGE",
                      "slotSetting": false,
                      "value": "1"
                    }
                  ],
                  "connectionStrings": [],
                  "alwaysOn": true
                },
                "keyVaultReferenceIdentity": "[resourceId(parameters('appServiceResourceGroup'),'Microsoft.ManagedIdentity/userAssignedIdentities/',parameters('managedIdentityName'))]",
                "clientAffinityEnabled": false,
                "serverFarmId": "[resourceId(parameters('serverFarmResourceGroup'),'Microsoft.Web/serverFarms',parameters('appServicePlanName'))]",
                "hostingEnvironment": "[parameters('appServiceEnvironmentName')]"
              }
            }
          ]
        }
      }
    }
  ]
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
    <OutputType>Exe</OutputType>
    <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
    <PublishReadyToRun>true</PublishReadyToRun>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="8.0.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.10.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Warmup" Version="4.0.2" />
    <PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.21.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.7.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.7.0" OutputItemType="Analyzer">
      <TreatAsUsed>true</TreatAsUsed>
    </PackageReference>
    <PackageReference Include="Microsoft.FeatureManagement.AspNetCore" Version="2.5.1" />
    <PackageReference Include="Serilog.AspNetCore" Version="6.1.0" />
  </ItemGroup>

  <ItemGroup>

  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project>
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,911 questions
{count} votes

Accepted answer
  1. navba-MSFT 27,540 Reputation points Microsoft Employee Moderator
    2023-10-18T04:39:57.3733333+00:00

    @David Sun Thanks for getting back. I'm glad to see you were able to resolve your issue. Thanks for posting your solution so that others experiencing the same thing can easily reference this. Since the Microsoft Q&A community has a policy that the question author cannot accept their own answer, they can only accept answers by others, I'll repost your solution in case you'd like to Accept the answer.

    Issue:
    You are encountering the below issue after publishing your isolated Azure function app:

    Microsoft.Azure.WebJobs.Script: Error building configuration in an external startup class. Microsoft.Azure.WebJobs.Extensions.FunctionMetadataLoader: The file '/home/site/wwwroot/PGO.PowerBI.Export' was not found.
    Resolution:
    The issue was due to architectural mismatch. The error was occurring when RuntimeIdentifier is win-x64. Removing this it worked fine.

    **
    Please 'Accept as answer' and ‘Upvote’ so that it can help others in the community looking for help on similar topics.

    2 people found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

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.