Query data from the Azure Time Series Insights Gen2 environment using C Sharp
Note
The Time Series Insights service will be retired on 7 July 2024. Consider migrating existing environments to alternative solutions as soon as possible. For more information on the deprecation and migration, visit our documentation.
This C# example demonstrates how to query data from the Gen2 Data Access APIs in Azure Time Series Insights Gen2 environments.
Tip
View Gen2 C# code samples at https://github.com/Azure-Samples/Azure-Time-Series-Insights.
Summary
The sample code below demonstrates the following features:
Support for SDK auto-generation from Azure AutoRest.
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 Data Access API requests.The sample provides a console interface demonstrating how HTTP requests are made to the following:
Prerequisites and setup
Complete the following steps before you compile and run the sample code:
- Provision a Gen2 Azure Time Series Insights environment.
- Configure your Azure Time Series Insights environment for Microsoft Entra ID as described in Authentication and authorization.
- Run the GenerateCode.bat as specified in the Readme.md to generate the Azure Time Series Insights Gen2 client dependencies.
- Open the
TSIPreviewDataPlaneclient.sln
solution and setDataPlaneClientSampleApp
as the default project in Visual Studio. - Install the required project dependencies using the steps described below and compile the example to an executable
.exe
file. - Run the
.exe
file by double-clicking on it.
Project dependencies
It's recommended that you use the newest version of Visual Studio:
- Visual Studio 2019 - Version 16.4.2+
The sample code has several required dependencies which can be viewed in the packages.config file.
Download the packages in Visual Studio 2019 by selecting the Build > Build Solution option.
Alternatively, add each package using NuGet 2.12+. For example:
dotnet add package Microsoft.IdentityModel.Clients.ActiveDirectory --version 4.5.1
C# sample code
Please refer to the Azure Time Series Insights repo to access the C# sample code.
Note
- The code sample can be executed without altering the default environment variables.
- The code sample will compile to a .NET executable console app.
Next steps
To learn more about querying, read the Query API reference.
Read how to connect a JavaScript app using the client SDK to Azure Time Series Insights.