AzureFunctionApp无法加载System.IO.Pipelines连接到Redis

在 VS2019 (16.8.3) 中创建了一个新的 Function App,HTTP 触发器以连接到 Azure Redis 缓存。从 nuget 添加了 StackExchange.Redis 2.2.4。

local.settings.json 包含 RedisConnectionFromKeyVault 的键/值和来自门户访问键的主连接字符串。

{
    "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "RedisConnectionFromKeyVault": "<<SNIP>>.redis.cache.windows.net:6380,password=<<SNIP>>,ssl=True,abortConnect=False"
  }
}

将以下行添加到默认功能代码中:

var connectionRedis = Environment.GetEnvironmentVariable("RedisConnectionFromKeyVault", EnvironmentVariableTarget.Process);
var cache = ConnectionMultiplexer.Connect(connectionRedis).GetDatabase();

当我在本地运行并触发函数应用程序时,我在 ConnectionMultiplexer.Connect 调用中收到以下异常。

System.Private.CoreLib: Exception while executing function: Function1. StackExchange.Redis: Could not load file or assembly 'System.IO.Pipelines, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
   at StackExchange.Redis.ConnectionMultiplexer.Connect(ConfigurationOptions configuration, TextWriter log) in /_/src/StackExchange.Redis/ConnectionMultiplexer.cs:line 1032
   at StackExchange.Redis.ConnectionMultiplexer.Connect(String configuration, TextWriter log) in /_/src/StackExchange.Redis/ConnectionMultiplexer.cs:line 1015
   at FunctionApp1.Function1.<Run>d__0.MoveNext() in E:GitReposFunctionApp1FunctionApp1Function1.cs:line 26

在控制台应用程序中尝试过类似的代码,它工作正常吗?

我错过了什么?为什么函数应用程序认为它找不到 System.IO.Pipelines 程序集?

即使我明确包含 System.IO.Piplelines nuget 包,它也找不到它?

回答

看起来这是 Azure Functions 的一个已知问题,如https://github.com/Azure/azure-functions-host/issues/5894 所述

StackExchange.Redis 提出了问题
https://github.com/StackExchange/StackExchange.Redis/issues/1637

https://github.com/StackExchange/StackExchange.Redis/issues/1655

可以通过将 _FunctionsSkipCleanOutput 元素如下添加到 csproj 来解决问题

<PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <AzureFunctionsVersion>v3</AzureFunctionsVersion>
    <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> <!-- *** this line is new ** -->
</PropertyGroup>


以上是AzureFunctionApp无法加载System.IO.Pipelines连接到Redis的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>