locked
Issue with Purging Content from Azure CDN using API as a service RRS feed

  • Question

  • While developing a service that would automate removal of content from the CDN Akamai service, received the following error (Note: internal data collected along with the Exception information):

    OnTimer AzureCDN.Error: 
    PurgeCdnEndpoint:
    (EndpointName=CDNEndPAutoSync, ProfileName=CDNProfAutoSync, ResourceGroupName=CDNResGAutoSync, ContPaths=/Images/Picture1.jpg ,/Images/GO_Transit_logo.png ,/Images/GrillMaster1.jpg) 

     Microsoft.Azure.Management.Cdn.Models.ErrorResponseException: Operation returned an invalid status code 'NotFound'
       at Microsoft.Azure.Management.Cdn.EndpointsOperations.<BeginPurgeContentWithHttpMessagesAsync>d__21.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Microsoft.Azure.Management.Cdn.EndpointsOperations.<PurgeContentWithHttpMessagesAsync>d__12.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Microsoft.Azure.Management.Cdn.EndpointsOperationsExtensions.<PurgeContentAsync>d__15.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Microsoft.Azure.Management.Cdn.EndpointsOperationsExtensions.PurgeContent(IEndpointsOperations operations, String resourceGroupName, String profileName, String endpointName, IList`1 contentPaths)
       at AzureCDNManageService.AzureCDN.PurgeCdnEndpoint(CdnManagementClient cdn, List`1 contPaths)

    The executing code section is

            /// <summary>
            /// Purges the CDN endpoint.
            /// </summary>
            /// <param name="cdn">An authenticated CdnManagementClient</param>
            /// <param name="contPaths">List of strings containing files to be purged</param>
            private static void PurgeCdnEndpoint(CdnManagementClient cdn, List<string> contPaths)
            {
                try
                {
                    if (contPaths.Count > 0)
                    {
                        cdn.Endpoints.PurgeContent(endpointName, profileName, resourceGroupName, contPaths);
                    }
                }
                catch (Exception ex)
                {
                    _error = String.Format("PurgeCdnEndpoint:{0}(EndpointName={1}, ProfileName={2}, ResourceGroupName={3}, ContPaths={4}) {0}{0} {5}", Environment.NewLine, endpointName, profileName, resourceGroupName, String.Join(" ,", contPaths.ToArray()), ex.ToString());
                }
            }
    

    This same section of code, using the same parameter settings and accounts, in a console application was able to successfully purge the listed content.

    The service is installed on a windows server 2016 and basically monitors and initiates purges when required.

    Is there any way to find out the cause?

    Thanks

    Dave

     

    Dave

    Friday, May 4, 2018 5:40 PM

All replies

  • Does the service always fail, or only sometimes?

    Can you share the rough timestamp of the request failure, and the REST request/response data?

    Monday, May 7, 2018 11:02 PM
  • Do you also get this error when trying to purge the content via the portal? 

    https://docs.microsoft.com/en-us/azure/cdn/cdn-purge-endpoint

    Monday, May 7, 2018 11:28 PM
  • Sorry for late reply...did not have alerts set on the thread...

    The time stamp was 5/4/2018 12:58:17 PM EST

    Thanks


    Dave

    Tuesday, May 8, 2018 1:31 PM
  • Again, Apologies for late reply. Not 100% sure but I believe that I did test via the portal interface for purging and was successful. No error. I will test later this afternoon.

    Thanks


    Dave

    Tuesday, May 8, 2018 1:33 PM
  • @Richard Li - Forgot to answer your REST/Response question. From the code above, I'm using the Azure components from the Nuget Microsoft Azure CDN Management Library (https://www.nuget.org/packages/Microsoft.Azure.Management.Cdn) and using the PurgeContent from the EndpointsOperationExtensions (https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.management.cdn.endpointsoperationsextensions?view=azure-dotnet) to which, I believe there is currently no response mechanism to see the response data from the call other than the error context as reported above.

    Any insight you might have would be appreciated...

    Dave


    Dave

    Tuesday, May 8, 2018 6:57 PM