我已经按照官方文档开发了代码,但它没有工作。我必须将密钥存储在保管库中。
当我进行调试时,它只是在上述步骤停止并且不会进一步。我也试过没有调试。它是一样的。是否还有其他设置/权限。
private void EncryptFields()
{
string publicKey = GetAzureVaultSecret().Result;
}
public static async Task<string> GetAzureVaultSecret()
{
var kv = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(GetAzureVaultAccessToken));
var secret = await kv.GetSecretAsync(GlobalConstants.AzureVaultURLSecretURI);
return secret.Value;
}
public static async Task<string> GetAzureVaultAccessToken(string authority, string resource, string scope)
{
var authContext = new AuthenticationContext(authority);
ClientCredential clientCred = new ClientCredential(GlobalConstants.AzureVaultClientId, GlobalConstants.AzureVaultClientSecret);
//STOPS AT THE BELOW STEP AND NOTHING HAPPENS
AuthenticationResult result = await authContext.AcquireTokenAsync(resource, clientCred);
if (result == null)
{
throw new InvalidOperationException("Failed to obtain the token");
}
return result.AccessToken;
}
日志:
ManagedPoolThread#3 00:23:46 WARN内存使用量超过了 MemoryMonitor阈值。 ManagedPoolThread#3 00:23:46 WARN Memory 用法:3,21,95,91,168 ManagedPoolThread#3 00:23:46 WARN Number of 由于日志条目之间的最短时间而抑制了日志:10