您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

用于 .NET 的 Azure 流分析库Azure Stream Analytics libraries for .NET

概述Overview

Azure 流分析是完全托管的事件处理引擎,可以用来设置针对流式处理数据的实时分析计算。Azure Stream Analytics is a fully managed event-processing engine that lets you set up real-time analytic computations on streaming data. 数据可能来自设备、传感器、网站、社交媒体源、应用程序、基础结构系统等。The data can come from devices, sensors, web sites, social media feeds, applications, infrastructure systems, and more.

若要详细了解 Azure 流分析,请参阅 Azure 流分析实时欺诈检测入门To learn more about Azure Stream Analytics, see Get started with Azure Stream Analytics Real-time fraud detection.

管理库Management library

使用 Azure 流分析管理库可创建、启动和停止 Azure 流分析作业。Use the Azure Stream Analytics management library to create, start, and stop Azure Stream Analytics jobs.

直接从 Visual Studio 包管理器控制台或使用 .NET Core CLI 安装 NuGet 包Install the NuGet package directly from the Visual Studio Package Manager console or with the .NET Core CLI.

Visual Studio 包管理器Visual Studio Package Manager

Install-Package Microsoft.Azure.Management.StreamAnalytics
dotnet add package Microsoft.Azure.Management.StreamAnalytics

代码示例Code Example

此示例实例化流分析客户端并创建流式处理作业。This example instantiates a Stream Analytics client and creates a streaming job.

/* Include these 'using' directives:
using Microsoft.Azure.Management.StreamAnalytics;
*/
SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());

// Get credentials
ServiceClientCredentials credentials = GetCredentials().Result;

// Create Stream Analytics management client
StreamAnalyticsManagementClient streamAnalyticsManagementClient = new StreamAnalyticsManagementClient(credentials)
{
    SubscriptionId = subscriptionId
};

// Create a streaming job
StreamingJob streamingJob = new StreamingJob()
{
    Tags = new Dictionary<string, string>()
    {
        { "Origin", ".NET SDK" },
        { "ReasonCreated", "Getting started tutorial" }
    },
    Location = "West US",
    EventsOutOfOrderPolicy = EventsOutOfOrderPolicy.Drop,
    EventsOutOfOrderMaxDelayInSeconds = 5,
    EventsLateArrivalMaxDelayInSeconds = 16,
    OutputErrorPolicy = OutputErrorPolicy.Drop,
    DataLocale = "en-US",
    CompatibilityLevel = CompatibilityLevel.OneFullStopZero,
    Sku = new Sku()
    {
        Name = SkuName.Standard
    }
};
StreamingJob createStreamingJobResult = streamAnalyticsManagementClient.StreamingJobs.CreateOrReplace(streamingJob, resourceGroupName, streamingJobName);

示例Samples

查看 Azure 流分析示例的完整列表View the complete list of Azure Stream Analytics samples.