smarx’s microblog

@smarx < this < blog.smarx.com 
« Back to blog

Why my latest blog post didn't work for a while

For those who were wondering (mostly Twitter users who jumped on the post as soon as I mentioned it), here’s the story of why my latest blog post (http://blog.smarx.com/posts/using-the-new-windows-azure-cdn-with-a-custom-domain) was “all screwy” (for a lack of a better term) for about 15 minutes until I sorted things out.

That post is about the new Windows Azure CDN capability, and I wanted to demonstrate it by doing a blog post where all the images were being served from a CDN.  In fact, all my blog posts from now on will work that way.

Background: I wrote my own blog software which runs on Windows Azure, and I use Live Writer via AtomPub to publish to the blog.  To make that work smoothly with the new CDN domain I set up (cdn.blog.smarx), I needed to edit the code so that when an image is posted to the blog, the URL that comes back is the one that points to the CDN address (instead of just smarxblogstorage.blob.core.windows.net, where it used to point).

Here’s what happened:

1.       I updated my blog code and ran a copy locally that would “do the right thing” w.r.t. the images in a new post.

2.       I used Live Writer to write the blog post and post it to localhost (going against cloud storage, so everything would look right at the real blog).

3.       I accidentally posted to the real blog (blog.smarx.com) instead, so images didn’t point to the CDN versions.

4.       I posted again via Live Writer to localhost to get things fixed up.

5.       Now there were two posts (since I wasn’t editing a post… I was posting something new, since it was going to a different URL).

6.       Having two posts broke some code on my blog that expected only one post at a time to have the same permalink.  (Hmm, I should have enforced that constraint at the data access layer…)

7.       I scrambled to write some code to delete one of them and ran that.

8.       It deleted one, but not the one I wanted to delete.

9.       I deleted the other one and published again from Live Writer.

10.   By now, Live Writer wasn’t trying to upload images anymore; it was using the existing URLs embedded in the blog post (so they looked ok but were not pointing to the CDN).

11.   I tried deleting the images and publishing from Live Writer again in the hopes that it would now be forced to re-upload the images.

12.   That didn’t work.  Now I had a live post with broken images everywhere.

13.   I deleted all the images in the post and re-inserted them from the images on my local drive, to really force a re-upload.

Lucky step #13 did the trick, and the post is now live at  http://blog.smarx.com/posts/using-the-new-windows-azure-cdn-with-a-custom-domain properly showing off the new Windows Azure CDN.

Boy, that was a stressful 15 minutes.

Loading mentions Retweet