azure函数defaustazurecrecrecrecrecreCredential方法找不到azure.core.tokenrequestcontext
我正在尝试从Azure函数c#脚本中的Azure密钥库中读取秘密,但是我面临的错误
我已经创建了一个function.proj文件,其中有下面的内容,
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.6.0" />
<PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.3.0" />
</ItemGroup>
</Project>
我启用了从我的功能应用程序创建了一个对象ID号。 选择秘密权限的获取和列表
然后复制此数字,并将其添加到我的密钥保险库访问策略中,然后在我尝试以下代码时
string keyVaultUri = "https://my-vault-test.vault.azure.net/";
var client = new SecretClient(new Uri(keyVaultUri), new DefaultAzureCredential());
var secret = client.GetSecret("first-secret");
:错误:
2022-05-04T16:41:51.383 [错误]执行'functions.myfff'(失败, id =数字...,持续时间= 574ms)未找到方法:'void azure.core.core.tokenrequestcontext..ctor(system.String [],System.String, System.String,System.String)'。
I'm trying to read secrets from a Azure Key Vault in my azure function c# script, but I'm facing an error
I already create a function.proj file with content below
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.6.0" />
<PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.3.0" />
</ItemGroup>
</Project>
I enabled the System assigned from my Function App and it created a Object Id number.
Then copied this number and added it to my Key Vault Access policies at Select principal option and choose Get and List for Secret Permissions
When I try this code below:
string keyVaultUri = "https://my-vault-test.vault.azure.net/";
var client = new SecretClient(new Uri(keyVaultUri), new DefaultAzureCredential());
var secret = client.GetSecret("first-secret");
error:
2022-05-04T16:41:51.383 [Error] Executed 'Functions.myFff' (Failed,
Id=number..., Duration=574ms) Method not found: 'Void
Azure.Core.TokenRequestContext..ctor(System.String[], System.String,
System.String, System.String)'.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我更改了包装的版本,它运行良好...
1.5.0 for Azure.Identity
4.2.0 for Azure.security.keyvault.secrets
I changed the versions of the packages and it worked well...
1.5.0 for Azure.Identity
4.2.0 for Azure.Security.KeyVault.Secrets