Azure, Azure Government, Technical

Using Event Hub and EventProcessorHost on Azure Government

There are few needs which apply to almost every industry when it comes to building software and solutions to meet the needs of that industry. Manufacturing, healthcare, industrial, education, home automation, military and public safety (to name a few) all have a need to collect data from hundreds/thousands/millions of data sources and bring the data together in order to either report on it as a whole or send the data somewhere else. For example, a government agency responsible for monitoring rainfall and temperature across an entire country. It would be great if that agency could set up a few thousand monitoring stations around the country and have those stations report their respective sensor data to a central location for aggregation where the agency can begin to see trends across various regions within the country and across given time spans. Quite a bit more reliable and near-real time compared to sending a worker out to each station to collect data and bring it back manually to a data center.

In order to manage the intake and processing of what could be billions of pieces of data per day we will need a scalable and efficient hub for all of the sources to talk to at once. Using architecture speak, we need a durable event stream collection service. Azure Event Hub was built to support these types of use cases and perform as the event stream collection service that sits in the middle of our Internet of Things (IoT) architecture. Once we get our environmental sensors set up to send their data to Event Hub, we can easily scale that service to support the thousands of devices we need and begin building really powerful reporting solutions that utilize the ingested data.

To see what an actual Event Hub implementation would start to look like on Azure Government, where it was recently released (as of the date of this post) along with all other Azure regions, let’s start by setting up a simple Event Hub service using a single instance of EventProcessorHost following the instructions on the Azure documentation site. For the most part, using Event Hubs in Azure Government is the same as any other Azure region. However, since the endpoint for Azure Government is instead of for many other Azure regions, the sample needs to be modified a bit. Creating the Event Hub and storage account is exactly the same, shown in the screenshots below choosing the USGov Iowa region:

Creating the Event Hub

Creating the Storage Account

Creating the sender client is the same as shown in the example, as well. The small tweak we need to make is on the receiver, which references the storage account we created previously since EventProcessorHost utilizes a storage account when processing messages. Notice the URL for the storage endpoint in Azure Government is * When you create the EventProcessorHost in the receiver application, the default behavior of the class is to assume you are using a storage account located in the * domain. This means if you run the sample as-is (with your Event Hub and Storage Account info, of course), you will get an error:

Since my Storage Account was named “rkmeventhubstorage”, the default behavior is to create a URI of Obviously, that doesn’t exist. I need a URI of What now?

Diving into the source for Microsoft.ServiceBus.Messaging.EventProcessorHost, you’ll see (or just save your time and trust me) that the blob client is created using the CloudStorageAccount class. Looking at the documentation for that class, you won’t see anything to help get that endpoint updated (as of the writing of this post.) Turns out there’s an undocumented property for EndpointSuffix. Bingo. All you need to do is add a property for EndpointSuffix to use and the stars will align. Here is the full Main method for the Receiver application, showing the use of the EndpointSuffix property.

string eventHubConnectionString = "Endpoint=sb://;SharedAccessKeyName=ReceiveRule;SharedAccessKey={YourSharedAccessKey}
string eventHubName = "rkmeventhub";
string storageAccountName = "rkmeventhubstorage";
string endpointSuffix = "";
string storageAccountKey = "{YourStorageAccountKey}";
string storageConnectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1};EndpointSuffix={2}",
storageAccountName, storageAccountKey, endpointSuffix);

string eventProcessorHostName = Guid.NewGuid().ToString();
EventProcessorHost eventProcessorHost = new EventProcessorHost(eventProcessorHostName, eventHubName, EventHubConsumerGroup.DefaultGroupName, eventHubConnectionString, storageConnectionString);

Console.WriteLine("Receiving. Press enter key to stop worker.");

After adding that property, your Receiver will be able to receive the messages successfully.


How to Install Windows 10 Preview on a WinBook TW700

I picked up a couple WinBook TW700’s from MicroCenter back around Christmas time and after seeing some good stability results running Windows 10 preview on my Surface Pro 3 I thought the tablet would be a good device for the OS, too. I decided to do a clean install completely formatting the “hard” disk so I could get back the recovery partition space. The install is pretty much like on any other computer, but there are some driver issues that you need to be aware of so I wanted to post the steps here. This was with the current technical preview release build 10041 so any future builds may be slightly different and, hopefully, an improved experience with driver updates.

First of all, if you ever want the option to rollback to your Windows 8.1 install, you’ll need to create a recovery USB drive. Plenty of info on how to do that on the Internets so I won’t try to cover it here. For what it’s worth, I didn’t bother. 😉 Once you’re comfortable on that front, hit up the Windows Insider site to download the latest Windows 10 build. You’ll need a USB stick at least 4 GB to use for the tablet install so procure one if you don’t already have one. Format the USB to FAT32, mount the Windows 10 ISO on your computer and copy all of the contents of the ISO to your empty USB stick.

Now head over to your tablet. Since drivers aren’t available for many of the devices on the 700, the easiest way I found to get them updated post-Win 10 install is to copy the existing. Navigate to c:windowsSystem32DriverStoreFileRepository and copy the entire FileRepository folder to another USB stick and keep it handy. Now get a USB hub plugged into your tablet so you can have at least three devices plugged in at once. You’ll need to attach a USB keyboard, USB mouse and your USB drive with the Windows 10 installation files. Once that’s all hooked up, restart the tablet. When it’s starting up, hit F12 to get into the boot menu so you can choose to boot from the USB. From here on out it’s a basic Windows install so have fun with that and come back when complete, formatting your drives during the process if you so wish.

Now you should have a nice clean Windows 10 install and noticed that pretty much nothing works, except the USB mouse and keyboard :). Remove the Windows 10 USB and plug in the USB with the drivers. Launch Device Manager and you’ll see many yellow exclamation points. For each one you see, right click to update the driver and choose the option to search a local folder for drivers and select your USB. This will take some time and new ones will pop up after updating others, so just be patient and keep going until all the exclamation points are gone. Once Device Manager is clean, restart the tablet. After it comes back up, you’re up and running and all devices, including the touch screen, should be working. Lastly, run Windows Update to grab any updates there and restart if prompted. Unplug the USB hub and have fun tabletting on Windows 10!