fdvxkg
Last Updated: February 25, 2016
·
3.031K
· artfulhacker
10425126 10103995008712411 6222461894198440691 n

Azure CDN now Supports CORS

So we can finally host fonts in our Azure CDN!!!

This goes for anything else subject to cross-origin resource sharing restrictions.

So update your azure storage client library to (> 3.0) and do something like this:

var client = storageAccount.CreateCloudBlobClient();
var properties = client.GetServiceProperties();

var cors = new CorsRule();
cors.AllowedOrigins.Add("artfulhacker.com");
cors.AllowedMethods = CorsHttpMethods.Get;
cors.MaxAgeInSeconds = 3600;
properties.Cors.CorsRules.Add(cors);            

client.SetServiceProperties(properties);

If you want to allow any parent calling domain use this instead:

cors.AllowedOrigins.Add("*");

More information on this can be found here:

http://msdn.microsoft.com/en-us/library/windowsazure/dn535601.aspx

Say Thanks
Respond

3 Responses
Add your response

16895
Cb1593d703308e817d040825519fb0fb

I can believe it that a CDN is not configured by default to accept CORS from its own backend URL !

over 1 year ago ·
17021
202bfd99f4900ed88a72e4c1721dbe95

For me it doesn't seem to work. So I tried to apply with the asterisk (*) to be sure, but it still doesn't work. Running my app for second time I see with debugging the rule is applied.

over 1 year ago ·
17082
202bfd99f4900ed88a72e4c1721dbe95

Figured out blob storage does support the CORS rules, but the Azure CDN strips the CORS headers again.

over 1 year ago ·