gpt4 book ai didi

.net - Azure Blob 存储成功请求在 Application Insights 中显示为失败请求

转载 作者:行者123 更新时间:2023-12-03 01:07:04 25 4
gpt4 key购买 nike

以下容器存在,因此返回失败的请求代码 409

var container = blobClient.GetContainerReference("my-container");
container.CreateIfNotExists();

我会在创建之前进行检查以确保 Blob 引用不存在。这将返回带有 bool 值的 404 响应代码。

if(container.GetBlockBlobReference("this-file-could-exist").Exists()) {

在第一个示例中,我希望容器存在,在第二个示例中,我希望文件不存在。但在这两种情况下我都会进行检查以确保。

代码一切正常。问题是 Application Insights 会提醒我大量失败的请求。虽然这些并不是真正失败的请求,但实际上是成功的请求,因为这就是我所期望的。

解决这个问题的最佳方法是什么?我可以使 azure 返回 200 成功吗,还是需要在 Application Insights 中以某种方式忽略这些。

最佳答案

如果您使用的是最新版本的存储客户端库,当您执行CloudBlobContainer.CreateIfNotExists()方法时,它实际上执行的是创建操作,因此有时服务器响应会是409。

8.2.0版本源代码

enter image description here如果可能,您可以尝试将存储客户端库版本降级到 v7.2.1。

7.2.1版本源代码

enter image description here

我在我的关于操作中执行以下代码,我可以在application Insight中发现结果代码200

CloudBlobContainer container = blobClient.GetContainerReference("mycontainer");

container.CreateIfNotExists();

enter image description here

关于.net - Azure Blob 存储成功请求在 Application Insights 中显示为失败请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45227439/

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