c# - Azure Functions 运行时无法访问

标签 c# .net azure azure-devops azure-functions

我的 Azure 函数返回错误:Azure Functions 运行时无法访问

    System.Reflection.ReflectionTypeLoadException : Unable to load one or more of the requested types.
Method 'LogFunctionStarted' in type 'WebJobs.Host.Storage.Logging.PersistentQueueLogger' from assembly 'Microsoft.Azure.WebJobs.Host.Storage, Version=4.0.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.

  at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)

  at System.Reflection.RuntimeModule.GetTypes()

  at System.Reflection.Assembly.GetTypes()

  at Mapster.TypeAdapterConfig.<>c.b__87_0(Assembly assembly)

  at System.Linq.Enumerable.SelectArrayIterator`2.MoveNext()

  at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.ToList()

  at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)

  at Mapster.TypeAdapterConfig.Scan(Assembly[] assemblies)

  at DTSQuickHit.Functions.Startup.Configure(IFunctionsHostBuilder builder) at E:\buildagents\Agent03\_work\37\s\DTSQuickHit.Functions\Startup.cs : 32

我的启动:

var environmentName = Environment.GetEnvironmentVariable("AZURE_FUNCTIONS_ENVIRONMENT");
var basePath = IsDevelopmentEnvironment(environmentName)
    ? environmentName
    : $"{Environment.GetEnvironmentVariable("HOME")}\\site\\wwwroot";

var config = new ConfigurationBuilder()
    .SetBasePath(basePath)
    .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
    .AddEnvironmentVariables()
    .Build();

Microsoft.Azure.WebJobs.Host.Storage 甚至不在我的项目文件中,所以我不明白这个问题。

我的项目文件:

  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="4.3.0" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.1.0" />
  </ItemGroup>

你能帮我解决这个问题吗?

最佳答案

如果与函数应用中的存储帐户设置相关的任何解决方案不起作用,原因可能如下。

您的函数工作线程运行时无法启动,现在因为 Azure 在后台做了一些奇特的事情来尽快重新部署资源,它以某种方式将您的函数名称绑定(bind)到工作线程,因此即使您重新部署,它也会继续失败。

解决此问题的方法是扩展底层应用服务计划,以强制功能站点在新工作人员上启动。扩展完成后,工作线程运行时将再次可用。

我希望这有帮助:)

关于c# - Azure Functions 运行时无法访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72377617/

相关文章:

c# - 如何修复以下代码示例的 Fortify 扫描报告中的 ‘Path Manipulation’ 问题

c# - 向机器人框架应用程序添加按钮

c# - 从 WinForms 窗体显示 WPF 窗口绝对安全吗?

c# - IFoo foo = new Foo() 和 Foo foo = new Foo() 有什么区别

c# - 使用 IIS 的基本身份验证在 WCF 服务中获取用户名

azure - 指定Azure容器服务的Kubernetes版本

c# - dotNetRDF 中的 sparql 查询

c# - 文本框控件更新后 Bindingsource 将不会更新

c# - 使用 BlobUploadOptions 时如何在 Azure BlobClient 中设置覆盖

powershell - Azure 自动化 Powershell 脚本 - 它们会像 SQL 代理作业一样线性运行吗?