Scott Hanselman

Iterating quickly at a Hackathon with Azure Mobile Services and Dynamic Schema

October 8, '13 Comments [11] Posted in Azure
Sponsored By
Photo from Digital Undivided's Facebook

This last weekend I was in New York presenting at FOCUS100. I also was a mentor for the 24 hour mobile hackathon along with Tara Walker. The attendees were trying to create a mobile app (responsive site, or a native app, it didn't matter) in a single day (we were up all night.) A few of the teams didn't have any back-end experience, but had deep HTML and JavaScript experience. Rather than having them hardcode data a few ended up using Azure Mobile Services (which isn't the best name, but it's something.)

I call it a backend in a box. Rather than creating your own RESTful service with CRUD (Create, Read, Update, Delete) to return JSON stored in a database, you show Mobile Services what your data should be shaped like and lets you query it dynamically. So it's an abstraction over the boring stuff. You can add custom APIs and fully edit all operations later, but it gets you 80% of what you want for 20% of the time. Later you spend 80% of your time doing all your custom stuff; it's a great accelerator. It also abstracts away social identity logins (Facebook, Twitter, Google, Microsoft ID) as well as mobile push notifications.

Even though it's called Azure Mobile Services, it could also be called "Backend in a Box" or "Azure Backend Accelerator" but somehow those aren't really good names either. ;)

Here's how we iterated very quickly with one project. There's some tricks that we discovered to make things easier and more obvious. I'm pushing all the things we/I learned back into the Mobile Services team as they iterate quickly and are always improving the service.

Initial Iterations with Azure Mobile Services

First, let's assume you've signed for a free trial at You get $200 in credits (which is enough to run two VMs full time or dozens of standard sites on a single VM for a month, as well as 10 free websites, and 10 free mobile services).

You might also install the Azure CLI (Command Line Interface) via NPM as in "npm install azure-cli --g" then run "azure account download" then "azure account import" to associate your subscription's certs with the command line.

NOTE: If you are a command line person you can do most everything with the CLI. You can "azure mobile create 'servicename'" or "azure mobile table create" as well as "azure mobile data read" and on and on. We used the HTML5 Portal at the hackathon because it was easier for newbies to visualize.

From the Portal, make a Mobile Service:

You have no mobile services

Make a mobile service:

Making a mobile service

As an FYI, here's doing the same thing at the command line:

c:\>azure mobile create
info: Executing command mobile create
Mobile service name: hanselmanmobile
SQL administrator user name: focus100
SQL administrator password: ********
Confirm password: ********
+ Creating mobile service
info: Overall application state: Healthy
info: Mobile service (hanselmanmobile) state: ProvisionConfigured
info: SQL database (hanselmanmobile_db) state: Provisioned
info: SQL server (aq8l9z9gcb) state: ProvisionConfigured
info: mobile create command OK

Then I can create a Table in my new database. There's several levels of permissions can set, like auth'ed users, or accessible only with the app key. To speed up initial development, I'm setting it to Everyone. Then I'll ratchet up security as the schema starts to gel.

Creating a new table

Here's the same thing at the command line:

c:\>azure mobile table create hanselmanmobile widgets
info: Executing command mobile table create
+ Creating table
info: mobile table create command OK

I could set the permissions at create time with the command line as well, or update permissions after the fact:

c:\>azure mobile table update hanselmanmobile widgets -p read=public,insert=public,delete=public,update=public
info: Executing command mobile table update
+ Updating permissions
info: Updated permissions
info: mobile table update command OK

My endpoint is now (I could have lots of tables, of course.)

How do I get data in there and how do I tell the system what the data looks like? Since JSON is the format Mobile Services uses on the wire, you POST JSON at the service endpoint and it'll store that document.

Posting Data to Mobile Services in Multiple Ways

Some examples for Mobile Services have you/me/developers write an HTML page with JavaScript and run that to POST initial data. I, and the folks at the hackathon, preferred to get the data shape close while the UI folks did their mockups in parallel. Most attendees were familiar with cURL and wanted to use that.

Here's three ways to POST data to the new service.

Note that:

  • The data must be valid JSON.
  • You must include a Content-Type: application/json header or you'll get an HTTP 400 that says "invalid JSON," even though it may be the missing header.
  • A successful record creation will return an HTTP 201 CREATED.

Posting JSON to a Mobile Service via Command line with cURL

I like cURL for GETs, but for POSTing JSON it's complex and a hassle to encode the quotes and double-quotes in JSON correctly. Instead, I POST from a file. Put your JSON exactly as you want it in a text file, then:

c:\>curl -v -X POST -H "Content-Type: application/json" -d @topost.txt 

Doing the HTTP POST from a file removes a whole pile of issues. Also, use -v for verbose for ease of debugging.

Posting JSON to a Mobile Service with Fiddler

From my PC using Fiddler I can compose new JSON to POST like this:

POSTING with Fiddler

And note the HTTP 201 CREATED result:


Posting JSON to a Mobile Service with Postman

If you're using Google Chrome, you can get the Postman App (it's a REST debugger/Tivo for Chrome) or the REST Console and also POST and GET to your heart's content. Again, make sure to get the Content-Type set.

POSTing to an Azure Mobile Service with POSTMAN

Once the data is in the table, I can access it with a simple HTTP GET (in a browser or whatever) as well as via the Azure Command Line Tool or via cURL:

c:\>azure mobile data read hanselmanmobile widgets
info: Executing command mobile data read
data: id name price date_available
data: -- -------------- ----- -------------------------
data: 1 Ethernet Cable 5.99 2013-04-12T20:44:55+00:00
info: mobile data read command OK

c:\>curl --header accept:application/json
[{"id":1,"name":"Ethernet Cable","price":"5.99","date_available":"2013-04-12T20:44:55.000Z"}]

Of course, I can also see the data in the Portal:

Data in the Mobile Service

If I don't like the shape of this table, I can drop the table and recreate. I can also call "azure mobile data truncate" from the command line. I can delete an individual column and re-POST, or, if I'm just adding a column, I can post differently shaped data. This is the "dynamic schema" setting. When I get everything the way I want and I'm done iterating, I turn dynamic schema off and freeze the schema.

Azure Mobile Services Dynamic Schema

Mobile Services works great for getting a back end database and CRUD services up FAST. At this point, we were able to hook up HTML and JavaScript on the front-end and start pulling in live data quickly.

Later I'm going to learn about adding custom APIs, social logins, and push notifications as they'll be useful for future hackathons.

Sponsor: Big thanks to Telerik Icenium for sponsoring the blog's feed this week! Telerik Icenium now includes Visual Studio integration. Code once using HTML5 & JavaScript - build, test, and publish native-running iOS & Android apps. Start your 30 day trial with support!

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 twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Do you miss MIX? Join us at AngleBrackets 2.0 in Vegas

October 2, '13 Comments [10] Posted in Musings
Sponsored By

Later this month we're doing AngleBrackets again, you may have heard. Last spring we had a blast with folks like Lea Verou, Denise Jacobs, John Papa, and myself.

I miss the MIX conference. It was a fun web-focused conference with developers, designers, and web heads of all types. AngleBrackets, I think, is trying to bring MIX back.

This time we're going even "awesomer" with Douglas Crockford and Scott Guthrie!


We've got a great schedule lined up with Ward Bell, Elijah Manor, Miguel Castro, Michelle Bustamante, and lots more!

There's also pre- and post-conference workshops on User Experience, PhoneGap, Essential HTML5, Single Page apps, as well as "Fun with Functions with Douglas Crockford" himself!

Here's some sessions you'll see at AngleBrackets:

  • AngularJS SPA Jumpstart - Dan Wahlin
  • Apps & Opportunities - Steve Guggenheimer
  • Build a Business Application using ASP.NET MVC and Web Forms - John Kuhn
  • Building an End-to-End AngularJS App - Dan Wahlin
  • Building Rich Data HTML Client Apps with BreezeJS - Brian Noyes
  • Cloud-Powered Apps in Minutes with Windows Azure Mobile Services - Josh Twist
  • Code First Development with Entity Framework - Glenn Condron
  • Comparing AngularJS and Durandal for SPA Development - John Papa
  • Data Binding with Knockout.js - John Papa
  • Design or Die: The Challenge for Line-of-Business Developers - Billy Hollis
  • Designing RESTful Services with Web API - Brian Noyes
  • Doing More with LESS for CSS - Todd Anglin
  • End-to-End Security for Your Web API and MVC Applications - Michele Leroux Bustamante
  • Fixing Common JavaScript Bugs - Elijah Manor
  • Gamify Your Work - Denise R. Jacobs
  • Herding JavaScript File Cats with Dependency Management - Ward Bell
  • How to Build ASP.NET Web Applications Using Async - Glenn Condron
  • Implementing the HTML5 History API - Miguel Castro
  • Introduction to MVC - Scott Allen
  • JavaScript Patterns to Clean Up your Client-Side Code - Dan Wahlin
  • JavaScripts, Virtual Machines, the Cloud and The Metal - Scott Hanselman
  • jQuery-free JavaScript - Elijah Manor
  • Making Design Simpler for Developers - Shawn Wildermuth
  • Making HTML5 Work Everywhere - Todd Anglin
  • Mobile ASP.NET Web Forms - Making the Impossible Possible - Jeff Fritz
  • Mobile First Responsive Design with Bootstrap 3 - Shawn Wildermuth
  • Scalable and Modular CSS FTW! - Denise R. Jacobs
  • SignalR: The Real-time Web Made Simple - Damian Edwards
  • Syntaxation - Douglas Crockford
  • Understanding Dependency Injection & Writing Testable Software - Miguel Castro
  • Unit Testing 101 in JavaScript - Ward Bell
  • Web API 2: Web Services for Websites, Modern Apps, and Mobile Apps - Scott Hunter
  • What's New in Visual Studio 2013 ASP.NET Web and Cloud Tools - Scott Hanselman
  • What's your job, anyway? An indictment of current programming practices - Billy Hollis
  • Windows Azure Today and Tomorrow - Scott Guthrie

When you register for AngleBrackets you also get to go to all the conference sessions for our "sister conference" DevIntersection. Check out the DevIntersection promotional video and note that you can get $50 off with Registration Code SCOTTHA.

See you there!

Also mark your calendars for April 13 - 16, 2014 at the JW Marriott in Orlando.  We'll have AngleBrackets on the east code and busses to Disney World for folks bringing family.

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 twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

It's WAY too early to call this Insulin Pump an Artificial Pancreas

September 29, '13 Comments [41] Posted in Diabetes
Sponsored By


The diabetic internet and lots of mainstream news agencies are abuzz about the new insulin pump from Medtronic. Poorly written news articles that are effectively regurgitations of the Medtronic Press Release have exciting headlines like this:

Other news outlets have slightly better headlines like

But then ruin it with vague subtitles that are missing important context:

  • FDA approved the company’s automated insulin delivery system.

This is Step 1, possibly Step 0.

TO BE CLEAR. This new Medtronic 530G pump is NOT an artificial pancreas. It is an insulin pump, similar to the very model I'm wearing right now. It is paired with a revision of Medtronic's CGM (Continuous Glucose Meter) system and it does one new thing.

This new pump will turn off if you ignore its alarm that you may be having a low blood sugar.

Read it again, I'll wait.

Note the JDRF chart above describing the steps we need to towards a true artificial pancreas. This new 530G from Medtronic is arguably Step 1 in this 6 step process. It's the first step of the first generation.

But wait, doesn't your pump just handle things for you? You don't have to stick your fingers anymore, right? Wrong.

Let's stop and level set for a moment. Here's a generalization of your day if you're not diabetic.


Here's what a Type 1 diabetic (like me) does:


If I get this new pump that news outlets are incorrectly calling an artificial pancreas will anything in this cycle change? No.

There's NOTHING automatic here. I want to make that clear. Today's insulin pumps are NOT automatic. I set them manually, I tell them what to do manually. Yes, they "automatically deliver insulin as I sleep" but only because I told it to. If I eat and do nothing, I WILL get high blood sugar and today's insulin pumps will do exactly NOTHING about it.

If I only make decisions about insulin dosage based on my CGM then I WILL eventually get in trouble because today's CGMs are demonstrably less accurate than finger sticks. And, here's the kicker, finger sticks aren't even that accurate either.

Even more insidious is the issue of lag time. Medtronic's last generation of CGM lagged by 20 to 30 minutes BEHIND a finger stick. That meant I was getting "real time values" that in fact represented my blood sugar in the past. It's hard to make reliable altitude changes in your plane if your altimeter shows your altitude a half hour ago.

The Medtronic Press Release says that this new Enlite Sensor is 31% more accurate. I hope so. I personally continue to use a Medtronic 522 pump (this new one is the 530G) but I have given up on Medtronic's CGM in favor of a Dexcom G4. I am thrilled with it. The G4 has about a 5 minute lag time and is astonishingly accurate.

NOTE: I have no personal or investment relationship with either Dexcom or Medtronic. I am not a doctor or a scientist. I write this blog post with the expertise of someone who has been a Type 1 Diabetic for 20 years, a user of a Medtronic Pump for 15 years, a user of a Medtronic CGM for 4 years, and more recently a user of a Dexcom G4 for a year. My most recent A1C test was 5.5 putting my blood sugars at near non-diabetic levels on average. TL;DR - I'm a very good diabetic who uses the best available technology to keep me alive as long as possible.

I am extremely disappointed in the lack of research, due diligence and basic medical common sense in these articles. If you are a Type 1 Diabetic or have someone in your life who is, do the research and the reading and please spread the word so people can make informed decisions.

Related Reading

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 twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

The Myth of the Rockstar Programmer

September 29, '13 Comments [94] Posted in Musings
Sponsored By

There-is-an-I-in-TEAMThe Myth of the Rockstar Programmer is just that, a myth. It's an unfortunate myth for a number of reasons.

  • It sets an unreasonable expectation for regular folks.
  • Calling out rockstars demotivates the team.
  • Telling someone they are a rockstar may cause them to actually believe it.

Reality is a normal distribution curve. Lots of good average senior developers, some amazing outliers and some junior folks with potential. (and some folks that suck.)

Brooks's law: Adding manpower to a late software project makes it later.

The Rockstar Developer is a Myth

People love to say that a rockstar can do the work of 10 regular engineers. That's just nonsense. 9 women can't have one baby in a month, and 10 "rockstar" developers can't replace 100 regular ones.

I hate Quora so I won't link to them, but here's a modification of a great answer from Nate Waddoups that was taken from some internal engineering paperwork:

  • Junior Engineer - Creates complex solutions to simple problems.
  • Engineer - Creates simple solutions to simple problems.
  • Senior Engineer - Creates simple solutions to complex problems.
  • Rockstar Engineer - Makes complex problems disappear.

Am *I* a rockstar? I'm a competent Senior Engineer who is also loud. I've been on a lot of successful projects in the last 20 years and I was never the smartest guy in the room.

Senior + Loud != Rockstar

In my experience, in fact...

Senior + Thoughtful == Rockstar

That may or may not include being loud. Just because someone has written a blog, or a book, or speaks well doesn't mean they are a good developer. You certainly don't want a diva. Diva Developers do more harm than good.

Are rockstars about lines of code? No, good developers solve problems. More specifically, they make problems go away. They fix problems rather than complaining about them.

The Rockstar Team is Reality

In fact, it's diversity of thought and experience in a team that makes a Rockstar Team - that's what you really want. Put thoughtful and experience architects with enthusiastic and positive engineers who are learning and you'll get something.  If you insist on calling someone a rockstar, they are likely the team's teacher and mentor.

Jon Galloway says:

Pairing "step back and think" devs with "crank a lot of pretty good code out" devs is a recipe for a good team.

Build smart, diverse teams. Build rockstar teams.

UPDATE: I was just told about this post by shanley on the "10x Engineer." It's a great and detailed piece and you should check it out!

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 twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Sit, Stand, Walk, Type - Using a Treadmill Desk

September 25, '13 Comments [45] Posted in Musings
Sponsored By
Treadmill Desk

I've been doing this whole "sitting and thinking for money" thing for over twenty years now. I've written about some of the things that happen to the body after sitting and typing for long periods, and talked about ways we can try to stem the tide, like

Almost ten years ago I blogged about The Programmer's Back, The Programmer's Hands, and worse yet (and most recently) The Programmer's Body.

I'm happy with my desk, but since Being a Remote Worker Sucks I get cabin fever and need to mix it up. Sometimes I sit at my desk, sometimes I stand, sometimes I just escape to a local café. I needed another option.

I noticed that I wasn't getting nearly close enough to the arbitrary goal of 10,000 daily steps per my FitBit. When I travel I walk obsessively, but here in Oregon running and walking in the rain is really no fun. I started running on the treadmill in the last few months while making may way through my NetFlix queue but quickly realized that this is prime-email-deleting-time I'm wasting!

It was finally time to make this Treadmill into a desk. Being the immensely handy fix-it type that I am (not) I promptly tried to cut a piece of wood. It was quite the achievement, let me tell you.

The prototype was fine, just a board laid across the treadmill but it worked. I enlisted my Dad (who is actually Handy) and we iterated. Here's what we came up with. Bonus points to my Dad who is incapable of letting a piece of wood leave his shop without being sanded or property stained.

Treadmill Desk

First, we took the original boards and added small supports to keep it from moving laterally. Then I added foam from the inside of a bike helmet to make the fit even tighter against the side supports.

Treadmill Desk

Then, Dad built a small box with a lip to sit on top of the boards. This brings the laptop (my Lenovo X1 Carbon Touch) up to a height that keeps my hands at exactly a 90 degree angle to the keyboard. This has proven very comfortable - not too low and not too high.

Treadmill Desk

If I want to run full out, I just lift the two pieces up and move the aside. It's also worth noting that I'm still using the safety cord in case I trip or fall off the treadmill. I'm considering actually drilling a 1.5" hole through the middle of the box to thread the cord so if I do take a spill, it won't take the box with me.

I've been doing about 2 miles per hour at a slight incline. I don't like super slow walking (1 mph) as I find it actually requires more thinking than normal walking. So far today I've moseyed about 5 miles on the treadmill desk without really feeling it. I'm not sure I'd want to spend a full day doing this, but it's very comfortable and I think I'll use it for at least an hour or so at a time.

This was super easy to do and I recommend it to anyone who has (or can cheaply get) a treadmill, a few pieces of wood, and a laptop. It was so easy and the benefits are so clearly obvious, I'm actually a little disappointed I didn't do this years ago.

Sponsor: Thank you to RedGate for sponsoring the feed this week! Easy release management: Deploy your .NET apps, services and SQL Server databases in a single, repeatable process with Red Gate’s Deployment Manager. There’s a free Starter edition, so get started now!

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 twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

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