Lonnie Bowling

PI to Mobile Part 2 - Web API

Blog Post created by Lonnie Bowling Champion on Aug 5, 2012



I decided to break this part into two videos.  Part 2a is implementing the PI SDK into the WCF service created in Part 1 of this series.  Part 2b creates an ASP.Net Web API that connects it all together.  At the end of the two videos I have a working, but simple, RESTful type API which various mobile device can use to access PI data from an on-prem server.


PI to Mobile Part 2a - Azure Service Bus with OSIsoft PI SDK


In this video I extend our WCF service to use the PI SDK to access a PI System.  Data is relayed to Azure using a service bus.  In Part 2b I use this service bus to feed an ASP.Net Web API.  The goal is provide a Rest API PI service for mobile device to access PI data.


Here is 2a video




PI to Mobile Part 2b – ASP.Net Web API


In this video I create a RESTful API using ASP.Net Web API.  I connect to our service bus that was created in Part 1 and extended in Part 2a.  I cover how to deploy the entire project to Azure and end the video with a working example of a Web API service that provides data formated as JSON from a PI System.


Here is part 2b video






Source code is in two zip files because of file size limitations.  Unzip them in a common directory.


Download zip file 1 (11.8M)


Download zip file 2 (8.3M)


If you would like to test drive the API just open your browser and type the following:




This will return the last hour of values and times for simulation tag cdt158. Access is via Azure and then to the example PIConnect application running on my test server. You are not connecting to my server directly, but to the Web API hosted in Azure.  The range is in hours from now, so -1, returns the last hour of data.  Feel free to change the tag name and range.  If you have issues, please let me know, as this is kinda an experiment :)


I hope this inspires you to start thinking about how the cloud and mobile technology can help you innovate, and look good to the boss :)