Skip to content

Commit fed0ccd

Browse files
authored
Merge pull request #110573 from mamccrea/functions-overview
Stream Analytics: udf overview
2 parents ee62d15 + f43175f commit fed0ccd

File tree

2 files changed

+61
-7
lines changed

2 files changed

+61
-7
lines changed

articles/stream-analytics/TOC.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,18 @@
6161
href: stream-analytics-sql-output-perf.md
6262
- name: Blob custom path patterns
6363
href: stream-analytics-custom-path-patterns-blob-storage-output.md
64-
- name: User-defined functions
64+
- name: Extend queries with functions
6565
items:
66-
- name: Machine learning UDF
67-
href: machine-learning-udf.md
68-
- name: C# UDF
69-
href: stream-analytics-edge-csharp-udf-methods.md
66+
- name: Functions overview
67+
href: functions-overview.md
7068
- name: JavaScript UDF
7169
href: stream-analytics-javascript-user-defined-functions.md
70+
- name: JavaScript UDA
71+
href: stream-analytics-javascript-user-defined-aggregates.md
72+
- name: C# UDF
73+
href: stream-analytics-edge-csharp-udf-methods.md
74+
- name: Machine learning UDF
75+
href: machine-learning-udf.md
7276
- name: Optimize your Stream Analytics job
7377
items:
7478
- name: Understand and adjust Streaming Units
@@ -140,8 +144,6 @@
140144
href: stream-analytics-edge.md
141145
- name: Toll booth sensor data analysis
142146
href: stream-analytics-build-an-iot-solution-using-stream-analytics.md
143-
- name: Run a JavaScript UDA
144-
href: stream-analytics-javascript-user-defined-aggregates.md
145147
- name: High-frequency trading
146148
href: stream-analytics-high-frequency-trading.md
147149
- name: Process IoT streaming data
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: User-defined functions in Azure Stream Analytics
3+
description: This article is an overview of user-defined functions in Azure Stream Analytics.
4+
author: mamccrea
5+
ms.author: mamccrea
6+
ms.service: stream-analytics
7+
ms.topic: conceptual
8+
ms.date: 04/07/2020
9+
---
10+
11+
# User-defined functions in Azure Stream Analytics
12+
13+
The SQL-like query language in Azure Stream Analytics makes it easy to implement real-time analytics logic on streaming data. Stream Analytics provides additional flexibility through custom functions that are invoked in your query. The following code example is a UDF called `sampleFunction` that accepts one parameter, each input record the job receives, and the result is written to the output as `sampleResult`.
14+
15+
```sql
16+
SELECT
17+
UDF.sampleFunction(InputStream) AS sampleResult
18+
INTO
19+
output
20+
FROM
21+
InputStream
22+
```
23+
24+
## Types of functions
25+
26+
Azure Stream Analytics supports the following four function types:
27+
28+
* JavaScript user-defined functions
29+
* JavaScript user-defined aggregates
30+
* C# user-defined functions (using Visual Studio)
31+
* Azure Machine Learning
32+
33+
You can use these functions for scenarios such as real-time scoring using machine learning models, string manipulations, complex mathematical calculations, encoding and decoding data.
34+
35+
## Limitations
36+
37+
User-defined functions are stateless, and the return value can only be a scalar value. You cannot call out to external REST endpoints from these user-defined functions, as it will likely impact performance of your job.
38+
39+
Azure Stream Analytics does not keep a record of all functions invocations and returned results. To guarantee repeatability - for example, re-running your job from older timestamp produces the same results again - do not to use functions such as `Date.GetData()` or `Math.random()`, as these functions do not return the same result for each invocation.
40+
41+
## Diagnostic logs
42+
43+
Any runtime errors are considered fatal and are surfaced through activity and diagnostic logs. It is recommended that your function handles all exceptions and errors and return a valid result to your query. This will prevent your job from going to a [Failed state](job-states.md).
44+
45+
46+
## Next steps
47+
48+
* [JavaScript user-defined functions in Azure Stream Analytics](stream-analytics-javascript-user-defined-functions.md)
49+
* [Azure Stream Analytics JavaScript user-defined aggregates](stream-analytics-javascript-user-defined-aggregates.md)
50+
* [Develop .NET Standard user-defined functions for Azure Stream Analytics jobs](stream-analytics-edge-csharp-udf-methods.md)
51+
* [Integrate Azure Stream Analytics with Azure Machine Learning](machine-learning-udf.md)
52+

0 commit comments

Comments
 (0)