Track and send your position to SharePoint with Microsoft Flow, Azure Functions and Power BI
Yes, how you can presume from the title, I’m talking about of geolocation. I read an interesting article by the MVP Jussi Roine on Petri, so I decided to dedicate my attention to clarify some aspects for the people that have not great confidence with Microsoft Flow, Azure Functions and Power BI.
First of all to summarize, the solution’s purpose is to send the current user geolocation with the smartphone across the app Microsoft Flow (Android, IOS), these geolocation info will be stored in a SharePoint online list, but before to save the data, Microsoft Flow App will call an Azure Function to grab through the Google Maps API the current position, obviously the last step will be display the info in a Power BI web part (in preview at the moment). For the accomplishment of this solution there are several strict requirements:
At the end we will have something like that:
Let’s go forward with the various steps:
First of all we have to prepare the structure of the SharePoint list, so create a new custom list, I called it “Tracking”:
|Title||Single line of text|
|location||Single line of text|
|lat||Single line of text|
|lon||Single line of text|
|Check-In||Single line of text|
Feel free to customize it as you prefer, in my case at the end the result will be, for example:
It’s time to build up the workflow with Microsoft Flow, really user friendly, to start designing, in the top bar of your SharePoint list view click on “Flow” icon and after “Create a flow” or eventually go here:
Create the workflow from blank without a template, Microsoft Flow is really nice to use and super intuitive to build in few minutes a workflow, this is my final workflow:
Above as you can see there are all the steps, the first one is triggered when there is the click button on the Microsoft Flow app. In the second step I’ll call the Azure function with an HTTP POST:
Directly from the smartphone we have the possibility to send the latitude and longitude to the Azure function, this couple of info are essential to retrieve the geolocation through the Google Maps API. Basically in the third step I’m going to handle the result of my Azure function with a JSON parse action, in fact I wanna add in my SharePoint list the address and in order to do that, I have to specify this in the JSON parse step:
The last step is characterized by the list item creation on SharePoint list:
so with Microsoft Flow we have finished.
The Azure Functions are the perfect choice when you have to implement microservice, I mean service with not a great business logic behind, like in this case. Open the Azure Functions Portal and proceed with the login, create here an “Http trigger” function, I used C# but obviously you can use what you prefer, below my function: It’s necessary insert in the Azure Function your developer Google Maps API Key, save, copy the url of your Azure Function and paste it on Microsoft Flow HTTP step.
At the end the SharePoint list will have this info:
but unfortunately this look and feel is not so suitable, the last step consists to have an intuitive UI. SharePoint online offers natively the web part Power BI in preview mode and this rapresent the final goal, now go here about the login use the same SharePoint online account because Power BI is part of Office 365 and here you have to configure (get data from SharePoint List) the report, after that, copy the url report because in the next step we will use it for the Power BI web part, keep in mind that to be able to embed in SharePoint Online the report, you need of the pro version of Power BI.
Now create a modern page on SharePoint and add the Power BI web part, paste here the url previously copied, as you can see I have done my check-in when I was in Italy and Germany, the final result will be: