Create ImageResizer.Plugins.AzureCDN
It can be adapted from the existing CloudFront plugin.
web.config:
<add name="AzureCDN" />
<azurecdn redirectThrough="https://azxcxcxcxcxcx.vo.msecnd.net" redirectPermanent="false" />
ImageResizer\Plugins\AzureCDN\AzureCDNPlugin.cs:
http://pastebin.com/JjRfhTcd
That is basically the CloudFrontPlugin.cs with altered references to web.config, without TransformCloudFrontUrl and with regular querystrings because Azure CDN has no problem with them.
ImageResizer\Plugins\AzureReader\AzureReader.cs -
needs an extra line:
c.Pipeline.RewriteDefaults += new Configuration.UrlRewritingEventHandler(Pipeline_RewriteDefaults);
and this:
void Pipeline_RewriteDefaults(System.Web.IHttpModule sender, System.Web.HttpContext context, Configuration.IUrlEventArgs e)
{
//Always request caching for this VPP. Will not override existing values.
if (vpp.IsPathVirtual(e.VirtualPath)) e.QueryString["cache"] = ServerCacheMode.Always.ToString();
}
Both copied from ImageResizer\Plugins\S3Reader\S3Reader.cs
I have this working in my solution
Azure now supports querystring preservation, making this irrelevant.
-
Azure CDN now supports querystring preservation, so I don't think this idea is relevant any longer; no plugins are required for Azure or CloudFront when they are configured properly.
-
frankvaneykelen commented
Yes, I can confirm that the CloudFront plugin does work unmodified, but the changes to AzureReader.cs are required to make it work
-
Well, it's already generic in everything except name. I agree a name change is needed, but it should work unmodified for your scenario.
-
frankvaneykelen commented
(and sorry for my late reply: I didn't have "Receive comment updates" checked)
-
frankvaneykelen commented
RE: Would it be easier to just use the CloudFront plugin as-is?
You mean adapting the CloudFront plugin to a generic CDN plugin that you point to the required CDN via configuration? Yes!
But then you would also have to change the name(space) of the plugin.
-
Would it be easier to just use the CloudFront plugin as-is?
-
frankvaneykelen commented
UPDATE: I was wrong about TransformCloudFrontUrl and the regular querystrings. My AzureCDNPlugin.cs now looks like this: http://pastebin.com/9ZXem43Y