- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试运行 Azure 函数,但在部署时遇到以下错误 --
Microsoft.Azure.WebJobs.Script: Error building configuration in an external startup class.
System.Private.CoreLib: Could not load file or assembly '<MyAssembly>, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null'.
但是我的部署成功了,我可以在 App Files 中看到该 DLL。我在 Functions v4.0 上运行 C#/.net 6.0,并使用部署中心生成的 GitHub 工作流操作进行部署。
什么会导致运行时无法看到主函数DLL?
添加应用程序文件的图像:
我的项目包引用:
<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.8.2" />
<PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.5.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.15.1" />
<PackageReference Include="Cosmonaut" Version="2.11.3" />
<PackageReference Include="Cosmonaut.ApplicationInsights" Version="2.1.1" />
<PackageReference Include="Cosmonaut.Extensions.Microsoft.DependencyInjection" Version="2.3.0" />
<PackageReference Include="Cosmonaut.NestedQueries" Version="2.11.4" />
<PackageReference Include="Microsoft.Azure.AppConfiguration.AspNetCore" Version="6.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.6.2" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.SendGrid" Version="3.0.3" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="5.1.1" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Azure" Version="1.6.3" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.3" />
</ItemGroup>
来自部署中心的部署 GitHub 操作:
# Docs for the Azure Web Apps Deploy action: https://github.com/azure/functions-action
# More GitHub Actions for Azure: https://github.com/Azure/actions
name: Build and deploy dotnet core app to Azure Function App - brokentoysapi3
on:
push:
branches:
- master
workflow_dispatch:
env:
AZURE_FUNCTIONAPP_PACKAGE_PATH: './api/_new/BrokenToys.Api/' # set this to the path to your web app project, defaults to the repository root
DOTNET_VERSION: '6.0.x' # set this to the dotnet version to use
jobs:
build-and-deploy:
runs-on: windows-latest
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v2
- name: Setup DotNet ${{ env.DOTNET_VERSION }} Environment
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: 'Resolve Project Dependencies Using Dotnet'
shell: pwsh
run: |
pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}'
dotnet build --configuration Release --output ./output
popd
- name: 'Run Azure Functions Action'
uses: Azure/functions-action@v1
id: fa
with:
app-name: 'brokentoysapi3'
slot-name: 'Production'
package: '${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}/output'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_E20EFE8EF7D84C4AA5B5C75BE0B66D0F }}
这是我的启动类(class):
using BrokenToys.Api.Models.Games;
using Cosmonaut;
using Cosmonaut.Extensions.Microsoft.DependencyInjection;
using Microsoft.Azure.Functions.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
[assembly: FunctionsStartup(typeof(BrokenToys.Api.Startup))]
namespace BrokenToys.Api
{
public class Startup : FunctionsStartup
{
public static IConfiguration Configuration { set; get; }
public override void Configure(IFunctionsHostBuilder builder)
{
var cosmosSettings =
new CosmosStoreSettings
("BrokenToys", "https://<mycosmosdb>.documents.azure.com:443/", "<mykey>");
builder.Services.AddCosmosStore<Score>(cosmosSettings);
builder.Services.AddCosmosStore<Player>(cosmosSettings);
}
}
}
最佳答案
Microsoft.Azure.WebJobs.Script: Error building configuration in an external startup class. System.Private.CoreLib: Could not load file or assembly ', Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
此错误表明运行时无法加载您的函数的程序集。这可能是由于多种原因造成的,例如文件路径不正确或函数名称不正确。检查以下步骤是否有助于解决问题:
验证错误消息中程序集的名称和版本是否与“App Files”文件夹中程序集的名称和版本相匹配。如果它们不匹配,您可能需要重建项目并重新部署它。
检查程序集是否位于“App Files”文件夹中的正确位置。它应该位于 bin 文件夹中,该文件夹位于函数应用的根目录中。
检查程序集是否与函数的运行时版本兼容,并检查函数应用是否配置为在 Azure 门户中使用正确的运行时版本。
检查您的 GitHub 工作流操作是否已正确配置以部署您的函数应用。确保正在部署所有文件都部署到正确的位置。
我在我的环境中重现了相同的内容,并且它运行正常,没有任何问题,如下所示:
DLL 文件:
而且我还观察到您在应用程序中使用的包 Microsoft.Azure.WebJobs.Script
是 deprecated .
关于c# - 为什么 Azure Functions 运行时找不到我的 DLL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75945599/
例如,我有一个父类Author: class Author { String name static hasMany = [ fiction: Book,
代码如下: dojo.query(subNav.navClass).forEach(function(node, index, arr){ if(dojo.style(node, 'd
我有一个带有 Id 和姓名的学生表和一个带有 Id 和 friend Id 的 Friends 表。我想加入这两个表并找到学生的 friend 。 例如,Ashley 的 friend 是 Saman
我通过互联网浏览,但仍未找到问题的答案。应该很容易: class Parent { String name Child child } 当我有一个 child 对象时,如何获得它的 paren
我正在尝试创建一个以 Firebase 作为我的后端的社交应用。现在我正面临如何(在哪里?)找到 friend 功能的问题。 我有每个用户的邮件地址。 我可以访问用户的电话也预订。 在传统的后端中,我
我主要想澄清以下几点: 1。有人告诉我,在 iOS 5 及以下版本中,如果您使用 Game Center 设置多人游戏,则“查找 Facebook 好友”(如与好友争夺战)的功能不是内置的,因此您需要
关于redis docker镜像ENTRYPOINT脚本 docker-entrypoint.sh : #!/bin/sh set -e # first arg is `-f` or `--some-
我是一名优秀的程序员,十分优秀!