Monitor Stream Analytics
In this we will learn how to monitor and manage Stream Analytics resources with Azure PowerShell cmdlets and powershell scripting that execute basic Stream Analytics tasks.
Azure PowerShell cmdlets for Stream Analytics
The following Azure PowerShell cmdlets can be used to monitor and manage Azure Stream Analytics jobs. Note that Azure PowerShell has different versions. In the examples listed the first command is for Azure PowerShell 0.9.8, the second command is for Azure PowerShell 1.0. The Azure PowerShell 1.0 commands will always have “Az” in the command.
Get-AzureStreamAnalyticsJob | Get-AzStreamAnalyticsJob
Lists all Stream Analytics jobs defined in the Azure subscription or specified resource group, or gets job information about a specific job within a resource group.
Example 1
Azure PowerShell 0.9.8:
PowerShell
Get-AzureStreamAnalyticsJob
Azure PowerShell 1.0:
PowerShell
Get-AzStreamAnalyticsJob
This PowerShell command returns information about all the Stream Analytics jobs in the Azure subscription.
Example 2
Azure PowerShell 0.9.8:
PowerShell
Get-AzureStreamAnalyticsJob -ResourceGroupName StreamAnalytics-Default-Central-US
Azure PowerShell 1.0:
PowerShell
Get-AzStreamAnalyticsJob -ResourceGroupName StreamAnalytics-Default-Central-US
This PowerShell command returns information about all the Stream Analytics jobs in the resource group StreamAnalytics-Default-Central-US.
Get-AzureStreamAnalyticsInput | Get-AzStreamAnalyticsInput
Lists all of the inputs that are defined in a specified Stream Analytics job, or gets information about a specific input
Example 1
Azure PowerShell 0.9.8:
PowerShell
Get-AzureStreamAnalyticsInput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob
Azure PowerShell 1.0:
PowerShell
Get-AzStreamAnalyticsInput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob
This PowerShell command returns information about all the inputs defined in the job StreamingJob.
Get-AzureStreamAnalyticsOutput | Get-AzStreamAnalyticsOutput
Lists all of the outputs that are defined in a specified Stream Analytics job, or gets information about a specific output.
Example 1
Azure PowerShell 0.9.8:
PowerShell
Get-AzureStreamAnalyticsOutput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob
Azure PowerShell 1.0:
PowerShell
Get-AzStreamAnalyticsOutput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob
This PowerShell command returns information about the outputs defined in the job StreamingJob.
New-AzureStreamAnalyticsInput | New-AzStreamAnalyticsInput
- Firstly, creates a new input within a Stream Analytics job, or updates an existing specified input.
- Secondly, the name of the input can be specified in the .json file or on the command line. If both are specified, the name on the command line must be the same as the one in the file.
- Thirdly, if you specify an input that already exists and do not specify the -Force parameter, the cmdlet will ask whether or not to replace the existing input.
- Lastly, if you specify the -Force parameter and specify an existing input name, the input will be replaced without confirmation.
Example 1
Azure PowerShell 0.9.8:
PowerShell
New-AzureStreamAnalyticsInput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob -File “C:\Input.json”
Azure PowerShell 1.0:
PowerShell
New-AzStreamAnalyticsInput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob -File “C:\Input.json”
This PowerShell command creates a new input from the file Input.json. If an existing input with the name specified in the input definition file is already defined, the cmdlet will ask whether or not to replace it.
New-AzureStreamAnalyticsTransformation | New-AzStreamAnalyticsTransformation
- Firstly, creates a new transformation within a Stream Analytics job, or updates the existing transformation.
- Secondly, the name of the transformation can be specified in the .json file or on the command line. If both are specified, the name on the command line must be the same as the one in the file.
- Thirdly, if you specify a transformation that already exists and do not specify the -Force parameter, the cmdlet will ask whether or not to replace the existing transformation.
- Lastly, if you specify the -Force parameter and specify an existing transformation name, the transformation will be replaced without confirmation.
Example 1
Azure PowerShell 0.9.8:
PowerShell
New-AzureStreamAnalyticsTransformation -ResourceGroupName StreamAnalytics-Default-Central-US -File “C:\Transformation.json” -JobName StreamingJob -Name StreamingJobTransform
Azure PowerShell 1.0:
PowerShell
New-AzStreamAnalyticsTransformation -ResourceGroupName StreamAnalytics-Default-Central-US -File “C:\Transformation.json” -JobName StreamingJob -Name StreamingJobTransform
This PowerShell command creates a new transformation called StreamingJobTransform in the job StreamingJob. If an existing transformation is already defined with this name, the cmdlet will ask whether or not to replace it.
Remove-AzureStreamAnalyticsInput | Remove-AzStreamAnalyticsInput
Asynchronously deletes a specific input from a Stream Analytics job in Microsoft Azure. However, if you specify the -Force parameter, the input will be deleted without confirmation.
Example 1
Azure PowerShell 0.9.8:
PowerShell
Remove-AzureStreamAnalyticsInput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob -Name EventStream
Azure PowerShell 1.0:
PowerShell
Remove-AzStreamAnalyticsInput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob -Name EventStream
This PowerShell command removes the input EventStream in the job StreamingJob.
Remove-AzureStreamAnalyticsOutput | Remove-AzStreamAnalyticsOutput
Asynchronously deletes a specific output from a Stream Analytics job in Microsoft Azure. However, if you specify the -Force parameter, the output will be deleted without confirmation.
Example 1
Azure PowerShell 0.9.8:
PowerShell
Remove-AzureStreamAnalyticsOutput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob -Name Output
Azure PowerShell 1.0:
PowerShell
Remove-AzStreamAnalyticsOutput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob -Name Output
This PowerShell command removes the output Output in the job StreamingJob.
Start-AzureStreamAnalyticsJob | Start-AzStreamAnalyticsJob
Asynchronously deploys and starts a Stream Analytics job in Microsoft Azure.
Example 1
Azure PowerShell 0.9.8:
PowerShell
Start-AzureStreamAnalyticsJob -ResourceGroupName StreamAnalytics-Default-Central-US -Name StreamingJob -OutputStartMode CustomTime -OutputStartTime 2012-12-12T12:12:12Z
Azure PowerShell 1.0:
PowerShell
Start-AzStreamAnalyticsJob -ResourceGroupName StreamAnalytics-Default-Central-US -Name StreamingJob -OutputStartMode CustomTime -OutputStartTime 2012-12-12T12:12:12Z
This PowerShell command starts the job StreamingJob with a custom output start time set to December 12, 2012, 12:12:12 UTC.
Stop-AzureStreamAnalyticsJob | Stop-AzStreamAnalyticsJob
Asynchronously stops a Stream Analytics job from running in Microsoft Azure and de-allocates resources that were that were being used. Moreover, the job definition and metadata will remain available within your subscription through both the Azure portal and management APIs, such that the job can be edited and restarted. However, you will not be charged for a job in the stopped state.
Example 1
Azure PowerShell 0.9.8:
PowerShell
Stop-AzureStreamAnalyticsJob -ResourceGroupName StreamAnalytics-Default-Central-US -Name StreamingJob
Azure PowerShell 1.0:
PowerShell
Stop-AzStreamAnalyticsJob -ResourceGroupName StreamAnalytics-Default-Central-US -Name StreamingJob
This PowerShell command stops the job StreamingJob.
Test-AzureStreamAnalyticsInput | Test-AzStreamAnalyticsInput
Tests the ability of Stream Analytics to connect to a specified input.
Example 1
Azure PowerShell 0.9.8:
PowerShell
Test-AzureStreamAnalyticsInput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob -Name EntryStream
Azure PowerShell 1.0:
PowerShell
Test-AzStreamAnalyticsInput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob -Name EntryStream
This PowerShell command tests the connection status of the input EntryStream in StreamingJob.
Reference: Microsoft Documentation