title | description | ms.service | author | ms.author | manager | ms.reviewer | ms.devlang | ms.topic | ms.date |
---|---|---|---|---|---|---|---|---|---|
Query data from a Gen1 environment using C# code - Azure Time Series Insights Gen1 | Microsoft Docs |
Learn how to query data from an Azure Time Series Insights Gen1 environment using a custom app written in C#. |
time-series-insights |
shreyasharmamsft |
shresha |
cnovak |
orspodek |
csharp |
conceptual |
09/30/2020 |
[!INCLUDE retirement]
Caution
This is a Gen1 article.
This C# example demonstrates how to use the Gen1 Query APIs to query data from Azure Time Series Insights Gen1 environments.
Tip
View Gen1 C# code samples at https://github.com/Azure-Samples/Azure-Time-Series-Insights.
The sample code below demonstrates the following features:
-
How to acquire an access token through Microsoft Entra ID using Microsoft.IdentityModel.Clients.ActiveDirectory.
-
How to pass that acquired access token in the
Authorization
header of subsequent Query API requests. -
The sample calls each of the Gen1 Query APIs demonstrating how HTTP requests are made to the:
- Get Environments API to return the environments the user has access to
- Get Environment Availability API
- Get Environment Metadata API to retrieve environment metadata
- Get Environments Events API
- Get Environment Aggregates API
-
How to interact with the Gen1 Query APIs using WSS to message the:
Complete the following steps before you compile and run the sample code:
- Provision a Gen1 Azure Time Series Insights environment.
- Configure your Azure Time Series Insights environment for Microsoft Entra ID as described in Authentication and authorization.
- Install the required project dependencies.
- Edit the sample code below by replacing each #DUMMY# with the appropriate environment identifier.
- Execute the code inside Visual Studio.
It's recommended that you use the newest version of Visual Studio:
- Visual Studio 2019 - Version 16.4.2+
The sample code has two required dependencies:
- Microsoft.IdentityModel.Clients.ActiveDirectory - 3.13.9 package.
- Newtonsoft.Json - 9.0.1 package.
Download the packages in Visual Studio 2019 by selecting the Build > Build Solution option.
Alternatively, add the packages using NuGet 2.12+:
dotnet add package Newtonsoft.Json --version 9.0.1
dotnet add package Microsoft.IdentityModel.Clients.ActiveDirectory --version 3.13.9
Please refer to the Azure Time Series Insights] repo to access the C# sample code.
-
To learn more about querying, read the Query API reference.
-
Read how to connect a JavaScript app using the client SDK to Time Series Insights. Azure-Samples/Azure-Time-Series-Insights/gen1-sample/csharp-tsi-gen1-sample/Program.cs