My Switch to Azure Websites

  • May 06, 2014 at 11:42 PM
  • Shawn Wildermuth
  • 19 Comments

UntitledI am a developer first. I’ve become my family’s IT department but not by choice. This is the fate of most developers I know.

For the past year or so I’ve been experimenting with Azure Websites as a solution for quick, one-off sites and even for class examples. I’m a big fan. Let me tell you why.

Why Azure Websites?

Azure is a diverse landscape with lots of services. It be a little daunting. I’ve some of these services, but certainly not all. Azure Websites is particularly interesting to me in that fulfills my desire to not be an IT guy. Why?

Azure VMs and Web/Worker Roles are both interesting ideas, but for many of my projects (especially smaller ones) I just want to host some code and possibly some data. Azure Websites lets me push some code to a server and fire and forget. It’s pretty magical.There are a lot of great tutorials on getting that to work (including the great Visual Studio 2013 Update 2 integration) so I don’t want to repeat all of that.

Because I’ve been in that playground a while, I’ve had some of my newer projects completely hosted there (e.g. http://howtowat.ch). I’ve had a long relationship with OrcsWeb and absolutely love how great they’ve been. Just amazing technical support, but with my upcoming world tour I wanted to consolidate and not have to manage RDP-ing into a box. I just wanted it to work. So I decided to move all of my sites to Azure Websites.

The other reason I liked Azure Websites is that it can host a variety of technologies for me. I use ASP.NET MVC for most of my projects but there are a couple of Node.js projects (including using Ghost for a blog engine for some of my sites). Azure Websites can do PHP (which means WordPress) and other platforms too. When I shoehorned Node.js into my Windows 2003 version of IIS it wasn’t painless. While creating an instance of Ghost blog engine on Azure Websites was ridiculously easy. Yeah ridiculously easy.

Let’s talk about some challenges.

DNS

My first battle was that I was pointing all my domains to the old box at OrcsWeb and using IIS to handle aliases and pointing to individual sites. I’m awful at IIS so this was always painful. Creating redirects (e.g. from www.wildermuth.com to wildermuth.com) and redirecting from old sites (e.g. agilitrain.com to wilderminds.com) were all done with individual ‘sites’ in IIS on my OrcsWeb box. I am sure for many of you that are more competent in IIS will tell me that is what DNS is for. And you’re right.

OrcsWeb has a good DNS manager that I could have done it there if I were more competent but when I decided to go to Azure Websites, I was perplexed how I was going to do this. In fact, I started to toy with using ASP.NET URL Rewriting to do it. Yeech.

It seems I had to actually learn how DNS works. I transferred my DNS back from my host to my domain provider (I use NameCheap and love them). By transferring them back, I could simply use their DNS tool to do the right thing.

For example, I have a domain called WilderWorldTour.com for information on my upcoming year on the road. I needed to redirect to this directly to the part of my site that covers that. (I don’t’ really want a 301 redirect, just a simple redirect). NameCheap’s DNS made this easy:

image

This eliminated several steps. My registrar was pointing my DNS to OrcsWeb for DNS. That DNS was pointing to my local IIS which then redirected to the right place. Lots of things to manage. Now it’s in one place. You’ll have to understand how all this works but it’s not hard.

Custom Domains

The free tier of Azure Websites is great for small test or teaching projects but for many of my projects I really need custom domains for most of my projects. This means I have to move to the lowest non-free tier at least. The costs for Azure Websites is pretty low and since I have an MSDN subscription, it covers quite a lot of use without any cost directly to me (other than the MSDN subscription itself). To do this can confuse many so let me show you how this works (with NameCheap’s DNS setup at least…yours is probably similar).

To do this you need to enable the Shared Web Hosting Plan and then in the Configure tab, add custom domains (you can do this from the home tab too, but here is where I do it):

SNAGHTML176b429f

The trick to using a custom domain is that you need to handle a few DNS records to point it at Azure Websites. For this example, we’ll use the wildermuth.com domain (not a subdomain). To start out you’ll need to find the IP address of the server you’re site is on. This is in the domain dialog (click “manage domains”):

image

First you need to point the wildcard DNS entry as an A-Record to this::

imageimage

This will tell the Internet to go to that IP address when your domain is hit, but Azure still needs to verify that you own a domain so you need to create a CNAME entry.

When you create a new Azure Website, it’ll automatically host you on {yoursitename}.azurewebsites.net. For example, my blog is at http://wilderblog.azurewebsites.net. This is also the suffix that Azure Websites uses when you need this CName entry. The easiest way to do this is to create a CNAME entry called “awverify” that points to “awverify.{yourazurewebsitename}” or awverify.wilderblog.azurewebsites.net:

image

Make sure this is a CNAME record like shown here. Last step is usually to also support the www subdomain. To do this, you’ll need the www CNAME entry pointing at the Azure Website name (wilderblog.azurewebsites.com) but you’ll need a awverify entry here too. This entry should be named awverify followed by the subdomain + the Azure Websites (e.g. awverify.www.wilderblog.azurewebsites.net) with a CNAME value of the same value:

image

Then you’ll have a custom domain for your Azure Websites. Sure there are some moving pieces for the verification but it’s a one time deal.

Debugging

A new feature in Azure Websites that just blows me away is the ability to debug directly on the server. This is a big deal to me. Rarely the code I deploy works great locally, but on the server just doesn’t work as expected. This feature let’s me debug with Visual Studio 2012 or 2013 directly. To do this, you have to enable it in the Configuration tab:

image

Turning this on allows you to open the Server Explorer in Visual Studio and right-click the website to directly attach to the debugger:

 

image

This works.  Just works. Amazing.  Of course, I rarely use this and it is slow so it’s a fallback experience, should not be your main development experience. But it’s availability is awesome.

Monitoring My Websites

One of my favorite things about Azure Websites is to be able to see real-time stats of many of the characteristics I care about. I can even get alerts:

image

The Monitor tab is quite interesting and you can add a variety of different stats. You can even point these stats at a server so you can do your own analysis (I never do). In order to have alerts, you have to have monitoring endpoints which is a whole ‘nother blog post. But this is enough information for me!

Would you consider moving your websites to Azure?

 

Comments

Gravatar

Tyrone Wednesday, May 7, 2014

About Azure Websites and using your MSDN subscription, I thought you couldn't use the free credits towards a non-development/test site. Can you clarify?

Gravatar

Shawn Wildermuth Wednesday, May 7, 2014

Tyrone,

They changed this policy a while back. They'll still get after you for abuse, but to host blogs and such, they'll never come after you. There is a discussion with Scott Gu on this but I can't remember where it is.

Gravatar

Tony Spencer Wednesday, May 7, 2014

I love Azure Websites for some things, but I actually find it is less expensive to spin up an extra small VM sized Cloudapp for asp.net websites. Plus you aren't stuck with quotas or shared instances. You also get a static IP address out of the box, you get the ability to have a staging instance which can be promoted to production later, on top of all the great features the Azure Websites give you. Perhaps the only thing you don't get is free SSL for cloudapp.net domain like you do for azurewebsites.net domains. However, if you are hosting your own custom domain, that free SSL Cert doesn't really do much for you.


Gravatar

Shawn Wildermuth Wednesday, May 7, 2014

Tony,

Ultimately that may be true...but I don't want to manage the VM...I want to be isolated from the OS.

Gravatar

Guy Wednesday, May 7, 2014

I've been contemplating the same move... How are you managing email?

Gravatar

Ian Trem Wednesday, May 7, 2014

Great article Shawn, I'm not far behind you in moving some of my clients and my own websites over to Azure. One thing I don't think Microsoft is too clear about is where the need for Azure Web Sites ends and the need for Virtual Machines begins. Yes, VMs offer more management (and the headaches that brings) but what size of site needs a full VM to run it?

Great stuff though and I look forward to hearing more about your experiences.

Gravatar

Shawn Wildermuth Wednesday, May 7, 2014

Guy,

I use Gmail for email. Unfortunately Gmail for Apps and Exchange Online both are pretty significant costs (they used to be free to add domains). In this case I already had my mail domains. The DNS manager in NameCheap does allow me to specify MX records so that wasn't an issue.

Gravatar

Christopher Woodill Wednesday, May 7, 2014

I also had a great experience moving my blog to Azure...I also use Azure Web Sites for development projects. See my blog post on the experience here:
http://www.microsofttrends.com/2013/12/24/creating-a-web-site-on-azure-2/


Gravatar

Dan Wednesday, May 7, 2014

Cost wise, I have about 15 stupid sites with custom domain names that get very little traffic. Something like 1and1 or Arvixe charges $5-10 for unlimited custom domains and sites a month with a database included. I don't mind paying more for Azure, but I'd have to pay $5-10 a month for each domain name right? I'd move all my sites over if it was $20 a month.

Gravatar

Vitor Canova Friday, May 9, 2014

So if you want to use http://MyDomain.net instead of http://MyDomain.azurewebsites.net you cannot use the Free tier? Or it is because you are using more than one http://*.MyDomain.net ?

Gravatar

Shawn Wildermuth Friday, May 9, 2014

Victor,

Yes, exactly. To use any custom domain, you have to upgrade to at least shared. Free is a great testbed for developers, but if you need a domain, you need shared.

Gravatar

Gatis Avots Saturday, May 10, 2014

Shawn, Dan,

I have also hard time understanding pricing details.
Is is true that the price for a shared website listed on Azure Pricing Calculator is the total cost of website running 24 hours a day? If I have a family blog which gets say one visit per day for 3 minutes, then in total that would be about = 90 (minutes per month) x 0.01 (EUR/h) = 0.02 EUR in month. Or am I wrong..?

Thanks!

Gravatar

Wen Tuesday, May 13, 2014

Thanks Shawn,

I have been play with Azure for a while and absolutely love it. Just wondering how to set up the both "http://www.domain.com" and "http://mydomain.com" I always get 404 for "http://mydomain.com" and dont know how to set up in domain manager

Gravatar

Maurits Tuesday, May 13, 2014

Shawn, nice read and i agree totally. I moved all my sites to azure last year.

Guy,
I prefer using Sendgrid, you can add this using Store in Azure.
regards, Maurits

Gravatar

Vesselin Obreshkov Wednesday, May 14, 2014

@Victor - I believe you should be able to create a CNAME record in your DNS manager that points to your yourdomain.azurewebsites.net hostname and that should theoretically work? You just have to manage the DNS yourself and things like SSL won't work but you should be able to have youdomain.com point to your free tier Azure website. I have never tested that though.

Gravatar

Vesselin Obreshkov Wednesday, May 14, 2014

Also, you guys should check out this blog from Scott Hanselman which although a little old (by today's standards) should answer some or a lot of your questions:

http://www.hanselman.com/blog/PennyPinchingInTheCloudWhenDoAzureWebsitesMakeSense.aspx

Gravatar

Mark Costa Friday, May 16, 2014

I'm really having a hard time to understand Windows Azure Website specially the prices and it's advantages. Like I'm a web developer and I do a lot of freelancer projects. So let's say that I have a small size company customer - about 50 employees/e-mails accounts - and a small monthly website traffic - no more than 10GB - and that requires about 400MB disk space. What is cheaper? A regular web hosting company where I pay $5/mo or Azure Website?

Gravatar

Shawn Wildermuth Friday, May 16, 2014

Mark,

This depends on other factors like traffic in and out. But if you're paying $5/mo, it's probably better to stay where you are.


Leave a Comment

*
*
*