Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
896 views
in Technique[技术] by (71.8m points)

events - Azure Automation Purge CDN Endpoint

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

question from:https://stackoverflow.com/questions/66063708/azure-automation-purge-cdn-endpoint

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...