Azure KeyVault访问中的明显延迟 [英] Apparent delay in Azure KeyVault access

查看:55
本文介绍了Azure KeyVault访问中的明显延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个基于Azure的ASP.NET Web服务,可以访问Azure KeyVault.我们看到了两个实例,其中第一次尝试将方法挂起",然后在大约一分钟后起作用.

We have an Azure-based ASP.NET Web Service that accesses an Azure KeyVault. We are seeing two instances in which a method "hangs" on a first try, and then works a minute or so later.

在这两种情况下,都会发生KeyVault访问.在这两种情况下,当我们开始在这些方法中使用KeyVault时,问题就都开始了.

In both instances, a KeyVault access occurs. In both instances the problem started when we started using the KeyVault in these methods.

我们在第一个实例中进行了非常仔细的日志记录,并且在我们的代码中看不到其他任何可能导致挂起的信息. KeyVault访问是主要的可疑对象.

We have done very careful logging in the first instance, and cannot see anything else in our code that could cause the hang. The KeyVault access is the primary suspect.

此外,如果我们从本地服务器(从Visual Studio)运行应用程序,则KeyVault访问可以在首次尝试"下正常运行.仅当它在Azure上的生产环境中运行时,才产生挂起"错误,并且仅在该首次尝试"中产生.

In addition, if we run the app from our local servers (from Visual Studio), the KeyVault access works fine on the "first try". It only produces the "hang" error when it runs in production on Azure, and only on that "first try".

挂起"是指在一个实例中,它是由外部API触发的,至少需要60秒(我们可以知道这是因为外部API超时).一个页面请求,可能要经过几分钟,页面才会旋转,这时我们认为数据库请求或其他请求已超时.

By "hang" I mean that in one instance, which is triggered by an external API, it takes at least 60 seconds (we can tell that because the external API times out.) In the other instance, which is triggered by a page request, several minutes can pass and the page just spins, at which point we assume the DB request or something else has timed out.

当我说大约一分钟后"时,这与我们设定的重试时间一样快.

When I say "a minute or so later", that's as fast as we have timed the retry.

是否存在某种问题或功能,需要对KeyVault进行预热"才能使其首次尝试工作?

Is there some kind of issue or function where the KeyVault needs to be "warmed up" before it works on the first try?

更新:我正在更仔细地查看代码,并且至少看到了几个地方,我们可以在其中插入更多日志记录,以更准确地了解发生故障的位置.我要这样做,然后我将在这里报告.

Update: I'm looking at the code more carefully, and I see at least a couple of places where we can insert still more logging to get a more exact picture of where the failure occurs. I'm going to do that, and then I'll report back here.

更新:请参见下面的答案-主要的新手错误,已得到纠正.

Update: See answer below - major newbie error, has been corrected.

推荐答案

找到了问题和解决方法.

Found the problem, and the solution.

由于存在数秒的延迟,因此需要从异步任务中调用Key Vault访问.

Key Vault access needs to be called from an async task, because there is a multi-second delay.

private async Task<string> GetKeyVaultSecretValue(varSecretParms) {

我不了解底层技术,但是,显然,如果调用来自标准代码序列,则服务器不喜欢等待,因此线程被放弃/暂停.

I don't understand the underlying technology, however, apparently, if the call is from within a standard code sequence, the server doesn't like to wait, and so the thread is abandoned/halts.

这篇关于Azure KeyVault访问中的明显延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆