Azure 自动化清除 CDN 端点

Azure Automation Purge CDN Endpoint

我正在尝试放置一个 Azure Automation Runbook,目的是在我对 blob 存储进行更改时清除所有缓存。到目前为止,如果我从 azure portal 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 个并发清除请求的限制。