"Cloud discussion"-using open-source technology and Azure public cloud services to quickly build cloud-based IoT solutions (below), azureiot

Source: Internet
Author: User
Tags power bi

"Cloud discussion"-using open-source technology and Azure public cloud services to quickly build cloud-based IoT solutions (below), azureiot

This solution is a series of articles, including the first and second articles. In the article "using open-source technologies and Azure public cloud services to quickly build IoT solutions on the cloud (I)" last week, we have introduced the setup of Raspberry Pi and the installation and debugging of temperature sensors, we will continue to introduce the next process of "Creation and configuration of Azure-related services, code logic of Python Azure applications, and data verification through Power BI, finally, summarize the solution. The author of this article introduces:Microsoft Azure expert-level architect, Jianghu said "Huai Changqing". He has been named Microsoft's most valuable expert for five years. He has many years of cloud computing experience and has in-depth research on Microsoft's public cloud solutions. Solution Process: * About the solution architecture and the first half of the Process 1. install and set the OS for the Raspberry Pi. raspberry Pi Wireless LAN Settings and connection to the PC, and 3. for installation and debugging of temperature sensors, please read "using open source technology and Azure public cloud services to quickly build a cloud IoT solution (below)". 4. Azure service settings:

This step consists of three parts:Event HUB creation and setting, SQL Database creation and setting, and StreamAnalytics creation and.

  • Create and set event hub:

  • Note that the event hub name and namespace name are recorded, which will be used later. The format is: https://ksevent.servicebus.chinacloudapi.cn/ksevent where the front ksevent is the namespace name and the latter ksevent is the event hub name.

    Specify the partition and message retention period:

  • Stream analytics access sharing access policy settings:


      • SQL database creation and settings:

      • Create AvgReadings table:

        WinStartTime, WinEndTime, DeviceID, SensorID, SensorType, and SensorValue in the AvgReadings table

        Definition of AvgSensorValue and Eventcount:

    Create and set Stream Analytics: 
  • EventHUBStreamanalyticsSQL


    The definitions of these two Streamanalytics:

    Input settings (specify EventHub ):

    Select the EventHub created in the previous step and select the time center Policy Name in EventHub:


    Output settings (specify the SQL Server ):

    Select the SQLDatabase created in the previous step and select the AvgReadings table:

  • Stream Analytics Query settings:

    Kseventin filters DeviceId, SensorId, SensorType, and SensorValue data from event hub:

You can see the data received by StreamAnalytics in the SQL database:

5. RaspberryPi Python Azure Program

After sharing the creation and setup steps of Azure services, we should be able to find that: 1. Service creation and configuration are very simple; 2, the connection between different services is completely provided by Azure native, and users no longer need to deal with the connection problem between different services.

This step is the top priority of this solution and the only place where users need to write their own code. But don't worry, the amount of code is small, which may not be imagined by everyone.

Install and update Python, PHP, Socket, HTTP/REST, AzureSDK, and other related modules:

Root @ raspberrypi:/home/pi #Apt-get update

Root @ raspberrypi:/home/pi #Apt-get upgrade

Root @ raspberrypi:/home/pi #Apt-get install python-requests

Root @ raspberrypi:/home/pi #Apt-get installssl-cert

Root @ raspberrypi:/home/pi #Apt-get install php5-json

Root @ raspberrypi:/home/pi #Apt-get install php5-dev

Root @ raspberrypi:/home/pi #Curl https://bootstrap.pypa.io/get-pip.py | sudo python

Root @ raspberrypi:/home/pi #Pip install SoftLayerrequests = 2.5.3

Root @ raspberrypi:/home/pi #Pip install httplib2

Root @ raspberrypi:/home/pi #Pip install certifi

Root @ raspberrypi:/home/pi #Pip install urllib3

Root @ raspberrypi:/home/pi #Apt-get installlibio-pty-perl

Root @ raspberrypi:/home/pi #Pip install stdeb

Root @ raspberrypi:/home/pi #Apt-get install python-dev libffi-dev libssl-dev

Root @ raspberrypi:/home/pi #Pip install SoftLayerrequests = six-1.9.0

Root @ raspberrypi:/home/pi #Pip install -- upgrade ndg-httpsclient

Root @ raspberrypi:/home/pi #Pip install azure

Root @ raspberrypi:/home/pi #Pip install SoftLayer azure = 1.0.0

Obtain EVENTHUB SharedAccessName and SharedAccessKey:

Select kseventEvent Hub to view the Endpoint and SharedAccessKey:

So far, the Code has been completed, with dozens of lines of code.

6. Data Verification:

Data is collected from the temperature sensor through Raspberry Pi to EventHub, StreamAnalytics filters the data, and the filtered data is stored in SQLDatabase. Next, we can analyze and present data through PowerBI:

Power BI has a dedicated interface that can be easily connected to SQL Database (left). After that, you can use PowerBI to analyze and display data such as temperature and humidity stored in SQL Database (right ):

In addition, PowerBI can not only accept the input of data stored in SQLDatabase, but also the input of StreamAnalytics, so as to display Stream data in real time:


To successfully connect Power BI to Azure SQL Database of the Chinese version, you must add the IP address range of Power BI to the "allowed IP Address" List of Azure SQL Database, for example, if I use the Power BI service provided by Microsoft MSIT, I can add the IP address range used by MSIT to provide the Power BI service:

Then, you can use PowerBI to analyze and display the data in the Chinese AzureSQL Database.


So far, all the processes of the IoT solution have been completed, and the data from the front end has been collected and analyzed and presented to the back end. For Azure users, you only need to complete a very small amount of code on your own. Azure will help you complete the rest of the process. The establishment and completion of the entire solution will not take more than half a day. In addition, the entire system no longer requires the user to perform O & M management on their own. It can be said that it is completely a revolution in the IoT industry.

In addition, this solution is based on Raspberry Pi and based on the Linux platform. It uses the Python language to provide you with a solution that is more difficult to upgrade. If you use the Windows 10 IoT operating system and. Net for development, it will be simpler and the amount of code will be less. I have clients who use Arduino to send and receive sensor data. Because the hardware is too simple and only supports HTTP, AzureSDK installation is easier than Linux and Windows. However, with the efforts of both parties, the Microsoft team used the RESTAPI provided by AzureEvent Hub to help customers use Azure services and quickly set up IoT solutions.

In addition to the services listed in this article, you can also:

  • Integrate with the MediaService service provided by Azure to build an intelligent monitoring solution;

  • Integrate with the HDInsight service to build a big data analysis solution.

  • Integrates with the Mobile Service to build solutions for Mobile terminals.

More solutions will be available for you!

Azure has always pursued the idea of reducing technical costs and allowing users to focus on their own business logic. Azure helps you collect and filter data, data analysis and presentation and a series of related processes. It also helps you manage and maintain these systems, while other business logic is a great place for readers! Ten steps to build an IoT Solution Using Azure!

Finally, the editor has an appeal:


Visit http://market.azure.cn now


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.