用于 .NET 的 Azure 流分析库

概述

Azure 流分析是完全托管的事件处理引擎,可以用来设置针对流式处理数据的实时分析计算。 数据可能来自设备、传感器、网站、社交媒体源、应用程序、基础结构系统等。

若要详细了解 Azure 流分析,请参阅 Azure 流分析实时欺诈检测入门

管理库

使用 Azure 流分析管理库可创建、启动和停止 Azure 流分析作业。

直接从 Visual Studio 包管理器控制台或使用 .NET Core CLI 安装 NuGet 包

Visual Studio 包管理器

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

代码示例

此示例实例化流分析客户端并创建流式处理作业。

/* 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);

示例

查看 Azure 流分析示例的完整列表