Scott Hanselman

Cloud Power: How to scale Azure Websites globally with Traffic Manager

May 06, 2014 Comment on this post [26] Posted in Azure
Sponsored By

The "cloud" is one of those things that I totally get and totally intellectualize, but it still consistently blows me away. And I work on a cloud, too, which is a little ironic that I should be impressed.

I guess part of it is historical context. Today's engineers get mad if a deployment takes 10 minutes or if a scale-out operation has them waiting five. I used to have multi-hour builds and a scale out operation involved a drive over to PC Micro Center. Worse yet, having a Cisco engineer fly in to configure a load balancer. Certainly engineers in the generation before mine could lose hours with a single punch card mistake.

It's the power that impresses me.

And I don't mean CPU power, I mean the power to build, to create, to achieve, in minutes, globally. My that's a lot of comma faults.

Someone told me once that the average middle class person is more powerful than a 15th century king. You eat on a regular basis, can fly across the country in a few hours, you have antibiotics and probably won't die from a scratch.

Cloud power is that. Here's what I did last weekend that blew me away.

Here's how I did it.

Scaling an Azure Website globally in minutes, plus adding SSL

I'm working on a little startup with my friend Greg, and I recently deploy our backend service to a small Azure website in "North Central US." I bought a domain name for $8 and setup a CNAME to point to this new Azure website. Setting up custom DNS takes just minutes of course.

CNAME Hub DNS

Adding SSL to Azure Websites

I want to run my service traffic over SSL, so I headed over to DNSimple where I host my DNS and bought a wildcard SSL for *.mydomain.com for only $100!

Active SSL Certs

Adding the SSL certificate to Azure is easy, you upload it from the Configure tab on Azure Websites, then binding it to your site.

SSL Bindings

Most SSL certificates are issued as a *.crt file, but Azure and IIS prefer *.pfx. I just downloaded OpenSSL for Windows and ran:

openssl pkcs12 -export -out mysslcert.pfx -inkey myprivate.key -in myoriginalcert.crt

Then I upload mysslcert.pfx to Azure. If you have intermediaries then you might need to include those as well.

This gets me a secure connection to my single webserver, but I need multiple ones as my beta testers in Asia and Europe have complained that my service is slow for them.

Adding multiple global Azure Website locations

It's easy to add more websites, so I made two more, spreading them out a bit.

Multiple locations

I use Git deployment for my websites, so I added two extra named remotes in Git. That way I can deploy like this:

>git push azure-NorthCentral master
>git push azure-SoutheastAsia master
>git push azure-WestEurope master

At this point, I've got three web sites in three locations but they aren't associated together in any way.

I also added a "Location" configuration name/value pair for each website so I could put the location at the bottom of the site to confirm when global load balancing is working just by pulling it out like this:

location = ConfigurationManager.AppSettings["Location"];

I could also potentially glean my location by exploring the Environment variables like WEBSITE_SITE_NAME for my application name, which I made match my site's location.

Now I bring these all together by setting up a Traffic Manager in Azure.

Traffic Manager

I change my DNS CNAME to point to the Traffic Manager, NOT the original website. Then I make sure the traffic manager knows about each of the Azure Website endpoints.

Then I make sure that my main CNAME is setup in my Azure Website, along with the Traffic Manager domain. Here's my DNSimple record:

image

And here's my Azure website configuration:

Azure Website Configuration

Important Note: You may be thinking, hang on, I though there was already load balancing built in to Azure Websites? It's important to remember that there's the load balancing that selects which data center, and there's the load balancing that selects an actual web server within a data center. 
Also, you can choose between straight round-robin, failover (sites between datacenters), or Performance, when you have sites in geographic locations and you want the "closest" one to the user. That's what I chose. It's all automatic, which is nice.

Azure Traffic Manager

Since the Traffic Manager is just going to resolve to a specific endpoint and all my endpoints already have a wildcard SSL, it all literally just works.

When I run NSLOOKUP myHub I get something like this:

>nslookup hub.mystartup.com
Server: ROUTER
Address: 10.71.1.1

Non-authoritative answer:
Name: ssl.mystartup-northcentralus.azurewebsites.net
Address: 23.96.211.345
Aliases: hub.mystartup.com
mystartup.trafficmanager.net
mystartup-northcentralus.azurewebsites.net

As I'm in Oregon, I get the closest data center. I asked friends via Skype in Australia, Germany, and Ireland to test and they each got one of the other data centers.

I can test for myself by using https://www.whatsmydns.net and seeing the different IPs from different locations.

Global DNS

This whole operation took about 45 minutes, and about 15 minutes of that was waiting for DNS to propagate.

In less than an hour went from a small prototype in a data center in Chicago and then scaled it out to datacenters globally and added SSL.

Magical power.

Related Links


Sponsor: Big thanks to Aspose for sponsoring the blog feed this week. Aspose.Total for .NET has all the APIs you need to create, manipulate and convert Microsoft Office documents and a host of other file formats in your applications. Curious? Start a free trial today.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

"It's just a software issue"- Edge.js brings Node and .NET together on three platforms

May 01, 2014 Comment on this post [44] Posted in Learning .NET | nodejs | Open Source
Sponsored By
.NET and node together on three platforms

There was an engineer I used to work with who always said "That's just a software issue." No matter how complex the issue, no matter how daunting, they were confident it could be solved with software.

.NET and C# and NuGet and the community have been making some amazing stuff in the last few years like ScriptCS, Chocolately, Boxstarter. Azure Websites now supports ASP.NET, sure, but also PHP, Python, Java (Tomcat or Jetty or your own container), and node.js. Getting these things to work together has been an interesting software issue. Apps can run side-by-side, but they can't really talk to each other in-process. (Mostly one just moves data between universes over JSON and HTTP when need-be.)

However, Tomasz Janczuk has been working on Edge.js (on Github) for a while now. I showed his work at jQuery Portland last year, but this week he's taking it to the next level. He is creating a wormhole between software universes.

Edge.js now lets you run node.js and .NET code in-process on Windows, Mac, and Linux.

The name is great. An edge connects two nodes, and Edge.js is that edge.

node and .NET connected by edge.js

Here's a node app hello world node app calling .NET. Don't sweat that the .NET code is tunneled inside a comment, this is the Hello World proof of concept.

var edge = require('edge');

var helloWorld = edge.func(function () {/*
async (input) => {
return ".NET Welcomes " + input.ToString();
}
*/});

helloWorld('JavaScript', function (error, result) {
if (error) throw error;
console.log(result);
});

Perhaps you have a bunch of CPU intensive work or algorithms in C#, but you've also got a node.js app that needs the result of that work. Edge can help with that.

You can bring in a CS or CSX file into node like this:

var myCSharpCode = edge.func(require('path').join(__dirname, 'myCSharpCode.csx'));

You can bring code from a .NET DLL into a node.js compiled as well.

var clrMethod = edge.func({
assemblyFile: 'My.Edge.Samples.dll',
typeName: 'Samples.FooBar.MyType',
methodName: 'MyMethod'
});

It's not a hack, it's a clear way to marshal between CLR threads and the V8 (the node Javascript engine) thread. It's also interesting from a comp-sci perspective as the CLR can have many threads and V8 has the one.

nodecsharp

Here's Tomasz's own words:

Edge.js provides an asynchronous, in-process mechanism for interoperability between Node.js and .NET.

You can use this mechanism to:

  • access MS SQL from Node.js using ADO.NET more...
  • use CLR multi-threading from Node.js for CPU intensive work more...
  • write native extensions to Node.js in C# instead of C/C++
  • intergate existing .NET components into Node.js applications

Read more about the background and motivations of the project here.

Now, you might ask yourself, what problem does Edge.js solve? The answer is in the Edge.js FAQ.

Go explore what you can do. Edge goes much further than just C# and Node. It works on Windows, OSX, and Ubuntu but you should just "npm install edge" as there's a node package available.

Have fun! You have a lot more power and flexibility than you think. It's just a software problem.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Review: The Linksys WRT1900AC Dual-Wireless Router is the second coming of the WRT54G

April 24, 2014 Comment on this post [34] Posted in Reviews
Sponsored By

Linksys WRT1900AC RouterI just blogged about how I simplified my home network with a MoCA/Ethernet bridge. As a part of my home network rebuild, I swapped out my Netgear N600 for a shiny new Linksys WRT1900AC Wireless Router.

I've been a Linksys WRT54G fan for almost a decade. I ran HyperWRT for a while and then ended up with DD-WRT. Having a reliable, hackable router was a joy back in the day.

The Hardware

The new Linksys WRT1900AC has a design that is clearly meant to evoke the WRT54G, but it's a whole new beast. My first WRT54G was a Broadcom BCM4702 running @ 125Mhz, although later models went to 240Mhz. It had 16 megs of RAM and 4 megs of Flash. I was thrilled that theh WRT54G had "fast ethernet."

Compare that to the WRT1900AC with its dual-core 1.2Ghz ARM processor with 256 megs of DDR3. It's a PC, frankly, and I appreciate the power and flexibility.

This router is clearly a little spendy, and I was initially wondering it US$249 is worth the money. However, after using it for a week I can say yes. Let's say that it only lasts a year, that's less than $1 a day. If it lasts 5 years like previous routers, it's pennies. Considering that I work from home and need consistent and reliable connectivity, I'm willing to pay a premium for a premium device.

First, this is a 802.11a/b/g/n router and supports all devices, including the newer 80.11ac spec. It cover the full spectrum, pun intended, and has both 2.4GHz and 5.0Ghz support. It's got 4 large adjustable antennas, and the whole device is the size of a medium pizza. They even warn you not to put stuff on top of it so you don't block the heat sink.

I was also pleasantly surprised that the WRT1900AC has a USB 3.0 port and an eSATA port where you can plug in external storage, then access it as a file share. I was just talking to a neighbor who was considering a $600 NAS (Network Attached Storage) device, and I see now that the WRT1900AC could be that basic NAS for him. It supports FAT, NTFS, and HFS+ filesystems.

It's also super fast. Here's a large file copy for example. It's fast and rock solid at 100+ megabytes a second. I'm getting between 40-60 megabytes a second over wireless. I've also been able to get 20-40 megs a second off an attached hard drive. It's a competent simple NAS.

image

It's been consistently faster than my previous router in basically everything that I do. I haven't done formal tests, but it's looking like 20-30% just on the wireless side.

The Software

The WRT1900AC also will support OpenWRT later this year, and Linksys is encouraging folks like the DD-WRT, Open WRT, and Tomato projects to target this device. It's nice when a company creates hardware and doesn't freak out when the community wants to hack on it.

The installation was a breeze and I was impressed that they included a non-standard default password for out of the box security.

Their initial release of the built-in software is a little lacking, IMHO, in a few areas, most notably QoS (Quality of Service) and is a little bit of a step back from my previous routers. I'd like more absolute control over my traffic, but that's me. To compensate, I marked my Xbox and my Work PC as needing preferred packets, so rather than prioritizing specific traffic, the router will prioritize these machines by MAC address.

image

While it does lack in some places, it makes up in others. The interface is fast, and easy to use.

image

You can access lots of logs, diagnostics, and stats for everything. However, I have spent most of my time in the Network Map.

Screenshot (130)

Not to harp on this feature, but I really like this real-time filterable network map. From here I can see who's on which wireless channels, reserve DHCP leases, filter devices by type. It's a gimmick, but it's a gimmick that works and works well.

Screenshot (131)

I also registered my router with the LinksysSmartWifi.com site. This allows me to remotely manage the router from anywhere (without a dyndns.org account or opening the firewall) as well as from my iPhone. This also potentially means I could debug those network issues that only pop up when I'm travelling and my wife is trying to get on the internet. ;)

All in all, I'm very satisfied with this new router.

  • I've got greater wireless coverage than ever before.
  • I've got good management tools, inside, outside, and while mobile.
  • The speed is as good as anything I've ever used.
  • It has 90% of the features I need, and I'm confident I'll get more advanced features with updates or via open source projects.

For now, the Linksys WRT1900AC Wireless Router is sold only at Best Buy or on Linksys.com direct. It's worth the money if you want the fastest router out there.

* Disclaimer: I use affiliate links to buy gadgets and tacos. Click them and you support me, my lunch, and my blog.


Sponsor: Big thanks to Red Gate for sponsoring the feed this week. 24% of database devs don’t use source control. Do you? Database source control is now standard. SQL Source Control is an easy way to start - it links your database to any source control system. Try it free!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Simplifying your network with a bridge - Making an FIOs ActionTec MI424-WR a Network Bridge

April 23, 2014 Comment on this post [33] Posted in Tools
Sponsored By

I have FIOs Fiber-optic internet at my house and I'm very happy with it - have been for years. I get 35Mbit/s both up and down and it's rock solid. It's not technically all fiber of course, as the fiber goes into an ONT (Optical Network Terminal) in my garage and is changed into a COAX (Coaxial Cable) using MoCA technology, travels 50 feet, then goes into a very old ActionTec MI412-WR wireless router with 4 LAN ports. This common device is multi-function and not only changes the Coax to RJ-45 (Standard Ethernet), it acts as a LAN and Wi-Fi router, and also has been my home's DHCP server, passing out IP addresses to devices in my house.

NOTE: It may be possible to call your installer and have your ONT changed to use RJ-45, but Coax is the default for almost every installation I've seen. For most folks, it's fine. However, that Coax connection can limit our choices when adding 3rd party routers. Hence, this article.

The ActionTec MI424-WR is an old but competent router, but it has a very small NAT table which can cause issues over Xbox Live or in houses with dozens of devices, like mine. It also is a router with just 10/100Mbit Ethernet connections. If you're like me and push a lot of local traffic through it or use Gigabit Ethernet you'll want to think twice between flowing your entire home's traffic through this little router. I added a gigabit switch to partition things, but this router remains a weak part of the network.

There's a number of ways to optimize your home network when still using a mediocre router. The #1 complaint with wireless networks is wireless range. The second complaint is (perceived or otherwise) performance, both internally and externally.

TIP: Before you switch the ActionTec router to a bridge and possibly void warranties, here's two other options to improve your network. Otherwise, skip past these to the Bridging Instructions.

Option 1: Add a better wireless router and the ActionTec still does DHCP

I added a Netgear N600 a few years back along with a Netgear GS724T-300 24-port Gigabit Smart Switch. The N600 is powerful and faster Wireless N router for <$100. You can just disable the Wifi on your ActionTec and plug a new router into the old with a wired connection. The new router will get an IP address from the ActionTec and provide Wireless to the house. Just adding a new wireless router may be enough to get you more range without a lot of trouble.

Option 2: Add a second Wireless Router on the same SSID for double coverage

I've written up this option on my blog. You can have two routers with the same wireless network SSID. Before I had the N600, I added a second wireless router on the same SSID and used it effectively as a repeater.

Or, you can bridge the Coax and Ethernet and disable everything else on the ActionTec, removing all but the most fundamental of its functions.

GIANT DISCLAIMER: Let's just be clear here. I'm a random dude on the Internet and I'm showing you how to mess up your router and home network. If this works for you, awesome, I take full credit. If not, we never spoke and I don't know you. I know only what I wrote here. While some of you will write me with questions, I'll apologize now, everything I know is in this post, and I can't help. If there's errors in this post, they are mine and I'll try to correct them. Mess with your home router at your own risk.

Why did I do this? I want my internet traffic flowing through fewer boxes. I also wanted better wireless coverage in the house. I wanted a new, modern router with a larger NAT table, and better management tools. I didn't want to affect my (currently) very reliable internet connection by swapping out my old but reliable ActionTec. I just wanted to remove it from the equation.

WARNING TO THOSE GEEKS IN RELATIONSHIPS: You'll work on this for a whole weekend, like I did, and when you get it all working it'll be totally awesome and you'll love everything about yourself. Then, you'll go and regale our gender-non-specific-non-geek partner with tales of your dramatic success and they will not care. In fact, ideally, they won't even know that you did anything, but perhaps they'll be able to watch House of Cards in the tub when previously they couldn't. Regardless, be prepared for the deafening silence of your non-technical partner's profound apathy.

New Option: Make the ActionTec a Bridge, effectively hiding it from the network, and use a new Router for everything.

First, some irony. There's two great documents at the ActionTec support website.

  • The first is called "Can I Bridge the Actiontec MI424WR FiOS Router?" and basically says "The MI424WR does not support Transparent-Bridging, and neither Verizon nor Actiontec support attempting to bridge it."
  • The second document located at the same exact website is called "Configure MI424WR as a LAN MoCA Bridge." So. Ya. Drink that in. The point is, you're basically on your own and your Internet provider won't support you if you don't use their devices

That said, here's what I did. I picked up a new Router, specifically a Linksys WRT1900AC (between US$250 and US$300) that just came out.

MORE WARNINGS? REALLY? When redoing your home network you'll want to be prepared to lose connectivity, freak out a little, set static IP addresses, and be prepared to reset things if it doesn't work. If you're not comfortable with any of these things, just stop now.

You're going to be changing your router into a Bridge and it won't be passing out IP addresses any more. You best know where you'll be getting your next IP address from.

  • Set your PC to an unused static IP address within the range that your router passes out. For example. 192.168.1.100 for the PC.
  • Login to the router's existing IP address, usually 192.168.1.1, and go to My Network, then Network Connections, then Home/Office, then Settings

image

Note your current router's IP address:

image

  • Set a static IP. You want the PC and Router to have static IPs so you don't lose connectivity between them while you're doing all these changes. Once your IP has changed, you will likely need to access your router from that new IP to finish these instructions.
  • Also, disable the Wireless Access Point, you'll be using your other router soon. You only care about Ethernet and Broadband Connection (Coax).

Note also that my Coax and Ethernet are connected and not bridged. Ethernet and Wireless are bridged. That's the normal configuration for this router.

image

  • Go back to my Network, then Settings for Broadband Connection (Coax). Go to Internet Protocol and set your Broadband Connection (Coax) to No IP Address. This step is important.
    (They are all important, but this one is doubly so.)

Why? That means you don't want your Coax to pick up an IP Address from the ONT. You intent to pass traffic through (bridge) the Coax to the Ethernet. Your NEW router will use the Ethernet port and pick up the external IP Address from your provider.

image

  • Go back to Configure Home/Office Network and make sure you've checked the boxes under the Bridge section, so Broadband Connection and Ethernet are both checked, as seen below. Note that Wireless is disabled.

image

  • Click Apply and reboot the router.

At this point, the Coax port and the LAN 4 ports will be bridged. If you plug an Ethernet cable from the WAN port of your new router to ONE of the LAN ports of the ActionTec (and wait a while) you should see your new router pick up an external IP address. This did take about 5-10 minutes for me.

NOTE: Don't forget to change your PC's network back to automatically get an IP via DHCP.

Hopefully that's reasonably clear. Here's a visual way to look at it.

Typical Network

TypicalNetworkHanselman

Typical Network After Bridging COAX/Ethernet+ New Router

After performing major brain surgery like this you'll need to go over EVERY DEVICE IN THE HOUSE and Release/Renew their IP Address (I recommend this, although there are technically ways around it) as well as connecting them to your new Wireless Network's SSID.

My shiny new router is a Linksys WRT1900AC and it's AMAZING. It's spendy, but works fantastically and is worth the premium. It's nearly doubled my effective range and includes Gigabit Ethernet ports. Everything is faster, both internal traffic, and external.

TypicalNetworkHanselman

I hope this guide helps someone improve their home network. Have fun!


Sponsor: Big thanks to Red Gate for sponsoring the feed this week. 24% of database devs don’t use source control. Do you? Database source control is now standard. SQL Source Control is an easy way to start - it links your database to any source control system. Try it free!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Windows Phone 8.1 has my attention now

April 19, 2014 Comment on this post [67] Posted in WinPhone
Sponsored By
WindowsPhone 8.1-Nokia 920 and 1520

I've had an iPhone since the 3GS (I have a 5S right now) but I'm always flirting with the Windows Phone. It's just prettier than my iPhone, but my iPhone has a lot of apps...so I stay with it. Folks tease me at work and at conferences for not using a Windows Phone. I always say "when it's an awesome phone platform, I'll use it."

Man, Windows Phone 8.1 is definitely more than "point 1 better." Seriously.

It's the platform Windows Phone should have been from the beginning. From a general functionality perspective, this 8.1 update brings the Windows Phone (finally) on par with my iPhone 5s, and in some cases, takes it beyond. It's REALLY tempting now.

There's a lot of new stuff, but a few things really grabbed my attention that my iPhone doesn't have yet:

  • Notification Center - Finally. Swipe down from the top and get notifications in one place. Just like an iPhone you get quick access buttons for airplane mode, wireless, etc. Even better, those buttons are configurable. I added Internet Sharing to mine. You can also swipe down then press Settings as a fast way to get to the main settings page.
  • Transparent Live Tiles - You can use a background image for your whole start screen, and it will show through transparent tiles. It also has a nice parallax effect when scrolling. Check it out in the video below.
  • "Show more Tiles" on smaller resolution devices - The 1520 on the right has the 1080p screen, while the 920 is a lower resolution screen. Previously only high-res screens got the extra column of tiles. Now smaller screen devices can choose their start screen size and add LOTS more info to a single screen.
  • Pinnable Website Tiles - This one surprised me. I recently added support to my blog for IE11 Pinned Tiles, so you can pin this website to your start screen and get an updated Live Tile showing the latest stories. I talked to the front end developer at The Verge and he added the feature for theverge.com as well. His implementation is REALLY impressive. The surprise was that Windows Phone 8.1 now supports that same technique and I didn't need to do anything. See on the 920 on the right, at the bottom, that's a pinned flipped tile showing a story from my blog. Very nice.
  • Cortana Voice Assistant - You could say this is the Windows' Siri, but it's more like Google Now with a personality. The voice recognition happens as you speak as opposed to after the fact, which is nice. You can ask questions like "How old is Oprah" and she (or he) just knows. You can say "Call my wife" and she'll say "Who is your wife?" then associate a contact with that nomenclature.
  • Quiet Hours - I use Do Not Disturb on my iPhone. Quiet Hours takes this a little further with the concept of an "Inner Circle" and a more sophisticated series of configurable rules like "Don't bother me at night on weekdays unless it's these three people, and text everyone else back that I'm not answering calls."
  • Driving Mode - This was added in a Windows Phone 8 update but I love it. It knows you're driving because you associate your cars' Bluetooth with it, then it will text folks "I'm driving, I'll get back to you" if they text you. You can choose to never see the text until you stop. Very cool.
  • Keyboard Swiping - It's built into the main keyboard now, no separate app. The predictive text has gotten better as well.
  • Battery Sense - The phone can tell you what apps are eating the battery, and when they are eating it. It'll show if the battery is being used by apps in the background or in the foreground.

I recorded a video on a real phone (the 1520 above, in fact) and demonstrated a LOT of the new feature. Check it out as part of my Windows 8 YouTube video playlist, or embedded below. I used the Project My Screen app (MSI) and turned it on in Settings on the phone, connected with USB.

If you have a Windows Phone 8 now and want to get the preview of Windows Phone 8.1:

If you get the Preview today,your phone will update to the final version automatically, I'm told. Go check it out!

Related Links


Sponsor: Big thanks to Red Gate for sponsoring the feed this week. 24% of database devs don’t use source control. Do you? Database source control is now standard. SQL Source Control is an easy way to start - it links your database to any source control system. Try it free!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.