Sdílet prostřednictvím


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.

Summary

The sample code below demonstrates the following features:

Prerequisites and setup

Complete the following steps before you compile and run the sample code:

  1. Provision a Gen2 Azure Time Series Insights environment.
  2. Configure your Azure Time Series Insights environment for Microsoft Entra ID as described in Authentication and authorization.
  3. Run the GenerateCode.bat as specified in the Readme.md to generate the Azure Time Series Insights Gen2 client dependencies.
  4. Open the TSIPreviewDataPlaneclient.sln solution and set DataPlaneClientSampleApp as the default project in Visual Studio.
  5. Install the required project dependencies using the steps described below and compile the example to an executable .exe file.
  6. Run the .exe file by double-clicking on it.

Project dependencies

It's recommended that you use the newest version of Visual Studio:

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