Swiftorial Logo
Home
Swift Lessons
Matchups
CodeSnaps
Tutorials
Career
Resources

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:

  1. Navigate to the Azure portal.
  2. Click on Create a resource and search for Time Series Insights.
  3. Select Time Series Insights from the results and click Create.
  4. Fill in the necessary details such as Subscription, Resource group, and Environment name.
  5. Choose the Tier based on your needs (Gen1 or Gen2).
  6. Select the Storage account where your data will be stored.
  7. 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:

  1. Go to the Time Series Insights environment you created.
  2. Click on Event Sources under the Settings section.
  3. Click Add to create a new event source.
  4. Choose IoT Hub as the source type.
  5. Fill in the details for the IoT Hub, such as IoT Hub name, endpoint, and consumer group.
  6. 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:

  1. Navigate to your Time Series Insights environment in the Azure portal.
  2. Click on Explore under the Overview section.
  3. The explorer will load, showing a timeline of your time-series data.
  4. 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:

  1. Open Power BI Desktop.
  2. Click on Get Data and select Azure Time Series Insights.
  3. Enter the connection details for your Time Series Insights environment.
  4. 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.