Azure 自动化清除 CDN 端点

标签 azure events automation azure-blob-storage

我正在尝试放置一个 Azure 自动化 Runbook,目的是在对 Blob 存储进行更改时清除所有缓存。到目前为止,如果我从 azure 门户上传 1 个文件,效果很好。但是,如果我尝试上传多个文件,其中一些文件就会失败并出现以下错误。

We can only accept 100 paths for purging concurrently. Please try again in a few minutes.

这是我在自动化 Runbook 流程中使用的代码:

param (
    [Parameter (Mandatory = $false)]
    [object] $WebHookData
)

## Authentication ##

# Runbook must authenticate to purge content
# Connect to Azure with RunAs account
$conn = Get-AutomationConnection -Name "AzureRunAsConnection"

# Connect to Azure Automation
$null = Add-AzAccount `
  -ServicePrincipal `
  -TenantId $conn.TenantId `
  -ApplicationId $conn.ApplicationId `
-CertificateThumbprint $conn.CertificateThumbprint


## declarations ##

# Update parameters below
# CDN Profile name
$profileName = "<CDNProfileName>"
# CND Resource Group
$resourceGroup = "<Resource-Group>"
# CDN Endpoint Name
$endPointName = "<EndPointName>"

# Set Error Action Default
$errorDefault = $ErrorActionPreference

## Execution ##

# Convert Webhook Body to json
try {
    $requestBody = $WebHookData.requestBody | ConvertFrom-json -ErrorAction 'stop'
}
catch {
    $ErrorMessage = $_.Exception.message
    write-error ('Error converting Webhook body to json ' + $ErrorMessage)
    Break
}
# Convert requestbody to file path

try {
    $ErrorActionPreference = 'stop'
    $filePath = $requestBody.data.url -replace "https://<storageaccountname>.blob.core.windows.net",""
}
catch {
    $ErrorMessage = $_.Exception.message
    write-error ('Error converting file path ' + $ErrorMessage)
    Break
}
finally {
    $ErrorActionPreference = $errorDefault
}
# Run the purge command against the file
try {
    Unpublish-AzCdnEndpointContent -ErrorAction 'Stop' -ProfileName $profileName -ResourceGroupName $resourceGroup `
    -EndpointName $endPointName -PurgeContent '/*'
}
catch {
    $ErrorMessage = $_.Exception.message
    write-error ('Error purging content from CDN ' + $ErrorMessage)
    Break
}

任何人都可以帮助解决这个问题,或者向我澄清清除因该错误而失败的原因(“BadRequest”)

非常感谢您的帮助

最佳答案

从底部the article about CDN purge enpoint :

Purge requests take approximately 10 minutes to process with Azure CDN from Microsoft, approximately 2 minutes with Azure CDN from Verizon (standard and premium), and approximately 10 seconds with Azure CDN from Akamai. Azure CDN has a limit of 100 concurrent purge requests at any given time at the profile level.

在配置文件级别的任何给定时间,并发清除请求的限制为 100 个。

关于Azure 自动化清除 CDN 端点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66063708/

相关文章:

azure 函数代理在 Linux 系统上不起作用

macos - 自动化 Git 和 SSH 工作流程

php - 从另一个站点自动登录到 wordpress 仪表板

selenium-webdriver - 使用 Selenium webdriver 实现 Metamask 自动化

c# - Azure 字符串未被识别为有效的日期时间

azure - 使用 ARM 模板从私有(private) Github 存储库部署网站

azure - 如何使 Azure 应用服务 Web 应用从我的 repoRoot/src/views/folder 作为网站根目录为我的网站提供服务?

javascript - event.preventDefault() 不会避免打开链接

c# - 在 C# 中,事件处理程序参数是逆变的吗?

events - Console.ReadLine() 传递给 C# 事件