Dependencies Azure密钥Vault 401身份验证错误

Dependencies Azure密钥Vault 401身份验证错误,dependencies,azure-application-insights,http-status-code-401,azure-keyvault,Dependencies,Azure Application Insights,Http Status Code 401,Azure Keyvault,我正在为我的azure无状态服务结构应用程序从密钥保管库获取机密值,并获得401个依赖项错误(如果我通过connected application insight进行检查),在100个密钥保管库机密中,只有2个密钥保管库机密。 下面给出的是通过application insight显示的一个关键vault机密的依赖项错误的屏幕截图 这里是请求路径 下面给出了我获取保险库密钥的代码- public async Task<string> GetSecretAsync(strin

我正在为我的azure无状态服务结构应用程序从密钥保管库获取机密值,并获得401个依赖项错误(如果我通过connected application insight进行检查),在100个密钥保管库机密中,只有2个密钥保管库机密。 下面给出的是通过application insight显示的一个关键vault机密的依赖项错误的屏幕截图

这里是请求路径

下面给出了我获取保险库密钥的代码-

    public async Task<string> GetSecretAsync(string secretName, string clientId, string appKey, string vaultAddress)
            {
                string secretValue = string.Empty;
                if (string.IsNullOrEmpty(secretName))
                    throw new ArgumentNullException(nameof(secretName));

                if (string.IsNullOrEmpty(clientId))
                    throw new ArgumentNullException(nameof(clientId));

                if (string.IsNullOrEmpty(appKey))
                    throw new ArgumentNullException(nameof(appKey));

                if (string.IsNullOrEmpty(vaultAddress))
                    throw new ArgumentNullException(nameof(vaultAddress));

                var secretIdentifier = vaultAddress + "secrets/" + secretName;
                string cacheKey = secretIdentifier + clientId + appKey;

                secretValue = await GetSecretValue(clientId, appKey, secretIdentifier, cacheKey);

                return secretValue;
            }

private async Task<string> GetSecretValue(string clientId, string appKey, string secretIdentifier, string cacheKey)
        {
            IAdAuthentication authToken = new AdAuthentication
            {
                ClientId = clientId,
                AppKey = appKey
            };
            KeyVaultClient keyVaultClient = new KeyVaultClient(authToken.GetAuthenticationTokenAsync);

            // Get secret from the KeyVault.

            SecretBundle secret = null;

            Task tskGetSecret = Task.Run(async () =>
            {
                        //Here I am getting exception with response
                        secret = await keyVaultClient.GetSecretAsync(secretIdentifier).ConfigureAwait(false);
            });
            await Task.WhenAny(tskGetSecret);

            if (tskGetSecret.IsFaulted || tskGetSecret.IsCanceled)
            {
                secret = null;
            }

            string secretValue = string.Empty;
            if (secret != null && secret.Value != null)
            {
                secretValue = secret.Value.Trim();
            }

            return secretValue;
        }

我将结束此问题,因为通过进一步调试,我发现该问题不是间歇性的,也与特定的密钥库机密无关。获取应用程序的第一个密钥vault secret的值时,始终会出现问题。我将结束此问题,并打开一个包含适当详细信息的文档

at Microsoft.Rest.RetryDelegatingHandler.<>c__DisplayClass11_0.<<SendAsync>b__1>d.MoveNext()