Reputation: 1569
I am trying to put in place a Azure Automation Runbook with the intent to purge all the cache when I change is made to a blob storage. So far, if I upload from azure portal 1 file that works just fine. But if I try to upload multiple file, some of them they just fail with the following error.
We can only accept 100 paths for purging concurrently. Please try again in a few minutes.
Here is the code I am using in the automation Runbook process:
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
}
Anyone can help with this or clarify to me what could be the reason why the Purge is failing with that error ("BadRequest")
Thank you so much for your help
Upvotes: 1
Views: 924
Reputation: 28234
From the bottom of 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.
There is a limit of 100 concurrent purge requests at any given time at the profile level.
Upvotes: 2