Azure Time Series Insights Tutorial
Introduction
Azure Time Series Insights (TSI) is a fully managed analytics, storage, and visualization service that makes it easy to explore and analyze time-series data from IoT solutions. This tutorial will guide you through the steps to set up and use Azure Time Series Insights to gain insights from your IoT data.
Prerequisites
Before you begin, ensure you have the following:
- An active Azure subscription.
- Basic knowledge of Azure IoT and its components.
- Access to an IoT Hub with data being sent from IoT devices.
Step 1: Create a Time Series Insights Environment
First, you need to create a Time Series Insights environment in the Azure portal. Follow these steps:
- Navigate to the Azure portal.
- Click on Create a resource and search for Time Series Insights.
- Select Time Series Insights from the results and click Create.
- Fill in the necessary details such as Subscription, Resource group, and Environment name.
- Choose the Tier based on your needs (Gen1 or Gen2).
- Select the Storage account where your data will be stored.
- Click Review + create and then Create.
Step 2: Connect IoT Hub to Time Series Insights
Now, link your IoT Hub to the Time Series Insights environment:
- Go to the Time Series Insights environment you created.
- Click on Event Sources under the Settings section.
- Click Add to create a new event source.
- Choose IoT Hub as the source type.
- Fill in the details for the IoT Hub, such as IoT Hub name, endpoint, and consumer group.
- Click Create to add the event source.
Step 3: Explore Data with Time Series Insights
Once the IoT Hub is connected to Time Series Insights, you can start exploring your data:
- Navigate to your Time Series Insights environment in the Azure portal.
- Click on Explore under the Overview section.
- The explorer will load, showing a timeline of your time-series data.
- You can use the various tools available to filter, analyze, and visualize your data.
Step 4: Query Data Using TSI Query APIs
Azure Time Series Insights provides APIs that you can use to query your data programmatically. Here’s an example of how to use the TSI Query API:
Example Query
To query data, you can use a tool like Postman or write a script. Below is an example using a cURL command:
curl -X POST "https://.env.timeseries.azure.com/timeseries/query" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "getEvents": { "timeSeriesId": [" "], "searchSpan": { "from": "2023-01-01T00:00:00Z", "to": "2023-01-02T00:00:00Z" } } }'
Response:
{ "events": [ { "timestamp": "2023-01-01T01:00:00Z", "measurements": { "temperature": 22.5, "humidity": 55 } }, ... ] }
Step 5: Visualize Data with Power BI
You can also visualize Time Series Insights data using Power BI:
- Open Power BI Desktop.
- Click on Get Data and select Azure Time Series Insights.
- Enter the connection details for your Time Series Insights environment.
- Load the data and start creating visualizations to gain insights.
Conclusion
Azure Time Series Insights is a powerful tool for managing and analyzing time-series data from IoT devices. This tutorial covered the basics of setting up Time Series Insights, connecting it to an IoT Hub, exploring data, querying data programmatically, and visualizing data with Power BI. With these skills, you can start gaining valuable insights from your IoT data.