How to purge CDN files in an Azure Akamai profile

Author avatar

Steven Shaw

    Using Content Delivery Networks (CDN) can help boost the performance of websites. They work by having distributed servers around the globe that serve your static content (such as images, javascript or CSS) to the end user from the server that is nearest to them.

    CDN systems also can cache assets – they keep a copy of your images and don’t need to fetch them from the original source. This can raise challenges when you have assets that become out of date (for example, a banner with an offer), but you can still use a CDN and set it for a given timeframe, such as a one-week cache.

    We had this challenge recently on a client project, for which we had some images in our Microsoft Azure CDN.

    We were using the Akamai Profile – Akamai are a leader in the CDN world and were the provider of choice as they also offer new features such as HTTP2.

    We had a lot of images (Over 20,000) that needed to be purged. However it seems that in the standard Azure portal, there isn’t a “purge all” option for Akamai and wildcards (/*) didn’t seem to be supported or honoured when we were using it.

    After a lot of Googling and no joy, I contacted Azure support, who pointed me in the direction of a PowerShell command that would do the trick. To save you some time, I thought I would share it here!

    Some notes on the variables:

    • the endpoint needs to the base name of the endpoint, not the full URL (eg. “my-cdn” rather than “”)
    • You can wild card through the PowerShell interface, so using “/my-images/*” will purge everything under the my-images folder
    1. Open Powershell in an elevated permission mode such as Administrator:

    Connect to your Azure account using the following command:

    1. Enter the following variables with your correct settings:

    $ResourceGroupName = “YourResourceGroupName”
    $ProfileName = “YourCDNProfile”
    $EndpointName = “YourCDNEndpoint”
    $PurgeFolder = “ThePathOnYourCDNYouWishToPurge”

    1. Run the following command to purge your content:

    Unpublish-AzureRmCdnEndpointContent -ResourceGroupName $ResourceGroupName -ProfileName $ProfileName -EndpointName $EndpointName -PurgeContent $PurgeFolder

    Happy purging!



    +44 (0) 1225 480 480

    20 Manvers Street


    BA1 1JW


    +44 (0) 113 260 4010

    2nd floor, 2180 Century Way,

    Thorpe Park,

    Leeds, LS15 8ZB.


    +44 (0) 113 260 4010

    5th Floor, Cordy House,

    91 Curtain Road

    London, EC2A 3BS

    Part of the St. Ives Group

    • By pressing submit you consent for Edit to contact you via your email or telephone number for purposes relevant to your request for our goods or services. Your contact details, including your name, company, telephone number and email address will be used by Edit. By contacting you are agreeing to Edit’s Privacy Policy. If you have any questions, please ensure you review this section before submitting.

    • This field is for validation purposes and should be left unchanged.

    © 2018 Edit. St Ives Group. Company reg. no. 3624881, All rights reserved. VAT Registered GB 927458295 Privacy Policy | Terms & Conditions | Cookie Policy