| title | Monitor and manage Azure Stream Analytics jobs with PowerShell |
|---|---|
| description | This article describes how to use Azure PowerShell and cmdlets to monitor and manage Azure Stream Analytics jobs. |
| ms.service | azure-stream-analytics |
| ms.topic | how-to |
| ms.date | 03/28/2017 |
| ms.custom | devx-track-azurepowershell |
Learn how to monitor and manage Stream Analytics resources with Azure PowerShell cmdlets and PowerShell scripting that execute basic Stream Analytics tasks.
[!INCLUDE updated-for-az]
- Create an Azure Resource Group in your subscription. The following is a sample Azure PowerShell script. For Azure PowerShell information, see Install and configure Azure PowerShell;
Azure PowerShell 0.9.8:
# Log in to your Azure account
Add-AzureAccount
# Select the Azure subscription you want to use to create the resource group if you have more han one subscription on your account.
Select-AzureSubscription -SubscriptionName <subscription name>
# If Stream Analytics has not been registered to the subscription, remove remark symbol below (#)to run the Register-AzureProvider cmdlet to register the provider namespace.
#Register-AzureProvider -Force -ProviderNamespace 'Microsoft.StreamAnalytics'
# Create an Azure resource group
New-AzureResourceGroup -Name <YOUR RESOURCE GROUP NAME> -Location <LOCATION>Azure PowerShell 1.0:
# Log in to your Azure account
Connect-AzAccount
# Select the Azure subscription you want to use to create the resource group.
Get-AzSubscription -SubscriptionName "your sub" | Select-AzSubscription
# If Stream Analytics has not been registered to the subscription, remove remark symbol below (#)to run the Register-AzureProvider cmdlet to register the provider namespace.
#Register-AzResourceProvider -Force -ProviderNamespace 'Microsoft.StreamAnalytics'
# Create an Azure resource group
New-AzResourceGroup -Name <YOUR RESOURCE GROUP NAME> -Location <LOCATION>Note
Stream Analytics jobs created programmatically do not have monitoring enabled by default. You can manually enable monitoring in the Azure portal by navigating to the job's Monitor page and clicking the Enable button or you can do this programmatically by following the steps located at Azure Stream Analytics - Monitor Stream Analytics Jobs Programmatically.
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.
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:
Get-AzureStreamAnalyticsJobAzure PowerShell 1.0:
Get-AzStreamAnalyticsJobThis PowerShell command returns information about all the Stream Analytics jobs in the Azure subscription.
Example 2
Azure PowerShell 0.9.8:
Get-AzureStreamAnalyticsJob -ResourceGroupName StreamAnalytics-Default-Central-US Azure PowerShell 1.0:
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.
Example 3
Azure PowerShell 0.9.8:
Get-AzureStreamAnalyticsJob -ResourceGroupName StreamAnalytics-Default-Central-US -Name StreamingJobAzure PowerShell 1.0:
Get-AzStreamAnalyticsJob -ResourceGroupName StreamAnalytics-Default-Central-US -Name StreamingJobThis PowerShell command returns information about the Stream Analytics job StreamingJob in the resource group StreamAnalytics-Default-Central-US.
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:
Get-AzureStreamAnalyticsInput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJobAzure PowerShell 1.0:
Get-AzStreamAnalyticsInput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJobThis PowerShell command returns information about all the inputs defined in the job StreamingJob.
Example 2
Azure PowerShell 0.9.8:
Get-AzureStreamAnalyticsInput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob -Name EntryStreamAzure PowerShell 1.0:
Get-AzStreamAnalyticsInput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob -Name EntryStreamThis PowerShell command returns information about the input named EntryStream defined in the job StreamingJob.
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:
Get-AzureStreamAnalyticsOutput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJobAzure PowerShell 1.0:
Get-AzStreamAnalyticsOutput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJobThis PowerShell command returns information about the outputs defined in the job StreamingJob.
Example 2
Azure PowerShell 0.9.8:
Get-AzureStreamAnalyticsOutput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob -Name OutputAzure PowerShell 1.0:
Get-AzStreamAnalyticsOutput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob -Name OutputThis PowerShell command returns information about the output named Output defined in the job StreamingJob.
Gets information about the quota of streaming units in a specified region.
Example 1
Azure PowerShell 0.9.8:
Get-AzureStreamAnalyticsQuota -Location "Central US" Azure PowerShell 1.0:
Get-AzStreamAnalyticsQuota -Location "Central US" This PowerShell command returns information about the quota and usage of streaming units in the Central US region.
Gets information about a specific transformation defined in a Stream Analytics job.
Example 1
Azure PowerShell 0.9.8:
Get-AzureStreamAnalyticsTransformation -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob -Name StreamingJobAzure PowerShell 1.0:
Get-AzStreamAnalyticsTransformation -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob -Name StreamingJobThis PowerShell command returns information about the transformation called StreamingJob in the job StreamingJob.
Creates a new input within a Stream Analytics job, or updates an existing specified input.
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.
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.
If you specify the -Force parameter and specify an existing input name, the input will be replaced without confirmation.
For detailed information on the JSON file structure and contents, refer to the Create Input (Azure Stream Analytics) section of the Stream Analytics Management REST API Reference Library.
Example 1
Azure PowerShell 0.9.8:
New-AzureStreamAnalyticsInput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob -File "C:\Input.json" Azure PowerShell 1.0:
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.
Example 2
Azure PowerShell 0.9.8:
New-AzureStreamAnalyticsInput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob -File "C:\Input.json" -Name EntryStreamAzure PowerShell 1.0:
New-AzStreamAnalyticsInput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob -File "C:\Input.json" -Name EntryStreamThis PowerShell command creates a new input in the job called EntryStream. If an existing input with this name is already defined, the cmdlet will ask whether or not to replace it.
Example 3
Azure PowerShell 0.9.8:
New-AzureStreamAnalyticsInput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob -File "C:\Input.json" -Name EntryStream -ForceAzure PowerShell 1.0:
New-AzStreamAnalyticsInput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob -File "C:\Input.json" -Name EntryStream -ForceThis PowerShell command replaces the definition of the existing input source called EntryStream with the definition from the file.
Creates a new Stream Analytics job in Microsoft Azure, or updates the definition of an existing specified job.
The name of the job 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.
If you specify a job name that already exists and do not specify the -Force parameter, the cmdlet will ask whether or not to replace the existing job.
If you specify the -Force parameter and specify an existing job name, the job definition will be replaced without confirmation.
For detailed information on the JSON file structure and contents, refer to the Create Stream Analytics Job section of the Stream Analytics Management REST API Reference Library.
Example 1
Azure PowerShell 0.9.8:
New-AzureStreamAnalyticsJob -ResourceGroupName StreamAnalytics-Default-Central-US -File "C:\JobDefinition.json" Azure PowerShell 1.0:
New-AzStreamAnalyticsJob -ResourceGroupName StreamAnalytics-Default-Central-US -File "C:\JobDefinition.json" This PowerShell command creates a new job from the definition in JobDefinition.json. If an existing job with the name specified in the job definition file is already defined, the cmdlet will ask whether or not to replace it.
Example 2
Azure PowerShell 0.9.8:
New-AzureStreamAnalyticsJob -ResourceGroupName StreamAnalytics-Default-Central-US -File "C:\JobDefinition.json" -Name StreamingJob -ForceAzure PowerShell 1.0:
New-AzStreamAnalyticsJob -ResourceGroupName StreamAnalytics-Default-Central-US -File "C:\JobDefinition.json" -Name StreamingJob -ForceThis PowerShell command replaces the job definition for StreamingJob.
Creates a new output within a Stream Analytics job, or updates an existing output.
The name of the output 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.
If you specify an output that already exists and do not specify the -Force parameter, the cmdlet will ask whether or not to replace the existing output.
If you specify the -Force parameter and specify an existing output name, the output will be replaced without confirmation.
For detailed information on the JSON file structure and contents, refer to the Create Output (Azure Stream Analytics) section of the Stream Analytics Management REST API Reference Library.
Example 1
Azure PowerShell 0.9.8:
New-AzureStreamAnalyticsOutput -ResourceGroupName StreamAnalytics-Default-Central-US -File "C:\Output.json" -JobName StreamingJob -Name outputAzure PowerShell 1.0:
New-AzStreamAnalyticsOutput -ResourceGroupName StreamAnalytics-Default-Central-US -File "C:\Output.json" -JobName StreamingJob -Name outputThis PowerShell command creates a new output called "output" in the job StreamingJob. If an existing output with this name is already defined, the cmdlet will ask whether or not to replace it.
Example 2
Azure PowerShell 0.9.8:
New-AzureStreamAnalyticsOutput -ResourceGroupName StreamAnalytics-Default-Central-US -File "C:\Output.json" -JobName StreamingJob -Name output -ForceAzure PowerShell 1.0:
New-AzStreamAnalyticsOutput -ResourceGroupName StreamAnalytics-Default-Central-US -File "C:\Output.json" -JobName StreamingJob -Name output -ForceThis PowerShell command replaces the definition for "output" in the job StreamingJob.
Creates a new transformation within a Stream Analytics job, or updates the existing transformation.
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.
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.
If you specify the -Force parameter and specify an existing transformation name, the transformation will be replaced without confirmation.
For detailed information on the JSON file structure and contents, refer to the Create Transformation (Azure Stream Analytics) section of the Stream Analytics Management REST API Reference Library.
Example 1
Azure PowerShell 0.9.8:
New-AzureStreamAnalyticsTransformation -ResourceGroupName StreamAnalytics-Default-Central-US -File "C:\Transformation.json" -JobName StreamingJob -Name StreamingJobTransformAzure PowerShell 1.0:
New-AzStreamAnalyticsTransformation -ResourceGroupName StreamAnalytics-Default-Central-US -File "C:\Transformation.json" -JobName StreamingJob -Name StreamingJobTransformThis 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.
Example 2
Azure PowerShell 0.9.8:
New-AzureStreamAnalyticsTransformation -ResourceGroupName StreamAnalytics-Default-Central-US -File "C:\Transformation.json" -JobName StreamingJob -Name StreamingJobTransform -ForceAzure PowerShell 1.0:
New-AzStreamAnalyticsTransformation -ResourceGroupName StreamAnalytics-Default-Central-US -File "C:\Transformation.json" -JobName StreamingJob -Name StreamingJobTransform -ForceThis PowerShell command replaces the definition of StreamingJobTransform in the job StreamingJob.
Asynchronously deletes a specific input from a Stream Analytics job in Microsoft Azure.
If you specify the -Force parameter, the input will be deleted without confirmation.
Example 1
Azure PowerShell 0.9.8:
Remove-AzureStreamAnalyticsInput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob -Name EventStreamAzure PowerShell 1.0:
Remove-AzStreamAnalyticsInput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob -Name EventStreamThis PowerShell command removes the input EventStream in the job StreamingJob.
Asynchronously deletes a specific Stream Analytics job in Microsoft Azure.
If you specify the -Force parameter, the job will be deleted without confirmation.
Example 1
Azure PowerShell 0.9.8:
Remove-AzureStreamAnalyticsJob -ResourceGroupName StreamAnalytics-Default-Central-US -Name StreamingJob Azure PowerShell 1.0:
Remove-AzStreamAnalyticsJob -ResourceGroupName StreamAnalytics-Default-Central-US -Name StreamingJob This PowerShell command removes the job StreamingJob.
Asynchronously deletes a specific output from a Stream Analytics job in Microsoft Azure.
If you specify the -Force parameter, the output will be deleted without confirmation.
Example 1
Azure PowerShell 0.9.8:
Remove-AzureStreamAnalyticsOutput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob -Name OutputAzure PowerShell 1.0:
Remove-AzStreamAnalyticsOutput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob -Name OutputThis PowerShell command removes the output Output in the job StreamingJob.
Asynchronously deploys and starts a Stream Analytics job in Microsoft Azure.
Example 1
Azure PowerShell 0.9.8:
Start-AzureStreamAnalyticsJob -ResourceGroupName StreamAnalytics-Default-Central-US -Name StreamingJob -OutputStartMode CustomTime -OutputStartTime 2012-12-12T12:12:12ZAzure PowerShell 1.0:
Start-AzStreamAnalyticsJob -ResourceGroupName StreamAnalytics-Default-Central-US -Name StreamingJob -OutputStartMode CustomTime -OutputStartTime 2012-12-12T12:12:12ZThis PowerShell command starts the job StreamingJob with a custom output start time set to December 12, 2012, 12:12:12 UTC.
Asynchronously stops a Stream Analytics job from running in Microsoft Azure and de-allocates resources that were that were being used. 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. You will not be charged for a job in the stopped state.
Example 1
Azure PowerShell 0.9.8:
Stop-AzureStreamAnalyticsJob -ResourceGroupName StreamAnalytics-Default-Central-US -Name StreamingJob Azure PowerShell 1.0:
Stop-AzStreamAnalyticsJob -ResourceGroupName StreamAnalytics-Default-Central-US -Name StreamingJob This PowerShell command stops the job StreamingJob.
Tests the ability of Stream Analytics to connect to a specified input.
Example 1
Azure PowerShell 0.9.8:
Test-AzureStreamAnalyticsInput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob -Name EntryStreamAzure PowerShell 1.0:
Test-AzStreamAnalyticsInput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob -Name EntryStreamThis PowerShell command tests the connection status of the input EntryStream in StreamingJob.
Tests the ability of Stream Analytics to connect to a specified output.
Example 1
Azure PowerShell 0.9.8:
Test-AzureStreamAnalyticsOutput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob -Name OutputAzure PowerShell 1.0:
Test-AzStreamAnalyticsOutput -ResourceGroupName StreamAnalytics-Default-Central-US -JobName StreamingJob -Name OutputThis PowerShell command tests the connection status of the output Output in StreamingJob.
For further assistance, try our Microsoft Q&A question page for Azure Stream Analytics.