azure - 无法引用 Azure Functions 中的 Polly 或其他包

标签 azure azure-functions serverless

我已在版本 4 Azure Function 应用程序中尝试了以下操作

#r "Polly"
using System;
using System.Threading.Tasks;

和/或

using System;
using System.Threading.Tasks;
using Polly;

但在这两种情况下,它都表示未找到 Polly。从文档中,我尝试在函数应用程序的 json 文件中添加框架 46 引用,但这不起作用。导入依赖项的最佳方法是什么?

最佳答案

在 Azure Functions v4 中安装 Polly 依赖项注入(inject)的解决方法之一是:

  • 打开 Azure Functions V4 项目。
  • 右键单击项目 > 单击管理 Nuget 包
  • 为您的项目安装所需的扩展,例如

enter image description here

开始在函数类中编写与 Polly 策略扩展相关的代码,例如:

enter image description here

在Azure Functions中添加依赖注入(inject)的方法是:

  1. 通过右键单击项目,使用 NuGet 包管理器安装依赖项注入(inject)。 或者
  2. 使用 NuGet official Site 中提供的 DotNet CLI 或 Package Manager 命令.

关于azure - 无法引用 Azure Functions 中的 Polly 或其他包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70883616/

相关文章:

azure - 为 Azure 网站配置 web.config

c# - 如何使用azure函数应用程序读取azure blob中的内容

具有 Cosmos DB 绑定(bind)的 Azure Functions - 作为路由参数传递时 ORDER BY 不起作用

node.js - 无服务器部署 : Recoverable error occurred (write ECONNRESET), 休眠约 5 秒。尝试 4 个中的 1 个

javascript - 当使用 aws amplify on react 调用 api 网关时,我该如何获取状态码?

Azure 仅允许 Verisign 证书

python - 如何使用 Python 为 Azure 应用程序网关的监听器添加新证书

c# - Azure 存储分析日志解析错误

c# - Microsoft.Extensions.DependencyInjection 向构造函数注入(inject) null,而不是在服务丢失时抛出异常

amazon-web-services - 如何使用无服务器部署没有身份源的 API 网关自定义授权方?