【问题标题】:Azure Blob Container Alert if specific container folder is not updated in 24hrs如果特定容器文件夹未在 24 小时内更新,Azure Blob 容器警报
【发布时间】:2020-04-28 09:31:48
【问题描述】:

如果 blob 容器中的特定文件夹未在 24 小时内更新,我想找到一种发送警报的方法。我尝试通过门户设置警报,但我似乎只能根据整个 blob 容器的 Ingress 找到指标警报。有没有办法在容器内的文件夹上指定 Ingress?

我想通过门户中的“警报”选项卡执行此操作,但如果我不得不求助于编写代码,我也可以走这条路。

这是我迄今为止尝试过的图片:

【问题讨论】:

  • 您好,您的问题解决了吗?
  • 将您的答案标记为答案,我们很可能会采用类似的方法。

标签: azure azure-blob-storage azure-container-service azure-alerts


【解决方案1】:

似乎没有现成的解决方案来监视 Azure 警报中 Azure 存储容器中的文件夹。

根据您的要求,如果文件夹中超过 24 小时没有修改,您希望发送警报。所以我们可以在这个文件夹中获取最新的修改时间并与当前时间进行比较。您可以在下面尝试这个 powershell:

$storageAccount = "<your storage account>"
$resourceGroup = "<your resource group name>"
$containerName = "<container name>"
$folderName = "<folder name>"
$storage = Get-AzStorageAccount -name $storageAccount -ResourceGroupName $resourceGroup

$lastModifyTimeInFolder = (Get-AzStorageBlob -Prefix $folderName -Container $containerName -Context $storage.Context | Sort-Object -Property LastModified -Descending)[0].LastModified
$now = Get-Date


if($lastModifyTimeInFolder.CompareTo($now.AddHours(-24)) -ge 0){
echo "modified within 24hs"
}else {
#if last $lastModifyTimeInFolder less than current time minus 24 hours, you can trigger your own alert based on your logic here 
echo "modified exceeded 24hs "
}

您可以在 Azure 自动化中创建 runbooka scheduled task,即每 30 分钟运行一次此脚本以实现您的要求。

希望对你有帮助。

【讨论】:

    猜你喜欢
    • 2018-01-10
    • 2021-08-06
    • 2018-04-13
    • 1970-01-01
    • 1970-01-01
    • 2018-07-08
    • 2022-01-12
    • 2016-04-16
    • 2021-09-11
    相关资源
    最近更新 更多