我正在尝试从旧的“ Microsoft.Azure.KeyValut”程序包迁移到新的“ Azure.Security.KeyVault.Secrets”
我可以列出所有秘密,但是当我尝试获取我得到的秘密值和400 Http状态错误时:
Azure.RequestFailedException:'服务请求失败。状态:400 (错误请求)
内容:{“错误”:{“代码”:“ BadParameter”,“消息”:“方法GET确实 不允许执行操作'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);
}
}
答案 0 :(得分:0)
我尝试使用您问题中的代码,它返回的机密没有错误。请检查您的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);
}
访问策略: