Skip to content

Commit aa88e5b

Browse files
committed
Add Function support to Azure Stream Analytics PowerShell
This updates the Azure Stream Analytics PowerShell cmdlets with new cmdlets that support Functions, a new rest-only resource at the same level of inputs, outputs and transformation. Functions have the same actions as inputs and outputs (create, delete, get, test) as well as an additional action to retrieve the default definition for a function. - Added necessary classes to create the new function cmdlets - Updated the help xml files and other help related files to include functions - Added test coverage for functions, reran the tests and updated session records - Updated Stream Analytics SDK reference to version 1.7.3 New cmdlets: New-AzureRmStreamAnalyticsFunction Get-AzureRmStreamAnalyticsFunction Test-AzureRmStreamAnalyticsFunction Get-AzureRmStreamAnalyticsDefaultFunctionDefinition Remove-AzureRmStreamAnalyticsFunction
1 parent 4b58f19 commit aa88e5b

34 files changed

+6045
-3938
lines changed

src/ResourceManager/StreamAnalytics/Commands.StreamAnalytics.Test/Commands.StreamAnalytics.Test.csproj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.0.19.2-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
6767
</Reference>
6868
<Reference Include="Microsoft.Azure.Management.StreamAnalytics">
69-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.StreamAnalytics.1.7.1\lib\net40\Microsoft.Azure.Management.StreamAnalytics.dll</HintPath>
69+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.StreamAnalytics.1.7.3\lib\net40\Microsoft.Azure.Management.StreamAnalytics.dll</HintPath>
7070
</Reference>
7171
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7272
<SpecificVersion>False</SpecificVersion>
@@ -197,6 +197,9 @@
197197
<None Include="packages.config">
198198
<SubType>Designer</SubType>
199199
</None>
200+
<None Include="Resources\Function.json">
201+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
202+
</None>
200203
<None Include="Resources\Job.json">
201204
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
202205
</None>
@@ -206,6 +209,9 @@
206209
<None Include="Resources\Output.json">
207210
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
208211
</None>
212+
<None Include="Resources\RetrieveDefaultFunctionDefinitionRequest.json">
213+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
214+
</None>
209215
<None Include="Resources\Transformation.json">
210216
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
211217
</None>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "scoreTweet",
3+
"properties": {
4+
"type": "Scalar",
5+
"properties": {
6+
"inputs": [
7+
{
8+
"dataType": "nvarchar(max)",
9+
"isConfigurationParameter": false
10+
}
11+
],
12+
"output": {
13+
"dataType": "nvarchar(max)"
14+
},
15+
"binding": {
16+
"type": "Microsoft.MachineLearning/WebService",
17+
"properties": {
18+
"endpoint": "https://ussouthcentral.services.azureml.net/workspaces/f80d5d7a77fa4a46bf2a30c63c078dca/services/b7be5e40fd194258896fb602c1858eaf/execute?api-version=2.0&details=true",
19+
"apiKey": "$EncryptedStringForTesting",
20+
"inputs": {
21+
"name": "input1",
22+
"columnNames": [
23+
{
24+
"name": "tweet",
25+
"dataType": "String",
26+
"mapTo": 0
27+
}
28+
]
29+
},
30+
"outputs": [
31+
{
32+
"name": "Sentiment",
33+
"dataType": "String"
34+
}
35+
],
36+
"batchSize": 10
37+
}
38+
}
39+
}
40+
}
41+
}
Lines changed: 96 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,104 @@
11
{
2-
"location": "West US",
3-
"tags": { "key": "value" },
2+
"location": "West US",
3+
"tags": { "key": "value" },
44

5-
"properties": {
6-
"sku": {
7-
"name": "standard"
8-
},
9-
"inputs": [
10-
{
11-
"name": "Input",
12-
"properties": {
13-
"type": "stream",
14-
"serialization": {
15-
"type": "JSON",
16-
"properties": {
17-
"encoding": "UTF8"
5+
"properties": {
6+
"sku": {
7+
"name": "standard"
8+
},
9+
"inputs": [
10+
{
11+
"name": "Input",
12+
"properties": {
13+
"type": "stream",
14+
"serialization": {
15+
"type": "JSON",
16+
"properties": {
17+
"encoding": "UTF8"
18+
}
19+
},
20+
"datasource": {
21+
"type": "Microsoft.Storage/Blob",
22+
"properties": {
23+
"storageAccounts": [
24+
{
25+
"accountName": "azurenrtdogfood",
26+
"accountKey": "$EncryptedStringForTesting"
27+
}
28+
],
29+
"container": "samples",
30+
"pathPattern": ""
31+
}
32+
}
33+
}
1834
}
19-
},
20-
"datasource": {
21-
"type": "Microsoft.Storage/Blob",
35+
],
36+
"transformation": {
37+
"name": "transform1",
2238
"properties": {
23-
"storageAccounts" : [
24-
{
25-
"accountName": "azurenrtdogfood",
26-
"accountKey": "$EncryptedStringForTesting"
39+
"streamingUnits": 1,
40+
"query": "select Id, Name from Input"
41+
}
42+
},
43+
"outputs": [
44+
{
45+
"name": "Output",
46+
"properties": {
47+
"datasource": {
48+
"type": "Microsoft.Sql/Server/Database",
49+
"properties": {
50+
"server": "$EncryptedStringForTesting.database.windows.net",
51+
"database": "azurenrtsql",
52+
"user": "azurenrt@$EncryptedStringForTesting",
53+
"password": "$EncryptedStringForTesting",
54+
"table": "Samples"
55+
}
56+
}
2757
}
28-
],
29-
"container": "samples",
30-
"pathPattern": ""
3158
}
32-
}
33-
}
34-
}
35-
],
36-
"transformation": {
37-
"name": "transform1",
38-
"properties": {
39-
"streamingUnits": 1,
40-
"query": "select Id, Name from Input"
41-
}
42-
},
43-
"outputs": [
44-
{
45-
"name": "Output",
46-
"properties": {
47-
"datasource": {
48-
"type": "Microsoft.Sql/Server/Database",
49-
"properties": {
50-
"server": "$EncryptedStringForTesting.database.windows.net",
51-
"database": "azurenrtsql",
52-
"user": "azurenrt@$EncryptedStringForTesting",
53-
"password": "$EncryptedStringForTesting",
54-
"table": "Samples"
59+
],
60+
"functions": [
61+
{
62+
"name": "scoreTweet",
63+
"properties": {
64+
"type": "Scalar",
65+
"properties": {
66+
"inputs": [
67+
{
68+
"dataType": "nvarchar(max)",
69+
"isConfigurationParameter": false
70+
}
71+
],
72+
"output": {
73+
"dataType": "nvarchar(max)"
74+
},
75+
"binding": {
76+
"type": "Microsoft.MachineLearning/WebService",
77+
"properties": {
78+
"endpoint": "https://ussouthcentral.services.azureml.net/workspaces/f80d5d7a77fa4a46bf2a30c63c078dca/services/b7be5e40fd194258896fb602c1858eaf/execute?api-version=2.0&details=true",
79+
"apiKey": "$EncryptedStringForTesting",
80+
"inputs": {
81+
"name": "input1",
82+
"columnNames": [
83+
{
84+
"name": "tweet",
85+
"dataType": "String",
86+
"mapTo": 0
87+
}
88+
]
89+
},
90+
"outputs": [
91+
{
92+
"name": "Sentiment",
93+
"dataType": "String"
94+
}
95+
],
96+
"batchSize": 10
97+
}
98+
}
99+
}
100+
}
55101
}
56-
}
57-
}
58-
}
59-
]
60-
}
102+
]
103+
}
61104
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"bindingType": "Microsoft.MachineLearning/WebService",
3+
"bindingRetrievalProperties": {
4+
"executeEndpoint": "https://ussouthcentral.services.azureml.net/workspaces/f80d5d7a77fa4a46bf2a30c63c078dca/services/b7be5e40fd194258896fb602c1858eaf/execute?api-version=2.0&details=true",
5+
"udfType": "Scalar"
6+
}
7+
}
8+

src/ResourceManager/StreamAnalytics/Commands.StreamAnalytics.Test/ScenarioTests/EndToEndTests.ps1

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ function Test-TestStreamingAnalyticsE2E
2323
$inputName = "Input"
2424
$outputName = "Output"
2525
$transformationName = "transform1"
26+
$functionName = "scoreTweet"
2627

2728
# Create Job
2829
$actual = New-AzureRmStreamAnalyticsJob -File .\Resources\job.json -ResourceGroupName $resourceGroup -Name $jobName -Force
@@ -41,6 +42,10 @@ function Test-TestStreamingAnalyticsE2E
4142
$actual = Get-AzureRmStreamAnalyticsTransformation -JobName $jobName -Name $transformationName -ResourceGroupName $resourceGroup
4243
Assert-AreEqual $transformationName $actual.Name
4344

45+
# Get Job function
46+
$actual = Get-AzureRmStreamAnalyticsFunction -JobName $jobName -Name $functionName -ResourceGroupName $resourceGroup
47+
Assert-AreEqual $functionName $actual.Name
48+
4449
# New Input (Patch)
4550
$actual = New-AzureRmStreamAnalyticsInput -File .\Resources\Input.json -JobName $jobName -ResourceGroupName $resourceGroup -Force
4651
Assert-AreEqual $inputName $actual.Name
@@ -63,6 +68,15 @@ function Test-TestStreamingAnalyticsE2E
6368
$actual = New-AzureRmStreamAnalyticsTransformation -File .\Resources\Transformation.json -JobName $jobName -ResourceGroupName $resourceGroup -Force
6469
Assert-AreEqual $transformationName $actual.Name
6570

71+
# New Function (Patch)
72+
$actual = New-AzureRmStreamAnalyticsFunction -File .\Resources\Function.json -JobName $jobName -ResourceGroupName $resourceGroup -Force
73+
Assert-AreEqual $functionName $actual.Name
74+
75+
# Test Function
76+
$actual = Test-AzureRmStreamAnalyticsFunction -JobName $jobName -Name $functionName -ResourceGroupName $resourceGroup
77+
$expected = "True"
78+
Assert-AreEqual $expected $actual
79+
6680
# Get Quota
6781
$actual = Get-AzureRmStreamAnalyticsQuota -Location "West US"
6882
$expected = 0
@@ -90,6 +104,15 @@ function Test-TestStreamingAnalyticsE2E
90104
$expected = "True"
91105
Assert-AreEqual $expected $actual
92106

107+
# Get Function Default Definition
108+
$actual = Get-AzureRmStreamAnalyticsDefaultFunctionDefinition -File .\Resources\RetrieveDefaultFunctionDefinitionRequest.json -Name $functionName -JobName $jobName -ResourceGroupName $resourceGroup
109+
Assert-AreEqual $functionName $actual.Name
110+
111+
# Remove Function
112+
$actual = Remove-AzureRmStreamAnalyticsFunction -JobName $jobName -Name $functionName -ResourceGroupName $resourceGroup -Force
113+
$expected = "True"
114+
Assert-AreEqual $expected $actual
115+
93116
# Remove Output
94117
$actual = Remove-AzureRmStreamAnalyticsOutput -JobName $jobName -Name Output -ResourceGroupName $resourceGroup -Force
95118
$expected = "True"

0 commit comments

Comments
 (0)