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
Related protips:
Written by Mike Olsen
Related protips
3 Responses
I can believe it that a CDN is not configured by default to accept CORS from its own backend URL !
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.
Figured out blob storage does support the CORS rules, but the Azure CDN strips the CORS headers again.