title | description | ms.service | author | ms.author | manager | ms.reviewer | ms.devlang | ms.topic | ms.date |
---|---|---|---|---|---|---|---|---|---|
Query data from a Gen2 environment using C# - Azure Time Series Insights | Microsoft Docs |
Learn how to query data from an Azure Time Series Insights Gen2 environment by using an app written in C#. |
time-series-insights |
shreyasharmamsft |
shresha |
cnovak |
orspodek |
csharp |
conceptual |
10/02/2020 |
[!INCLUDE retirement]
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.
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:
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.
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
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.
-
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.