Search code examples
azureazure-functionsazure-linux

Linux Function App in Azure portal won't start because it keeps looking for a directory in /home/site/wwwroot/


I've been trying to get my Linux Function App running, but I've been stuck with this error now:

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

I can see all my project dlls and assets in /home/site/wwwroot/ yet this error keeps claiming that there should be a folder or file with my project name there?

My project is running using dotnet 6 isolated.

Any ideas why this FunctionMetadataLoader is looking for this file/folder? I checked similar Windows apps that I've deployed and they all have files directly in wwwroot.

This app is running within a Linux OS, I1 tier asp. And it release from CICD in Azure DevOps Zip Deploy.

Here is part of my arm template for the Function App.

"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": "0"
                    }
                  ],
                  "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 File:

<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>

Solution

  • win-x64 needs to be linux-x64 if you're running a Linux Function App