Query data from the Azure Time Series Insights Gen1 environment using C Sharp
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.
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 Azure Active Directory using Microsoft.IdentityModel.Clients.ActiveDirectory.
How to pass that acquired access token in the
Authorizationheader of subsequent Query API requests.
The sample calls each of the Gen1 Query APIs demonstrating how HTTP requests are made to the:
How to interact with the Gen1 Query APIs using WSS to message the:
Prerequisites and setup
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 Azure Active Directory 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:
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
C# sample code
Please refer to the Azure Time Series Insights] repo to access the C# sample code.