Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon CloudFront invalidation in ASP.Net

I am not sure how to send a request using ASP.Net to Amazon CloudFront to invalidate an object.

The details are here http://docs.amazonwebservices.com/AmazonCloudFront/latest/DeveloperGuide/index.html?Invalidation.html but I am not sure how to implement this in ASP.Net... can someone please help?

like image 845
dimoss Avatar asked Nov 30 '22 05:11

dimoss


1 Answers

The accepted answer no longer works as of the latest version of the AWS SDK for .NET (1.5.8.0). This should do the trick:

using Amazon;
using Amazon.CloudFront.Model;

...

var client = AWSClientFactory.CreateAmazonCloudFrontClient(accessKey, secretKey);
client.CreateInvalidation(new CreateInvalidationRequest {
    DistributionId = distributionID,
    InvalidationBatch = new InvalidationBatch {
        Paths = new Paths {
            Quantity = arrayofpaths.Length,
            Items = arrayofpaths.ToList()
        },
        CallerReference = DateTime.Now.Ticks.ToString()
    }
});
like image 91
Todd Menier Avatar answered Dec 06 '22 03:12

Todd Menier