Azure门户中的Linux Function应用程序无法启动,因为它一直在/home/site/wwwroot/中查找目录

z2acfund  于 2023-10-22  发布在  Linux
关注(0)|答案(2)|浏览(116)

我一直在尝试运行我的Linux Function应用程序,但我现在一直被这个错误卡住:
Microsoft.Azure.WebJobs.Script:在外部启动类中生成配置时出错。Microsoft.Azure.WebJobs.Extensions.FunctionMetadataLoader:未找到文件“/home/site/favicon. ico”。
我可以在/home/site/wwwroot/中看到我所有的项目dll和资产,但这个错误一直声称应该有一个文件夹或文件与我的项目名称在那里?
我的项目是使用dotnet 6隔离运行。
任何想法为什么这个FunctionMetadataLoader正在寻找这个文件/文件夹?我检查了我部署的类似Windows应用程序,它们都直接在wwwroot中有文件。
此应用程序在Linux操作系统中运行,I1层ASP。它在Azure DevOps Zip Deploy中从CICD发布。
这里是我的手臂模板的一部分功能应用程序。

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

rkkpypqq1#

我尝试在Azure DevOps中通过ARM模板使用Function App部署**.Net 6.0 Isolated Function**,并成功运行,参考如下:-

  • 我的ARM模板代码使用源代码控制参数参考我的github函数代码库:-*
    functionapp.json

你可以试试这个ARM模板进行测试。
下面的ARM模板参考来自我的SO线程答案请参考我的答案,以了解如何使用ARM模板部署Function应用程序和触发器。

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "appName": {
            "defaultValue": "[concat('funtionapp-', uniqueString(resourceGroup().id))]",
            "type": "string",
            "metadata": {
                "description": "The name of the function app that you wish to create."
            }
        },
        "sku": {
            "defaultValue": "S1",
            "type": "string",
            "metadata": {
                "description": "The pricing tier for the hosting plan."
            }
        },
        "workerSize": {
            "defaultValue": "0",
            "allowedValues": [
                "0",
                "1",
                "2"
            ],
            "type": "String",
            "metadata": {
                "description": "The instance size of the hosting plan (small, medium, or large)."
            }
        },
        "storageAccountType": {
            "defaultValue": "Standard_LRS",
            "allowedValues": [
                "Standard_LRS",
                "Standard_GRS",
                "Standard_ZRS",
                "Premium_LRS"
            ],
            "type": "string",
            "metadata": {
                "description": "Storage Account type"
            }
        },
        "repoURL": {
            "defaultValue": "https://github.com/sid24desai/FunctionApp49",
            "type": "string",
            "metadata": {
                "description": "The URL for the GitHub repository that contains the project to deploy."
            }
        },
        "branch": {
            "defaultValue": "master",
            "type": "string",
            "metadata": {
                "description": "The branch of the GitHub repository to use."
            }
        },
        "location": {
            "defaultValue": "[resourceGroup().location]",
            "type": "string",
            "metadata": {
                "description": "Location for all resources."
            }
        }
    },
    "variables": {
        "functionAppName": "[parameters('appName')]",
        "hostingPlanName": "[concat(parameters('appName'), '-plan')]",
        "storageAccountName": "[concat(uniquestring(resourceGroup().id), 'functions')]"
    },
    "resources": [
        {
            "type": "Microsoft.Storage/storageAccounts",
            "apiVersion": "2021-02-01",
            "name": "[variables('storageAccountName')]",
            "location": "[parameters('location')]",
            "sku": {
                "name": "[parameters('storageAccountType')]"
            },
            "kind": "Storage"
        },
        {
            "type": "Microsoft.Web/serverfarms",
            "apiVersion": "2020-12-01",
            "name": "[variables('hostingPlanName')]",
            "location": "[parameters('location')]",
            "sku": {
                "name": "[parameters('sku')]"
            },
            "properties": {
                "workerSize": "[parameters('workerSize')]",
                "numberOfWorkers": 1
            }
        },
        {
            "type": "Microsoft.Web/sites",
            "apiVersion": "2020-12-01",
            "name": "[variables('functionAppName')]",
            "location": "[parameters('location')]",
            "dependsOn": [
                "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]",
                "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
            ],
            "kind": "functionapp",
            "properties": {
                "name": "[variables('functionAppName')]",
                "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]",
                "clientAffinityEnabled": false,
                "siteConfig": {
                    "alwaysOn": true,
                    "cors": {
                        "allowedOrigins": [
                            "*"
                        ]
                    },
                    "appSettings": [
                        {
                            "name": "FUNCTIONS_EXTENSION_VERSION",
                            "value": "~v4"
                        },
                        {
                            "name": "AzureWebJobsStorage",
                            "value": "[concat('DefaultEndpointsProtocol=https;AccountName=',variables('storageAccountName'),';AccountKey=',listkeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2019-06-01').keys[0].value,';')]"
                        },
                        {
                            "name": "AzureWebJobsDashboard",
                            "value": "[concat('DefaultEndpointsProtocol=https;AccountName=',variables('storageAccountName'),';AccountKey=',listkeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2019-06-01').keys[0].value,';')]"
                        }
                    ]
                }
            },
            "resources": [
                {
                    "type": "sourcecontrols",
                    "apiVersion": "2020-12-01",
                    "name": "web",
                    "dependsOn": [
                        "[resourceId('Microsoft.Web/Sites', variables('functionAppName'))]"
                    ],
                    "properties": {
                        "RepoUrl": "[parameters('repoURL')]",
                        "branch": "[parameters('branch')]",
                        "IsManualIntegration": true
                    }
                }
            ]
        }
    ]
}

我的Azure Devops存储库:-

我的构建yaml管道:-

trigger:
- main

pool:
  vmImage: ubuntu-latest

steps:
- task: AzureResourceManagerTemplateDeployment@3
  displayName: 'ARM Template deployment: Resource Group scope'
  inputs:
    deploymentScope: 'Resource Group'
    azureResourceManagerConnection: 'xxx subscription(xxxxd6-b4fd-e2xxxx)'
    subscriptionId: 'xxxxxxxxx2a7'
    action: 'Create Or Update Resource Group'
    resourceGroupName: 'valleyrg103'
    location: 'Australia East'
    templateLocation: 'Linked artifact'
    csmFile: '$(System.DefaultWorkingDirectory)/functionapp.json'
    deploymentMode: 'Incremental'

输出:-

请确保在CORS设置中添加此**https://portal.azure.com**,如下所示:

带有.net 6.0隔离函数的函数应用程序已部署并成功运行,请参阅以下内容:-

使用ARM模板部署的发布管道的相同部署:资源组范围任务:-

输出:-

rsl1atfo

rsl1atfo2#

win-x64必须是linux-x64,如果你运行的是Linux Function应用程序

相关问题