28BYJ-48 Stepper Motor and ULN2003 Driver Intro

My buddy Sam Stokes just posted an awesome video on Channel 9’s “The Maker Show” about “Arduino and Servos” at the end of it, he mentioned that if you wanted to know more about steppers motors, you could check out my blog.

About a year ago, I was using some of the 28BYJ-48 steppers motors you can find pretty cheaply online.  In order to understand them better I took one apart.  That really got my mind going and after quite a bit of research I put together a video that explains how they work, and how you can drive them from pretty much any Microcontroller (like the Arduino, etc).  Check it out!

Using Power BI at Events


One of the issues we seem to run into regularly when we try to have attendees use Power BI at events like dev camps or hackathons is the messy account provisioning process.

I THINK I have this figured out, but I’m happy to take insights from anybody else if they have them.

The Video

I have published a video on Channel 9, “Signing up for Power BI“, that walks through the issues and solutions below. If you prefer to read about it rather than watch it, skip the video and scroll down!!

The Problem

  1. People can NOT sign up for Power BI using a “personal email address”.  That includes addresses from outlook.com, gmail.com, etc.  The reason why appears to be that Power BI uses Azure Active Directory behind the scenes, and it cannot add accounts for the public personal email services like outlook.com or gmail.com.    That means that all of the other guidance we give to attendees around signing up with their Microsoft Account (aka Live ID) is reversed with Power BI.  They CAN’T sign up with their Microsoft Account.
  2. There are some other reasons individuals may not be able to complete the self-service sign up process:  Power BI also doesn’t support .gov or .mil email addresses, the attendees may have an office 365 account that has been restricted by their administrator, and others.  The Power BI documentation includes a full list of possible issues.

Ideal Solutions

The following solutions are the easiest way to sign up for Power BI if you don’t already have an account you want to use.

  1. If the your employer or school is using Office 365 for their organizational email, and the organizational administrators have not specifically restricted access to Power BI (see above), then you should be able to just “Sign In” to http://powerbi.com with that account.  You don’t need to “Sign Up”.  Be aware that any usage you incur at the event will affect your account’s overall usage quotas. 
  2. If you have a good old “traditional” email address that uses Exchange or just plain old SMTP and POP or IMAP Servers, etc., you should be able to “Sign Up” at http://powerbi.com .  Email address like employeename@somecompany.com etc. should work fine for the normal sign-up process. 

Work Around

If neither of the above “IDEAL SOLUTIONS” works for the you, you can use the work around recommended by the Power BI team, and Sign Up for Power BI with a new Office 365 Trial.  I Recommend a few other specific steps than those outlined in that link.  These mainly include using “Private” or “Incognito” browser sessions and some best practices around how to fill out the required data.   For those steps, follow along below:

  1. Close all of open browser windows, then open a new “private” browser session .  These are “In Private” sessions in Edge or IE (Ctrl-Shift-P), or “Incognito” sessions in Chrome (Ctrl-Shift-N).  The reason why is that will allow you to browse as a new user with no existing cookies, credentials, etc.
  2. Once you are in a private browser window, follow this link to Sign Up for a Free Office 365 Enterprise Trial
  3. On Step 1 of the sign up wizard, USE YOUR REAL NAME, EMAIL, PHONE, and ORGANIZATION INFORMATION.  This WON’T CONFLICT with a real account you have at work or school.  This is just display and contact information for the trial you are creating.


  4. Step 2 is where you want to come up with a good name that doesn’t conflict with a long-term account you already own or wish to create in the future.  These instructions are intended to help you create a trial account that will be used for the duration of the trial period, and no longer.  If you are looking to create an official account for your organization you need to do more planning.   Anyhow:
    • For the User Name, I recommend using something like your FirstNameLastName.  This will make it easy to remember.  For example, in my case I would use BretStateham,  Of course, use whatever you like.
    • For the company or organization name, I recommend using your Initials, and the event name, YourInitialsEventName.onmicrosoft.com .  For example, if I were creating one to use at LAHacks, I might use BssLaHacks.onmicrosoft.com
    • Make sure to create a good password that you will remember.  You may want to note all of the things you used on this form.


  5. For Step 3, you will need to enter your REAL cell phone number, have the system send you a verification code via text, then enter the verification code you receive, and create your account


  6. After just a short time(a minute or two), your account should be ready:
    • Make a note of the portal address:
    • Make a note of your new trial account User ID:
      (or whatever you used)
    • Make sure to remember your password.  If you haven’t done so already you may want to make  note of all of the info.


  7. If you click on the “You’re ready to go…” link in on the screen, you will be taken into your Office 365 Portal (https://portal.office.com) .  The office apps (like Mail, Word, etc) should be ready in just a few minutes. 


  8. You can then go to http://powerbi.com (in the same browser if possible) and sign in with your new trial account user ID:


  9. When prompted, click the “Start” link to accept the license agreement:


  10. And after another minute or so, you should be in Power BI, and ready to start working!


Adding Users to your Office 365 Trial

If you have created an Office 365 trial account as outlined above, you can easily add other users to your trial.  This is really handy at an event like a hackathon where you might want to give multiple members of your team access to your Power BI data sets, reports, etc. Your can add a total of 25 users (including yourself) to your trial account.

  1. Open a private browser session, and login to http://portal.office.com using the trial account User ID you created above.  Then, click on the “Admin” link, or just open https://portal.office.com/admin


  2. On the admin page, along the left, expand “USERS”, then select “Active Users”, and click on the “+” button to create a new user:


  3. Complete the information for the new user.  You can either type a password in for them, or let a password be auto-generated and sent to them via email.  You can also add additional emails to send the password to, just semi-colon delimit the list of emails:


  4. The new User ID temporary auto-generated password will be displayed in the browser:


  5. But if you put the new user’s real email address in as the address to send the password to, within a couple of minutes the new user should receive an email with their login info:


  6. The new user can then use then open up a private browser session and login to http://powerbi.com using the new User ID and temporary password.  They can then change the password to something they will remember:


  7. And the new user will then be given access to Power BI (note, they can also login to https://portal.office.com to access office resources like email and more)


New C# REPL and scripting capabilities


Along with a number of other welcome additions to Visual Studio, Visual Studio 2015 Update 1 brings back and old friend. the C# Interactive Window.  The C# Interactive Window is what’s known as a “Read-Eval-Print-Loop” (REPL).  Interactive Windows are great when you just need to test a simple block of code, and don’t want to create an entire sample project, or code file. 

Opening the C# Interactive Window

Once you have Visual Studio 2015 with Update 1 running, From the menu bar, select “View” | “Other Windows” | “C# Interactive


Once the “C# Interactive” window appears, you can issue a “#help” command to get basic help on the commands available:


For a full set of documentation, you can check out Interactive Window Documentation on GitHub. You should also check out Kasey Uhlenhuth’s “Introducing the Visual Studio ‘C# REPL’” video from the “Connect(); //2015” event.  The documentation and Kasey’s video gives a pretty good introduction to the functionality so I won’t try to repeat that here, however, there are a few extra things I’ve found that I thought I’d share with you.

Give it a Try

If you have the Interactive Window open, you can try just entering a simple expression like “Hello, “ + “World!” and pressing ENTER.  You should see the result “Hello, World!” printed out for you.


Let’s try something with variables (you can use the #cls or #clear commands to clear the interactive window before moving on if you like a clean slate):


If you want to reset the state of the interactive window, including any variable or method declarations, you can use the #reset command.  The reset command clears the state, and reloads the “CSharInteractive.rsp” file to provide a default set of references and namespace imports (“using” directives). For example, here you can see that once I issue the #reset, the hello and world variables are now undefined.


To Semi-Colon or Not To Semi-Colon

When you type an expression (like “Hello, “ + “World!” ) into the window, you never use a semi-colon at the end, because it is an expression, not a statement.  The interactive window will always evaluate expressions, and output the result. 

When working with statements however, they MAY return a result (like in a method that returns a string).  For example, here I will create a method, called Concat that returns a string back to the caller.


Now, I’m going to call the method like an expression, WITHOUT a semi-colon.  Notice that the return value is displayed:


However, if I call it like a statement by adding a semi-colon.  The statement is executed, but the return value isn’t displayed. 


Command Line REPL

Lastly, I’ll mention that there is a command line version of the REPL functionality.  It doesn’t support all of the same commands as the interactive window, notably #clear, #cls and #reset are missing.  For the #clear and #cls commands, you can just use the command prompt’s cls command.  For the #reset, just stop the REPL and restart it. 

You need the Visual Studio tools to be in the path, the easiest way is to just use the “Developer Command Prompt” shortcut installed with Visual Studio:


From there, you can use the “csi.exe” command line REPL utility.  Calling “csi” with a “/?” parameter shows it’s optional parameters:


Here is the command prompt version of our Concat method and calls from before:


You can exit the REPL by typing Ctrl-C.

CSX Scripts

Lastly, you can save your C# scripts into a text file with a .csx extension.  Actually, the extension isn’t really important as long as you reference the full name when call it.  For example, I’ve saved a version of our Concat method declaration and call from above in a text file:


With your CSX scripts, you can’t have loose expressions (like “Hello, “ + “World!”).   All code needs to be wrapped up in methods or be statements.  Also, output is not automatically displayed.  If you want to see something, output it yourself using Console.WriteLine(), etc.


Wrap Up

It’s great to have the C# interactive window back.  I think there are a lot of use cases this will help solve and as a person who does demos a lot I think it will be a handy way to demo small concepts.  Check out the documentation, give it a try, and let me know what you think !

View your Application Insights data in Visual Studio

If you haven’t tried Microsoft Azure Application Insights before, it is a powerful tool for gaining insights in to how your web apps or mobile apps are being used, how they are performing, and what issues they may have.  You can even setup alerts in Application Insights to keep you informed when things happen that you care about.

Until now, you would primarily view the Application Insights data for your application using the Azure Portal (http://portal.azure.com)


Now with the Visual Studio 2015 Update 1 release though, you can now view Application Insights Data from right within Visual Studio 2015. To do so, from the Visual Studio 2015 menu bar, select “View” | “Other Windows” | “Application Insights Search


Then, when prompted select the Application Insights Resource you want to use:


Finally, you can use the search an filter criteria to zero in on exactly the Application Insights data you want to see


This new features makes it even easier to gain meaningful insight into your applications.  Give it a try and let me know what you think!

PowerShell script to open RDP session with an Azure VM

My Teammate Jeremy Foster recently shared some azure goodness that he added into his PowerShell Profile.  Then today, I ran across Brian Farnhill’s “Opening RDP session to an Azure VM with PowerShell” blog post and was inspired to add a simple function to my own PowerShell profile to simplify making RDP connections with my Azure VMs.

From a PowerShell command prompt, I opened my profile in notepad (or the text editor of your choice)

notepad $profile

Then, to the bottom of my profile I added the following function

function rdpvm ($ServiceName,$Name) {
  $vm = (Get-AzureVM -ServiceName $ServiceName -Name $Name)
  if($vm -and $vm.InstanceStatus -eq 'ReadyRole') {
    $rdp = (Get-AzureEndpoint -VM $vm | where { $_.LocalPort -eq 3389})
    $fqdn = (New-Object System.URI $vm.DNSName).Authority
    $port = $rdp.Port
    Write-Host "Opening Remote Desktop Session with $($fqdn):$($port)..."
    Start-Process "mstsc" -ArgumentList "/V:$($fqdn):$($port)"
  else {
    Write-Warning "The VM $($vm.Name) is not running ($($vm.InstanceStatus)).  You should start it first"

Now, in the future, when I am working with Azure in PowerShell I can simply run the following to open an RDP session with a VM.  Of course, this assumes I’ve already used “Add-AzureAccount” to sign into my azure subscriptions.

rdpvm -ServiceName <MyCloudServiceName> -Name <MyVMName>

Enabling Remote PowerShell Access for Secondary Administrators

If you want to use PowerShell Remoting to run scripts on a remote computer using an account other than the target machine’s built-in administrator account, you will  need to do a couple of things:

  1. On the target machine, create another user account and add it to the built-in “Administrators” group
  2. Set the HKLM/Software/Microsoft/Windows/CurrentVersion/Policies/System/LocalAccountTokenFilterPolicy (DWORD) to a value of 1 (you may need to add the LocalAccountTokeFilterPolicy DWORD value if it doesn’t exist). See http://support.microsoft.com/kb/942817/en-us for more details. 

Once you can do that you can use a Enter-PSSession or Invoke-Command with the credentials you created to remotely run PowerShell scripts against the target machine.

And yes, this applies to remoting into Azure Virtual Machines as well.  Just be aware that for Azure VMs you will need to import the certificate for the remote VM before you can successfully authenticate. 

For more info, check out Michael Washam’s “Introduction to Remote PowerShell with Windows Azure” and Jennelle Crother’s “The Imperfect Lab: Letting Additional Administrators Remotely Connect to Servers” .

Bret’s 70-532 MVA JumpStart Demo Files…

I’m presenting the Developing Microsoft Azure Solutions MVA (http://www.microsoftvirtualacademy.com/liveevents/developing-microsoft-azure-solutions) with Sidney Andrews today (12/19/2014).

We’ll be covering a number of topics:

  1. Azure Web Sites
  2. Cloud Services
  3. Virtual Machines
  4. Azure SQL Database
  5. Storage Services
  6. Application Architecture

Specifically, I’m covering the even numbered modules, on Cloud Services, Azure SQL Database, and Application Architecture.

You can grab a copy of my demos from http://aka.ms/BretsMVA532Demos .  Make sure to restore the NuGet packages in each solution.


Azure Hackathon Resources

At a Hackathon?  Need quick access to some “Azure How To’s to get you started?” Here are some links.  These resources are just to get your started.  If you need something more in depth, check out “Microsoft Virtual Academy

  1. Windows Azure Pass Usage Tutorial if you don’t have an Azure Pass code, you can always create a free trial
  2. Azure Documentation – Everything you need to know about Microsoft Azure
  3. Quick 3-Minute getting started with Azure videos
  4. Creating a Windows Virtual Machine in Azure – Azure Virtual Machines are a great way to get started with the cloud
  5. Creating a Linux Virtual Machine in Azure – Yep! You can create Linux VMs in Azure.   You can also learn how to install the LAMP stack on your Linux VM 
  6. Create a Node.JS Website in Azure and Deploy from GitHub – Azure websites support the platforms you love like ASP.NET, PHP, Python and Node.js and you can deploy from source control services like Visual Studio Online or GitHub
  7. Visual Studio Online – You can create FREE, PRIVATE projects in Visual Studio Online.  Get more than just source control.
  8. Create an Azure Mobile Service for your Android App – Azure Mobile Services are an extremely powerful way to create backends for your mobile apps!
  9. Create an Azure Mobile Service for your iOS App – And iOS apps
  10. Create an Azure Mobile Service for your HTML5 Client App!
  11. Getting User Data with Azure Mobile Services

“DevTest Scenarios in the DevOps World” Resources

Today, 10/20/2014 Cale Teeter, Charles Sterling, Jeff Levinson and I will be delivering a live session on Microsoft Virtual Academy on “Dev/Test Scenarios in the DevOps World”. 

You can grab a copy of Bret’s Demo Files here: http://1drv.ms/1r0CFJw

Spark Core enabled Compressed Air Rocket Launcher

Earlier this month some teammates and I were lucky enough to participate in TechCrunch Disrupt Hackathon in San Francisco


Our team project was called “Notifly” and was an online social media aggregation and activation platform.  In the end, we used it to watch a twitter hashtag, and launch a compressed air rocket when a threshold was crossed! We used a Spark Core from Spark.with a Relay Shield to activiate the rocket via a REST API!  Super cool Here’s a pic of everything assembled. 


Anyhow, if you would like to build your own, you can find the instructions for doing so on github at http://github.com/dxdisrupt/rocket