azureazure-devopsazure-web-app-serviceazure-pipelinesazure-cdn

Azure purge script from Azure DevOps


We are deploying web app to Azure cdn, but every time we need to wait pretty much time before app is updated. So we found out that there is a 'purge' button, which seems to work. After purge we have to wait like 5 min.

Now we want to run this every time app is released so we added a task to vsts with following script :

az cdn endpoint purge --resource-group $1 --profile-name $3 --name $4 --content-paths /*

with arguments: $(ResourceGroup) $(StorageAccountName) $(ProfileName) $(EndpointName)

but this does not work every time, seems like sometimes it works and after 5 min app is updated but sometimes we have to wait like 30 min.


Solution

  • Add the --no-wait parameter to avoid waiting for the operation to finish.

    az cdn endpoint purge --resource-group $1 --profile-name $3 --name $4 --no-wait --content-paths /*
    

    --no-wait

    Do not wait for the long-running operation to finish.

    https://learn.microsoft.com/en-us/cli/azure/cdn/endpoint?view=azure-cli-latest#optional-parameters