小编Ene*_*Boy的帖子

使用 DefaultAzureCredential 和 HttpClient 的 Azure Function 到 Azure Function 请求

我需要从另一个 Azure 函数调用 Http Azure 函数。

目前,我调用 Azure Key Vault 来获取目标函数的密钥,并将其放入此处记录的 URL 中:https: //learn.microsoft.com/en-us/azure/azure-functions/functions-bindings- http-webhook-trigger?tabs=csharp#api-key-authorization

但是,我想开始使用托管身份和 DefaultAzureCredential,但我无法找到如何将 DefaultAzureCredential 与 HttpClient 或类似工具一起使用。

如何使用 DefaultAzureCredential 和 HttpClient 从另一个函数调用一个函数?

c# httpclient azure-functions azure-managed-identity

3
推荐指数
1
解决办法
4834
查看次数

依赖注入 - 字典 C# 中的接口

我想将 a 注入IDictionary{key, interface}构造函数中,但我不知道如何在构造函数中设置它program.cs

我可以启动接口,也可以启动接口IDictionary,但我不知道如何组合它们。

任何建议都会被采纳。

附加背景:

所以我需要注入我的服务,例如

我需要注入服务,例如,

s.AddTransient<IFooService, AFooService>();
s.AddTransient<IFooService, BFooService>();
Run Code Online (Sandbox Code Playgroud)

但在我想要的构造函数中

public MyClass(IDictionary<string, IFooService> fooServices)
Run Code Online (Sandbox Code Playgroud)

c# dependency-injection interface idictionary .net-6.0

0
推荐指数
1
解决办法
1298
查看次数