使用 C Sharp 查询 Azure 时序见解 Gen1 环境中的数据Query data from the Azure Time Series Insights Gen1 environment using C Sharp

本 C# 示例演示如何使用Gen1 查询 API 查询 Azure 时序见解 Gen1 环境中的数据。This C# example demonstrates how to use the Gen1 Query APIs to query data from Azure Time Series Insights Gen1 environments.

提示

可以访问 https://github.com/Azure-Samples/Azure-Time-Series-Insights 查看 Gen1 C# 代码示例。View Gen1 C# code samples at https://github.com/Azure-Samples/Azure-Time-Series-Insights.

总结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. 预配 Gen1 Azure 时序见解环境。Provision a Gen1 Azure Time Series Insights environment.
  2. 为 Azure Active Directory 配置 Azure 时序见解环境,如身份验证和授权中所述。Configure your Azure Time Series Insights environment for Azure Active Directory as described in Authentication and authorization.
  3. 安装必需的项目依赖项。Install the required project dependencies.
  4. 编辑下面的示例代码,将每个 #DUMMY# 替换为相应的环境标识符。Edit the sample code below by replacing each #DUMMY# with the appropriate environment identifier.
  5. 在 Visual Studio 中执行代码。Execute the code inside Visual Studio.

项目依赖项Project dependencies

建议使用最新版 Visual Studio:It's recommended that you use the newest version of Visual Studio:

示例代码有两个必需的依赖项:The sample code has two required dependencies:

在 Visual Studio 2019 中,通过选择“生成” > “生成解决方案”选项来下载程序包。Download the packages in Visual Studio 2019 by selecting the Build > Build Solution option.

或者,使用 NuGet 2.12+ 添加这些包: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# 示例代码C# sample code

请参阅 Azure 时序见解存储库以访问 C# 示例代码。Please refer to the Azure Time Series Insights] repo to access the C# sample code.

后续步骤Next steps