Windows Azure Archives - Digital Tool Factory blog Windows Azure Archives - Digital Tool Factory blog

The Digital Tool Factory Blog

How to fix 502 Errors in WordPress on Windows Azure Websites

For the past month I’ve been getting the following error

502 – Web server received an invalid response while acting as a gateway or proxy server.There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.

I searched the internet – all to no avail – I tried Stack Overflow – no luck.

However, when I tried on the Azure Forums, they suggested turning on Failed Request tracing – which I did.

And while the error logs did not reveal any helpful error information, like “Setting A is set to true when it should be set to false for this to work” it did list quite a few entries for Glimpse – which I was using for my main website (the blog is in a subdirectory).  On a hunch I turned that off, and presto!  The site is working like a charm.  Why Glimpse when the site is deployed I have no idea, but I’m thrilled to not have the error anymore.


16
Sep 13


Written By Steve French

 

How to set mime types, aka Content Types with Windows Azure Storage

The Problem

I recently came across the conundrum of files not being availble for download after I uploaded them to Windows Azure Storage.

The Cause

Usually the problem is an incorrect mime type, but since Azure does not have mime types I had to do some more digging.

The Solution

It turns out there is a property called “ContentType” that must be set on the Azure Storage Blob programatically – here is an example

CloudBlockBlob blockBlob = container.GetBlockBlobReference(filename);

if (GetFileExtension(filename).ToUpper() == “.SWF”)
{
blockBlob.Properties.ContentType = “application/x-shockwave-flash”;
}
else if (GetFileExtension(filename).ToUpper() == “.MP4”)
{
blockBlob.Properties.ContentType = “video/mp4”;
}
blockBlob.SetProperties();

Once I did that everything worked as intended.


01
Aug 13


Written By Steve French

 

How to fix problems in adding ssl certs on Windows Azure Websites

For some reason, most likely because you never do it more than once a year, adding ssl certificates to a server is poorly documented and unnecessarily complicated.  Here are some things I learned recently about adding ssl certs on Windows Azure Websites.

I recently added a cert to this site, https://digitaltoolfactory.net which is hosted on Windows Azure Websites.  It looks simple enough, just upload a file, sure it’s a .pfx file, but those are avilable aren’t they?

Off I go to NameCheap.com, plunk down my $10 and get a GeoTrust Rapid SSL Certificate.  Then you have to generate a CSR – from there just go to your IIS manager and

  1. Click on “Create Certificate Request” (Common Name is the domain name btw)
  2. Do Everything it asks
  3. You will then plug that into your SSL Provider, they will then email (of all things) you back a long code
  4. Go Back to your IIS Manager and click on “Complete Certificate Request”
  5. You will then have a file – this is not the file you use
  6. From there click on the server certificate, and then click “Export”
  7. That will generate the .pfx file
  8. From there you can upload the file to Azure
  9. You then have assign the bindings to that certificate
  10. Restart the site in the Azure Manager

That’s it!

There are a few caveats.

The big one is that if you have any errors in this process Azure will not tell you – instead all you will get is the big scary “This site claims to be DigitalToolFactory.net, but the actual certificate is for *.WindowsAzureWebsites.net”.

The other caveat is that Microsoft is charging $9.00 per month to host a site site with Secure Socket Layer bindings, which is ridiculous.   By my estimation it costs more to host the cert than to host the actual site, which makes it unique in all web hosting.  Why they do this I don’t know.  I’m glad to have the option, but the amount seems ridiculous – hopefully that fee will drop soon.


26
Jul 13


Written By Steve French

 

My quick review of Red Gate’s Cloud Storage Studio 2

I recently had reason to move  a large number of files from one windows storage account to another.  One would think that this would somehow be built into Windows Azure storage, but alas, it is not that way.

Anyway, I searched the internets and came across Red Gate’s Cloud Storage Studio 2, which is more or less a file manager for Windows Azure Storage.

Here are my initial thoughts on Cloud Storage Studio 2

  1.  Overall status messages and notification messages appear in different places, this is  a bit annoying and confusing.
  2. I’m able to use it the way I want to without reading any documentation – that is always nice.
  3. The notifications and status need to be a bit more apparent – with a high latency product like a remote file manager the action status should be a bit more prominent.
  4. The price is a bit high – at $199 it’s a bit high for an impulse buy, and as a small shop I have a once a month need for a product like this (at present).  It is something I would have to consider.

On the whole, I like it, it works well (as I expect from Red Gate) and I would recommend it to others.

 


18
Feb 13


Written By Steve French

 

Tips and Tricks for running WordPress on Windows Azure

'factory at night' photo (c) 2008, Kazue Asano - license: http://creativecommons.org/licenses/by/2.0/I recently decided to experiment with Windows Azure, and here are some lessons learned about running WordPress on Windows Azure.  I wish I’d known these things before I started.

  1. Getting an install of WordPress on Windows Azure is as simple as they say it is.  Moving an existing site over to it can be challenging.
  2. One thing they do not tell you – while you can run up to 100 Azure Websites, which could be WordPress, on a reserved Azure instance, you only get 1 MySql Database.  As in one for the whole account.  The one you do get seems to be very nice.  When I first discovered this I almost scrapped the idea, but then I came across this blog post on using one MySql database for multiple WordPress accounts.  All you have to do is change the line

    $table_prefix = ‘wpGP_’;

    and you’re all set

  3. You cannot change the maximum upload size – it is set at 2 megs and that is all you get.  Since you are more less running in shared environment, that is not a bad thing
  4. However, I was moving my personal blog, which has been running for over seven years, and my initial import file was 14 megs in size.  I fixed this by splitting the 1 xml file into 19 xml files.  Tedious, but not difficult.
  5. Once all of the posts were in place it was a simple matter of migrating plugins and settings.  Quite frankly I was thrilled with the performance and responsiveness.

All good so far, but then I ran into the largest problem, specifically CNames.  Windows Azure uses CNames for EVERYTHING, which should not be a problem, but I hadn’t gotten around to moving that domain off of GoDaddy yet.  While it was easy to add a CName for www.moodyloner.net, it was NOT possible to add a CName for moodyloner.net.  This seems to be by design on Godaddy’s part.  I’m not sure why.  You can add a redirect of the domain in addition to changing the CName which is what I did.  Then you wait for two hours.

About a half hour in I lost my patience and moved the DNS over to Zonomi.  I was able to set everything up about five minutes and now I have a happy, responsive blog in the cloud.

Final thoughts about running WordPress on Windows Azure

I really like it.  The site is nice, fast, and responsive.  The permissions are configured properly out of the box and, now that I know all of these caveats, setting everything up should be easy going forward.


17
Sep 12


Written By Steve French

 

How to fix problems running Windows Azure web applications locally

The Problem:

You have an asp.net mvc 3 web project, and you are running it as part of a windows azure web application.   In my case it worked initially, but after I installed some Visual Studio plugins, run Windows Update, and installed a new router, it mysteriously stopped working.  A few of the error messages had me thinking it was caused by Sql Server, but I was mistaken.

The Cause:

This stumped me for several hours, but after much trial and error I discovered that the problem was with port mapping.

In the output window, I had the following messages:

Windows Azure Tools: Warning: Remapping public port 80 to 87 to avoid conflict during emulation.
Windows Azure Tools: Warning: Remapping public port 3389 to 3390 to avoid conflict during emulation.
Windows Azure Tools: Warning: Remapping private port 80 to 89 in role ‘MyCoolSite’ to avoid conflict during emulation.
Windows Azure Tools: Warning: Remapping private port 3389 to 3390 in role ‘MyCoolSite’ to avoid conflict during emulation.

I had enabled a homegroup somewhere along the way, which changed my network location, which somehow made changes in the firewall.

The Solution

This was more blind luck, but I got a windows firewall popup that asked me if I wanted to allow the Visual Studio Process to use lo these many ports.

So, in sum, check to make sure all of your ports are open.


15
May 12


Written By Steve French

 

How to create a Sql Azure database with Entity Framework codefirst

'King Cloud' photo (c) 2007, Karen Ka Ying Wong - license: http://creativecommons.org/licenses/by-sa/2.0/I’ve lately begun to use Windows Azure, and I thought I would start blogging about it as well.

Sql Azure database with entity framework codefirst – the song remains the same

As I am deeply committed to using ASP.net MVC 3 with Entity Framework CodeFirst, I thought at first moving to Azure might be a problem, as Sql Azure is marketed as a cousin to Sql Server, and not the real thing.  Happily that seems not to be the case.

I searched for a guide on how to use Entity Framework Codefirst with Sql Azure and couldn’t find one – so I just up and tried it and it worked quite well.  It works just like the regular Codefirst method, only you must specify the proper sql azure database in the web.Debug.config and the web.Release.config files.  Furthermore, that database must not already exist.  The Windows Azure admin screens strongly guide you in the direction of creating an initial database, but I’ve found if you just delete your default database it will create one for you.

So, in sum, you just treat Sql Azure the same as you would any other Sql Server database.  I’m not sure why Microsoft is marketing it as something radically different, but so far I have not discovered any meaningful differences between the two systems.


03
May 12


Written By Steve French

 




Copyright 2011 Digital Tool Factory. All Rights Reserved. Powered by raw technical talent. And in this case, WordPress.