gpt4 book ai didi

azure - SecretClient.GetSecret总是抛出400错误

转载 作者:行者123 更新时间:2023-12-02 07:21:53 31 4
gpt4 key购买 nike

我正在尝试从旧的“Microsoft.Azure.KeyValut”包迁移到新的“Azure.Security.KeyVault.Secrets”

我可以列出我所有的 secret ,但是当我尝试获取 secret 值时,我得到了 400 Http 状态错误:

Azure.RequestFailedException: 'Service request failed. Status: 400(Bad Request)

Content: {"error":{"code":"BadParameter","message":"Method GET doesnot allow operation 'ChilkatUnlock'"}}

internal SecretClient GetClient() {
var client = new SecretClient(new Uri(cKvUri), new ClientSecretCredential(cAzureTennantId, cAzureClientId, cAzureClientSecret));
return client;
}

internal void ListSecrets() {
var client = GetClient();


Pageable<SecretProperties> allSecrets = client.GetPropertiesOfSecrets();

foreach (SecretProperties secretProperties in allSecrets) {
Console.WriteLine(secretProperties.Name);
var val = client.GetSecret(secretProperties.Name);
Console.WriteLine(val.Value);
}
}

最佳答案

我尝试使用您问题中的代码,它返回 secret ,没有错误。请检查您的 ChilkatUnlock 方法。最后分享一下访问策略。

var client = new SecretClient(new Uri(cKvUri), new ClientSecretCredential(cAzureTennantId, cAzureClientId, cAzureClientSecret));

Pageable<SecretProperties> allSecrets = client.GetPropertiesOfSecrets();

foreach (SecretProperties secretProperties in allSecrets)
{
Console.WriteLine("Secret: " + secretProperties.Name);
var val = client.GetSecret(secretProperties.Name);
Console.WriteLine("Value: " + val.Value);
}

enter image description here

访问策略:

enter image description here

关于azure - SecretClient.GetSecret总是抛出400错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64643396/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com