gpt4 book ai didi

azure - WebJobs SDK 在 AzureWebJobsDashboard 连接中创建的 blob 的清理机制是什么?

转载 作者:行者123 更新时间:2023-12-02 11:51:28 26 4
gpt4 key购买 nike

Azure WebJob SDK 使用 AzureWebJobsStorageAzureWebJobsDashboard 应用设置中定义的存储连接字符串进行日志记录和仪表板。

WebJob SDK 在 AzureWebJobsStorage 中创建以下 Blob 容器:

  • azure-webjobs-hosts

WebJob SDK 在 AzureWebJobsDashboard 中创建以下 Blob 容器

  • azure-jobs-host-output
  • azure-webjobs-hosts

当 WebJob 运行时,会在上述 Blob 容器中创建许多 Blob。如果没有清理机制,容器可能会膨胀或饱和。

上述 blob 容器的清理机制是什么?

更新

下面的答案是一个解决方法。目前,没有内置机制来清理 WebJobs 日志。随着作业长期运行,日志可能会堆积得相当大。开发人员必须自行创建清理机制。 Azure Functions 是实现此类清理过程的好方法。下面的答案提供了一个示例。

最佳答案

What is the clean up mechanism for the blobs that WebJobs SDK creates in the AzureWebJobsDashboard connection?

我还没找到办法。 GitHub 上有一个与此主题相关的未解决问题,但尚未关闭。

No way to set webjob logging retention policy

在 GitHub 上的类似问题中,我们发现 Azure WebJob SDK 更改了将日志保存到 Azure 表存储的多个表的方式。我们可以轻松地每月删除该表。对于写入 Azure Blob 存储的日志,到目前为止还没有按月分组。

enter image description here

WebJobs.Logging needs to support log purge / retention policies

要删除旧的 WebJob 日志,我建议您创建一个时间触发的 WebJob 来删除您想要的日志。

Is there any AzureFunction code sample shows how to do the blob cleanup?

以下代码供您引用。

// Parse the connection string and return a reference to the storage account.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageConnectionString);

// Create the table client.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

// Retrieve a reference to a container.
var container = blobClient.GetContainerReference("azure-webjobs-hosts");
// Query out all the blobs which created after 30 days
var blobs = container.GetDirectoryReference("output-logs").ListBlobs().OfType<CloudBlob>()
.Where(b => b.Properties.LastModified < new DateTimeOffset(DateTime.Now.AddDays(-30)));
// Delete these blobs
foreach (var item in blobs)
{
item.DeleteIfExists();
}

关于azure - WebJobs SDK 在 AzureWebJobsDashboard 连接中创建的 blob 的清理机制是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43259345/

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