Pushing Data to an Azure Service Bus Queue

This is a simple example of what you need to get data into a queue in Azure Service Bus from a console application. This uses the WindowsAzure.ServiceBus NuGet package, so you can actually use it anywhere you can store a connection string and write some .Net.

Go here to get started, or log into your Azure portal.

Setting up the Queue

First, we’re going to create a new Service Bus Queue through the portal. This is pretty easy, just select New –> App Services –> Queue and pick Custom Create.


Punch in a name, create a new namespace then click next. You can use the default settings, just hit confirm. Note that if you use Quick Create, it assumes you have a namespace already setup, if that’s the case, you can use that as well.

Navigate to the Namespace dashboard and go to the configure tab. You’ll need to note the shared access key name and the key value itself.

Building the App

Next, create a new Console App in Visual Studio. Add this configuration line to your App.config (just make sure to remove the whitespace, it wrecks your config):

    <add name="AzureWebJobsServiceBus"
             SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=KEY" />

This gives the framework the connection string you need via the conventionally named key/value pair. Punch in those details you grabbed from the portal so that the connection string is valid for your environment.

Next, add a simple person class to your project as such:

public class Person
    public string Name { get; set; }
    public string EmailAddress { get; set; }

Get The Bits You Need

Now, get ready to send the message. You want to add the following package to your program via the Package Manager Console (or the Manage Packages menu item by right-clicking on your project in Solution Explorer).

install-package WindowsAzure.ServiceBus

Put in the Code that Does the Heavy Lifting

Finally, update your program code to grab the connection string and publish the message to the queue.

static void Main(string[] args)
    var connectionString = ConfigurationManager.ConnectionStrings["AzureWebJobsServiceBus"].ConnectionString;
    var client = QueueClient.CreateFromConnectionString(connectionString, "NAME-OF-QUEUE");
    var person = new Person {Name = "James Chambers", EmailAddress = "james@foo.com"};
    client.Send(new BrokeredMessage(person));

That’s it. Four lines of code and you have a way to push out a message and get back to work. Heck, if you can await (as in, in an aysnc method) you can even use SendAsync instead of Send so you don’t tie up your thread.

Next Steps

In the next post I’ll show you how to pop stuff off the queue and do something with it, then we’ll have a look at how to debug all of this.

Make sure you pop into Azure and give this a try! There is an amount of free credits that you get during your trial period. If you want to extend that, consider getting into MSDN (or getting your boss to) for other cool things as well, like VS Online and access to over a terabyte of development assets & software.

Happy Coding! Smile

Getting Microsoft Band Running Outside of the United States

If you are lucky enough to get your hands on a Microsoft Band before they’re readily available here in Canada or elsewhere worldwide in unsupported markets, you’ll likely run into a couple problems trying to get started.

When we tried to get my wife’s Band up and running we ran into a few small but totally surpassable hurdles. Our roadblocks stemmed from being both out-of-market and using a Windows Phone.

For the short version of the checklist to get thing running, skip to the end. For the walkthrough, keep reading.

Lighting up the Band on Your Phone

wp_ss_20150406_0001To start using the Band, you need an app on your phone, but it won’t appear in the Store. To get around this, you’ll need to change your Country/Region to “United States”, or another supported market (the app is available now in GB).

With the region set, you’ll be able to install and run the app, just reboot your phone and look for Microsoft Health in the Store. Unfortunately, you’ll hit another snag right away after you install it. Namely, you’re going to hit this error message when you try to launch Microsoft Health (the Band Sync app): Network Error. Something went wrong. Please check your network connection and try again.


Now, you can start troubleshooting, there are three reasons why you’ll get this error message than I have learned:

  1. You actually don’t have network connectivity. Make sure you’re connected to WiFi or have a good data connection with your cell provider.
  2. wp_ss_20150406_0002Your username has a special character in it. Likely due to a primarily English release in a limited market, it seems as though the app wasn’t thoroughly tested with letters outside of the English language. Go to the Microsoft Account site, sign in, navigate to “Basic Info”, then check your display name and remove any special characters.
  3. Your phone has a primary language other than English (United States). To change this, head back into settings and ensure that you have English (United States) in the list, and make sure that it is the first one in the list. I have it configured as such (see the image to the right) along with English (Canada) and it works just fine.

So, these are the solutions for Windows Phone, but I don’t have any iDevices or Adroid phones to test this out with. I wouldn’t be surprised if there were similar issues there as well, so hopefully these tips might be able to help you out.

The Short List

So, in summary, here’s what you’ll need to get going outside of a supported market with Microsoft Band:

  • A phone with the Country/Region set to “United States” (or another supported market)
  • A working and active WiFi or data connection
  • A display name in your Microsoft Account that doesn’t have special characters
  • A primary language of “English (United States)” (or another supported language)

A Quick Disclaimer

Changing the country, region and language settings on your phone may have other unintended side affects. Though it’s easy to change back, you should be aware of this in case other apps start behaving irrationally.

Hope this helps someone out there. A quick thanks to the gentleman on Microsoft Support chat who was completely willing to help troubleshoot, even though we weren’t in the US (he was the one who tipped us off about special characters).

Do you have a Band outside of the US? Do you have an iPhone or Adroid, and have you had any difficulties in getting it sync’d?

Off to keep building my Band app…happy coding everyone! Smile

Change in Windows Azure API – Websites.Services.WebEntities.ConnStringInfo

Automation is the bomb. I don’t like having to do something that can be automated more than once, so usually if I’m asked a second time (and I have a strong suspicion that I’ll be asked to do it again) I try to script it. This is very true of Windows Azure Web Apps and thankfully, it’s also easily facilitated.

I just fired up some old Azure PowerShell scripts I had (from mid-2013, I believe) that had a call that looked a little like the following:

# create and configure the connection string information 
$appConnString = New-Object Microsoft.WindowsAzure.Commands.Utilities.Websites.Services.WebEntities.ConnStringInfo; 

Essentially, it’s just creating an instance of the ConnStringInfo object so I can associate it with my site. However, when I tried running it I started getting the following error:

New-Object : Cannot find type [Microsoft.WindowsAzure.Management.Utilities.Websites.Services.WebEntities.ConnStringInfo]:
verify that the assembly containing this type is loaded.

Then, because the object couldn’t be created, I got errors trying to set each of the properties, like, “The property ‘ConnectionString’ cannot be found on this object. Verify that the property exists and can be set.”

Then I noticed that the script really mustn’t have been run in some time, as this is the current namespace for the class:


Websites was moved in late 2013 to the Commands namespace. You won’t likely run into it unless you dig up an old script that hasn’t run in a while, but the difference is subtle and might be tricky to spot.

Hope this helps, and happy coding! Smile

IoT For Humans (and Developers) – Getting Started with my Microsoft Band

Making the “Internet of Things” make sense to observers outside the industry is going to take a lot of work. While we might grow frustrated with the overuse and below-required understanding of the term, I would argue that in the industry we have a long way to go to fully understand the implications of security, health, privacy, etiquette, social dynamics, productivity and individualism.

But while the term may seem obscure, especially hiding being other abstractions like “connected devices” and mixed in with other buzzwords like “big data”, the reality is that…it’s here.

The auto industry embraced the “of Things” part really well quite some time ago, well before mainstream internet in fact, and has been increasingly good and getting the “Internet” part as well.

As a consumer, it would appear that my van sends me an email when it needs an oil change; in reality there is a query or a push occurring at some set interval or cued off of some trigger when I’ve reached a certain amount of mileage. That push or pull stores a flag in a database, which is later picked up by some service, likely processed through some kind of templating engine and mixed with my past service records and ultimately delivered to my inbox. But, dang, my van sends me emails, Mom!

Bringing IoT Home For .NET Developers

Even to me as a developer, while I’ve sensed these “Things” emerging around me it’s still been hard to find a way to explore them. You can’t get application development guidance or a NuGet package for your Chevy Uplander.

In many ways our phones have really become these interconnected devices as well, becoming more and more sensor-laden in a world where LTE and Wi-Fi signals have broader reach. Android watches and even the Pebble watch spaces have SDKs if you’re familiar with those development ecosystems or cross-plat tools to target specific devices.

But last week, my Microsoft Band showed up. And there is both an SDK and guidance freely available. As a developer on the .NET stack and solid knowledge of Azure, I can’t help but feel that my playground just got a lot bigger.

What I Get as a Tinkerer

So, for about $200, and leveraging my Azure benefits, I am like a kid in a candy shop. Here’s what I have:

  • A crazy amount of sensors (GPS, UV, heartrate, accelerometer, gyrometer, ambient light, microphone)
  • “Free” pairing with any major phone platform via the SDK
  • More sensors available via the phone
  • A myriad of connectivity options (Wi-Fi, Bluetooth, NFC)
  • Local and cloud-based storage
  • User accounts, identity services
  • Haptic and audio feedback mechanisms
  • Multiple interaction surfaces
  • Other cloud services (SMS, email, batch processing)
  • A human attached to all of the above
    • The ability to create applications on my laptop/PC/tablet that ties these things together

I haven’t quite figured out what I want to build yet, but there seems to be a lot of interesting paths.:

  • A “Safe and Alive” monitoring application for high-risk occupations (I’m already exploring this)
  • A immersive game with haptic, visual, audio, SMS and touch interactions
  • A reminder app to keep active, with an accountability partner using similar kit
  • An application that leverages the Band for build server (or other service) failures

Remember that some of these become quite interesting when you consider the fact that you don’t have to have your phone out or even in your pocket for these to work, just as long as the Band can maintain it’s Bluetooth connection. You can leave your phone when it gets the best signal (in the vehicle, at the entrance to a storage facility) and still have your app running, collecting, pushing, pulling and processing data.

So What Now?

These are exciting times, and I’m having fun exploring practical and completely impractical uses and applications. My kids, 13, 11 and 5, are infinite sources of hilarity in discussing what we can do with it. My wife, too, and I’ve found all of a sudden that without talking about “consumer applications”, “big data” and “interconnected devices” I have completely engaged the entire family in the “Internet of Things”. Oh, and I had to order my wife a Band as well. Smile

I’m going to start sharing my experiences while developing an application in the weeks ahead, delving into the use of the sensors on the Band, exploring interactions and trying to test it in real-world scenarios. Stay tuned to follow my path. My next post will be a “Hello World” app that introduces you to the tooling and SDK.

Have you got a Band? What applications are you thinking about developing? Do you have any successes or failures to share in regards to the “Internet of Things”?

Working from Home and Walking to Work: Surviving Remote Work

There’s a commercial that I’ve seen in the last few months on TV where the announcer is singing the praises of a lady who rides her bike to work, “…which is impressive, because she works from home.” While it’s true that it seems a little nuts to leave your house to go to your house, there’s actually some incredible wisdom in this simple practice. Working from home is a privilege and an expression of trust from our employers, even if we’re self-employed, and you need to be equipped to find a good cadence to your day.

Awake, Alert and Ready to Go

The first month that I started working from home I thought I had it made. I was sliding out of bed pretty much straight into my chair and starting my work day with the sludge still on my teeth, sipping on coffee and trying to make sense of the emails I was catching up on through my half-closed eyes. I’d usually wait until lunch to shower and I rarely did my hair.

Now, this was all kinds of bad for many reasons, especially because I wasn’t able to get any of my schtuff done, but it also meant that days were always a real slow build up. Rather than hitting the keyboard running with trumpets and sirens and “Hells, ya!”, it was more like a pitiful crawl being cheered on by a fourth-grader playing a sad kazoo.

So, I started walking to work. And I love it. I say goodbye to my kids and give my wife a smootch. I leave via the front or side door, head North and do a loop through my neighbourhood. I will usually read a few emails, catch up some news and listen to music as I walk, but often I stop to talk to folks who live in my community too. As I finish my walk, I enter the house through the back door, and I’m officially at work.

I am engaged, trumpets blaring, as I start hacking.

When I finish my work day, I leave through the back door, and head South, doing another loop, but usually on a different route. If it’s a busy evening, it can be as short as a block or two. I come in through the front or side door that I exited through in the AM and I’m back home.

Separation of Work Space and Home Space

This practice really helps me to keep the work stuff at work and the home stuff at home. There are a few other physical boundaries that I keep in place, but really, the walk at the start of the day and the end of the day are just a great way to get energized, tune in my focus on the way to my office and leave work behind when I’ve signed out for the evening.

Those other physical boundaries? I work in my office, I have a space set aside in my home where work stays. It is a very rare occasion when I bring my laptop out of my office to work elsewhere in my home.  I don’t keep a house phone in my office, and I don’t take my VOIP gear out into my home.  My wife and I don’t talk much through the day, if at all, except occasionally via Skype chat. In my new office (we’re in the process of renovating right now) I’m installing extra sound-proofing so that the noises of the home enter my work space even less than they do today.

Of course, there are some exceptions. At lunchtime, I just walk upstairs to have lunch with my bride, I don’t do the walk from-and-to work again. And if she is otherwise predisposed throughout the day, I’ll take the home phone with me as I head down to the office (our son has Type 1 Diabetes, and our house phone is the emergency contact number). And with kids missing school busses and meetings starting promptly in the AM or running late at the end of the day, I don’t always get my walk in. But I covet the days I do.

Find Your Own Survival Technique

The walking works for me, but it may not for you and I understand it’s not for everybody.  It really doesn’t have to be a walk, but as a remote worker I have found success in having a way to start my work cleanly and to be able to literally walk away from my job at the end of the day.

This is really a matter of figuring out how to not only survive the opportunity you have to work from home, but to find success in it. So figure it out! What is it for you that helps you train in on your work day? What is it that helps you disconnect as the evening begins?

Wake Up and Get S#!t Done – A Practice of Awesome

People, we need to get more stuff done. Insert whatever word is appropriate for you. We’re a culture consumed by consumption and I think it’s going to suck a lot of life out of our kids. Seriously, it’s going to suck.

As we seek to fill our time with things that are pre-fabricated, manufactured and less original, we lose out on the participation in creation, which is how we got to be awesome as a species in the first place. So, let’s be all commit to being more awesome.

  • Learn every day; just…be more learned.
  • Wake up early and give yourself an hour for your future self.
  • Teach someone, especially kids.

Sleep is awesome. I’m speaking from personal experience as I’ve done it a few times, in fact I’m quickly approaching 13,800 attempts at a night’s rest, many of them successful. I even take a nap most days. But we’re suckers for using sleep on the wrong end of our night. Staying up late is just way more appealing.

Bust Out of Your Funk

But what do we do in those last hours, when we’re the least rested and least focused? We watch House of Cards. Play games. Do the Facebook. Drown in Twitter or Instagram. Lame.

As far as New Years resolutions go, I’m not much of a fan. And since I try to do this every day already, it’s not really much of a commitment for me to make, but I think it’s a great life hack. So, here’s one thing that you can do to make your life better:

Wake up early.

That’s it. No secret sauce, no programs or diets or fads. Just get your arse out of bed.

I’ve been doing this, fairly faithfully for the last couple of years, and it’s something that I’ve started sharing with folks because it works. I can’t possibly make money off of you getting up earlier, so there’s nothing but a good honest recommendation in this.

Why do it? Because you can start to take control of your life, that’s why. You get up early, and things happen. There’s likely less distraction in your house and you’re going to be able to tune in to the task at hand. There are a ton of things you can do in just 45min-1hr:

  • Read something you’re interested in
  • Gain at least some awareness of world events
  • Learn, learn, learn
  • Go for a run/walk/bike, take out the trash, do some Yoga, shovel some snow (I do advise against snow blowers and lawn mowers in the wee hours, for the sake of the neighbours. Especially if I’m your neighbour)
  • Write, even if you aren’t sharing it
  • Solve a problem outside of your normal domain

I’m a software developer (in case you couldn’t tell from my blog) so for me, my goal is to stay caught up on the changes in the industry (cloud, patterns, vNext type stuff), things that influence my industry (electronics, politics, economic trends, job markets) and things that are disruptive to my career (wearables, IoT, startup culture, young kids with big ideas). I write code almost every morning. I try to work out 4 times a week.

If you don’t think that an hour of effort can make a difference, here’s what I did yesterday AM in 64 minutes:

  • Created a new Azure Web Site
  • Setup DNS for the site
  • Created a certificate request for the site
  • Applied for SSL with GoDaddy
  • Completed the certificate request
  • Exported the cert (with cert chain) and uploaded to azure
  • Added the site to a GitHub private repo
  • Published the site to Azure
  • Added two settings to turn “test” and “paypal sandbox” mode to my web.config
  • Added those app settings to the Azure website
  • Enabled SSL bindings and redirects

TL;DR: I got schtuff done. And yes, I track my time and keep a log. When I look back on my week, I can honestly reflect and say, “Good week, Chambers” or “Pick up the slack, home slice”. It’s not a tool to condemn myself, it’s a way to score wins and keep motivated. Last year I put over 150 hours into “my career” and this year my career is better than last year.


If you’re not a morning person, so what? All you’re saying is that you’re not great at waking up. So wake up earlier, and get over your “not a morning person” time, then get to work.

If you get up early and start doing something meaningful, there’s going to be a few things that happen:

  • You’ll start slipping away to bed earlier, because you’ll be tired earlier in the evening. Embrace it.
  • You’ll start to lose interest in gossippy, trendy fads.
  • Things you have wanted to learn will start to get learned.
  • Projects you have wanted to work on will get some attention.
  • It will be easier to walk away from your work during the day/evening and spend time with your family because you’re constantly achieving.
  • You will see less value in lower forms of entertainment (reality shows) and greater value in the investment in yourself and time with your loved ones.
  • You will be happier because you will feel like you’re accomplishing something nearly every single day.
  • You will appreciate your rest much more

Oh, yes, rest is important. And I don’t just mean sleep. No athlete worth her salt trains every day of the week, nor should you. Take a day off every week (I try to practice a digital Sabbath) and let yourself recharge. And balance your efforts (I take a walk before and after work). I will write on this soon, as it’s especially important for me as I am a remote worker.

    But, But, But…I Like my TV Shows! And I don’t Like to Get up Early!

“Can’t I just do this before I go to bed?” Sure, if that’s what you prefer. But why wait until your last hours of the day – as your concentration and willpower fade – to invest in yourself?

My morning ritual is easy: I get up, put the coffee on, do a quick workout (sometimes as short as 10 minutes), shower, grab my cup of joe and get to work. This takes less than 20 minutes, so I get up about an hour before the rest of the household. Want to know something crazy? I don’t even set an alarm. But, more on that in a future post.


My 11 year old son loves Lego and Dr. Who. He wakes up a couple of times a week and spends 10-15 minutes or so looking at online projects that other Lego-Whovians have built, and then tries to re-create them, or just builds his own, even recently getting into painting his own characters. He gets it: if he wants to learn how to do something, he’s got to put some time into it. He’s got school during the day, homework and music lessons during the evenings, and his parents make him get a reasonable sleep in each night. When else can he do this?

So, wake up early, close down your unnecessary browser tabs (Twitter, Facebook, email) and get some real s#@t done. Spend your early mornings on yourself, your daytime on your job, your evenings with the people you care about most and get a good night’s sleep. It will change your life for the better, guaranteed, or I’ll double your money back.

And happy coding. Smile

Fatal: unable to access ‘Repository': Failed connect to bitbucket.org:443; No error

I was getting this error when trying to push a new branch up to bitbucket today:

fatal: unable to access 'https://{account}@bitbucket.org/{project}/{repo-name}.git/': Failed connect to bitbucket.org:443; No error

I was able to get the correct IP for bitbucket.org via nslookup, and I was able to access both HTTP and HTTPS in a browser. Going verbose didn’t reveal much new information either:

$ GIT_CURL_VERBOSE=1 git push --set-upstream origin feature/select-account-dialog:feature/select-account-dialog
  * Couldn't find host bitbucket.org in the _netrc file; using defaults
  * Adding handle: conn: 0x36b570
  * Adding handle: send: 0
  * Adding handle: recv: 0
  * Curl_addHandleToPipeline: length: 1
  * - Conn 0 (0x36b570) send_pipe: 1, recv_pipe: 0
  * About to connect() to bitbucket.org port 443 (#0)
  *   Trying
  * Timed out
  *   Trying
  * Timed out
  * Failed connect to bitbucket.org:443; No error
  * Closing connection 0
fatal: unable to access 'https://{account}@bitbucket.org/{project}/{repo-name}.git/': Failed connect to bitbucket.org:443; No error

Then I noticed the Cisco VPN client icon in the taskbar…I was connected to a VPN. Disconnected, and the push was successful. Hope this helps someone else out there.

Haping coding. Smile

Team Foundation Error – BasicAuthCredential is not marked as serializable

I was working on a project hosted in a git repo in Team Foundation and wanted to update the build process. Scroll down for two different fixes if you’ve got the error, or read on to see if it’s applicable to your situation.

When I navigated to the step to configure the process template parameters, I ran into the following error:


The text was:

Team Foundation Error – Type ‘Microsoft.TeamFoundation.Client.BasicAuthCredential’ in assembly ‘Microsoft.TeamFoundation.Client, Version=, Culture=neutral, PublicKeyToken=’[token] is not marked as serializable.

I’m not aware of any recent changes or updates to my machine, my dev environment or the TFS server in question. I tried restarting Visual Studio, but the error persisted.

I then remembered that about three months ago I ran into a similar problem (though I can’t quite recall if it was the same error) when I started using a VM that had a co-worker’s credentials pre-baked into VS. To fix this problem I removed the credentials in Windows, and it resolved the issue, prompting me to sign in as myself when I next launched VS.

Solution 1 – Reset Your Credentials

Rather than removing the account, I wanted to first try to just poke it by re-entering my password or  To reset your credentials, try this:

  1. Close all instances of Visual Studio.
  2. Tap your Windows key, then type “Credentials”. The Credential Manager app link should show up in your list.
  3. Check out your “Windows Credentials”. Under Generic Credentials, you should see your TFS account.
  4. Click on the twirldown next to the entry and select “Edit”.
  5. Retype your password.

Solution 2 – Delete the Credentials from Windows

imageIf the reset doesn’t work, you can try this instead.

  1. Close all instances of Visual Studio.
  2. Tap your Windows key, then type “Credentials”. The Credential Manager app link should show up in your list.
  3. Check out your “Windows Credentials”. Under Generic Credentials, you should see your TFS account.
  4. Click on the twirldown next to the entry and select “Delete”.
  5. You may need to do this for more than one account, especially if you have a git:http:// account saved as well.
  6. Confirm the delete operation.

Whichever solution you have to go with, this should fix things up. Note that in solution 2, you’ll be prompted for your credentials when you open up Visual Studio and try to navigate to a team project.

Cheers, and happy coding! Smile

Day 2 – Adding Entities to a Storage Account Table

In this series we are looking at the basic mechanics of interacting with cloud-based Table Storage from an MVC 5 Application, using the Visual Studio 2013 IDE and Microsoft Azure infrastructure.

We’ve got some basics in place, namely loading up all resources from a table, but it turns out that users want to be able to add records, too. Who knew?  To allow this to happen, we’re going to need to update our view a little and add an appropriate method on our controller.  Let’s make that happen, then we’re going to take a look at why our approach is breaking down.  Don’t worry, we’ll start fixing things up in Day 3!

Updating Our View

We’re going to keep working off of the view we created in Day 2, just simply by adding a form below the existing UI. 

<h2>Like Kittehs? Add a Kitteh!</h2>
@using (Html.BeginForm("Index", "Home", FormMethod.Post))
    <div class="form-group">
        <label for="ImageUrl">What kind of Kitteh is it?</label>
        <select class="form-control" name="PartitionKey">
            <option value="FunnyKittehs">Funny Kitteh</option>
            <option value="CuteKittehs">Cute Kitteh</option>
    <div class="form-group">
        <label for="RowKey">Kitteh Name</label>
        <input type="text" class="form-control" id="RowKey" name="RowKey" placeholder="SeriousKitteh">
    <div class="form-group">
        <label for="ImageUrl">Image URL</label>
        <input type="url" class="form-control" id="ImageUrl" name="ImageUrl" placeholder="http://awesomekittehs.org/pic1.jpg">
    <button type="submit" class="btn btn-default">Submit</button>

If you’re new to Bootstrap, it may seem like there’s a lot going on there, but you get used to it pretty quickly. Our form has three “groups” in it.  This is a construct in Bootstrap that allows us to associate controls and labels and get the CSS styling we expect.   Each form group has a label and a control, in our case, and we’re simply putting in the properties we need in order to create a new row in our Azure Table.

The form is configured to POST to the Index action on the Home controller, so let’s set up someone to answer when the calls start coming.

Updating Our Controller

The next piece is just as easy. We want to accept the form information (our controller will leverage MVC’s model binding) and then create a new entity in the Table.

public ActionResult Index(KittehEntity entity)
    var storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));

    var client = storageAccount.CreateCloudTableClient();
    var kittehTable = client.GetTableReference("PicturesOfKittehs");

    var insert = TableOperation.Insert(entity);
    var kittehQuery = new TableQuery<KittehEntity>()
        .Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "FunnyKittehs"));

    var kittehs = kittehTable.ExecuteQuery(kittehQuery).ToList();

    return View(kittehs);

The insert is a type of TableOperation that we get by calling the static method aptly named “Insert” and passing in our entity. Our kittehTable object here is created in the context of a table reference that we load from our storage account by name.

At the tail end of the insert operation, we reload the list of kittehs (everyone is here to see the kittehs, after all) and return the view to render the list.

It’s Falling Apart!

Good grief, Charlie Brown, you’ve repeated all your code!  Our controllers should handle the mapping of requests and related payload to service endpoints, and direct users to the correct views.

Putting application logic into our methods is a dangerous slope, and anytime our actions start doing more than one thing we start making it hard to test and maintain our software.  This is ungood.

Next Steps

A lot of times tutorials and blog posts fall short in the area of best practices, and I don’t want to go there for this one. In tomorrow’s exercise we’re going to break our problem down into better pieces that more accurately represent what you’d be doing in a real-world application.

Microsoft Virtual Academy – A Lap Around Azure Websites – All the Questions and Links From the Talk

On January 14th, 2015 Jon Galloway and Cory Fowler presented a live “Lap Around Azure Websites” on Microsoft Virtual Academy. I was the online “Community Expert” for the live event and fielded questions in the chat.

The Links Shared from the Session

Some questions were more easily answered just by sharing a link! Here are the links that I mentioned in the chat or that were cited by Jon and Cory:

As well, here are some other really great MVA sessions you should take advantage of:

  • Building Apps with Node.js Jump Start (Course)
  • Introduction to Creating Websites Using Python and Flask (Course)
  • What’s New in Visual Studio 2013 Jump Start (Course)
  • Microsoft Azure Fundamentals (Course)

And, if you’re into the whole reading thing, I published a book on Azure Websites that is still really relevant, in spite of all the new features and changes the portal’s seen.

The Common and Predominant Questions

I grabbed the questions that stood out the most from the chat and am posting them below, along with my answers.

Can Javascript run on .NET platform also?
No, JavaScript doesn’t run natively on .NET. But Azure != .NET, and Azure Web Sites has many options for web stacks, including Node.js. Remember that JS has traditionally been a client-side language, so it of course can be used in any web application created with .NET

Do we need SDK’s and command line tools with Visual Studio 2015 Preview.
No, you don’t need it. But the SDK adds some extra (really useful) tooling, and the command line tools gives you options from a console or PowerShell script.

What are your thoughts on using WebMatrix? How does it compare to VS in terms of workflows you are going to talk about?
WebMatrix is a great tool for working with non-.Net stacks and has language support beyond what you’ll find in VS. However, if you’re working with .NET langauges (as well as many other non-.NET languages), VS gives you probably the IDE experience, hands-down.

When signing up for the free trial on Azure Websites it still asks me for entering my credit card details on the trial registration page. Is it going to charge me?
Even if they do collect the CC info, there will no charges. By default there is a spending limit of $0 on your account. Unless you remove that, there will not be any charges incurred. You can sign up with confidence!

How can you deploy to two Azure websites? One for Staging and another one for Production.
The easiest way is to use two different branches in source control, then you can automate everything about deployment to two entirely different websites. You can use slots and swapping to help with this.

My trial period has expired and I have converted my subscription to Pay-As-You-Go subscription. When will I have to pay something?
You’ll have to pay if you want to start adding “real-world” value to your project. Things like scaling, dedicated domain names, load balancing and the like.

Are MySQL databases hosted on Azure the same as SQL server? What’s the deal with these 3rd party partners? How is it different?
The third-party DB providers are from partners that may or may not use Azure resources. They provide an integration mechanism with Azure, but don’t necessarily spin up Azure resources. With MySQL, you just need a connection string to get at the data. It is not hosted on the same server as Azure SQL. And in the case of ClearDB, they are actually hosted on an Azure cluster.

Should a team have their GIT repository in VS online or Azure for an Azure site?
There is no preference. In fact, I have on-prem git repos, VS Online hosted and even repos (the majority) hosted on GitHub. You are free to choose what works with your team.

Should I add my packages to .gitignore when working with GitHub and Azure Websites? Does Kudu install the packages for me? If so, wouldn’t it be faster to deploy by NOT adding the packages to .gitignore?
It’s possible that you might save time, but deploying to different regions may mean greater latency as you deploy. Local cached packages can be quickly retrieved by Kudu, which could result in time saving for you.

Can I use the Kudu webhooks with a local githook from my Git repo? 
The webhook endpoint is exposed in the API, you can read more about it here.

How do deployment slots work? Can I use separate databases for different slots?
Slots can have their own configuration, so if you need different connection strings for the alternate slots, you can do that. This is also true of app settings and the like.

What does Kudu do?
Kudu is the deployment engine that powers Azure Websites. It’s grown into a great set of services that allow you to manage and customize your deployment process. There is a public API you can use in your own projects, integrate with other web hooks and more.

How does the Kudu Console work in the Browser?
The cool bits to me (as a developer) is the continuous connection to the browser from the server. That’s all powered by SignalR, which is another open source project started by some MS folks. You can find the SignalR GitHub repo here.

What are the costs related to turning on tracing?
There is a very small percentage of a performance hit, but nothing really in terms of monetary costs, it’s included in the platform. The one potential thing to watch for is that there is a cap on website space and the logfiles will count towards that.

How do I analyze the data from my error logs on my site?
You can use the built-in support site from the scm sub-domain on your site. Just navigate to <yoursite>.scm.azurewebsites.net/support and select your hostname. From there, you can drill in and see error and troubleshooting information.

Can I use .NET 3.5 on Azure Websites?
Yes, this is an option from the configuration menu. The only trouble I’ve had in moving to AW is when you have legacy third-party components that need access to unsafe memory or the registry (not supported on websites).