Azure Stream Analytics Management Client Library

raw JSON →
1.0.0 verified Fri May 01 auth: no python

Microsoft Azure Stream Analytics Management Client Library for Python. Version 1.0.0 is the first stable release. Allows management of Stream Analytics jobs, inputs, outputs, functions, and transformations via Azure Resource Manager. Released weekly with Azure SDK updates.

pip install azure-mgmt-streamanalytics
error AttributeError: module 'azure.mgmt.streamanalytics' has no attribute 'StreamAnalyticsManagementClient'
cause Incorrect import path due to older version or misspelling.
fix
Use: from azure.mgmt.streamanalytics import StreamAnalyticsManagementClient
error TypeError: __init__() missing 2 required positional arguments: 'credential' and 'subscription_id'
cause Constructor called without required arguments.
fix
client = StreamAnalyticsManagementClient(credential, subscription_id)
error msrestazure.azure_exceptions.CloudError: (AuthorizationFailed) The client '...' with object id '...' does not have authorization to perform action 'Microsoft.StreamAnalytics/streamingjobs/write'
cause Service principal or user lacks Contributor role on the subscription/resource group.
fix
Assign Contributor role for Stream Analytics: az role assignment create --assignee <object-id> --role Contributor --scope /subscriptions/<subscription-id>
gotcha The client constructor expects `credential` as first argument and `subscription_id` as second. Passing them in wrong order raises a confusing TypeError.
fix Always use: StreamAnalyticsManagementClient(credential, subscription_id)
deprecated Methods like `create_or_update` and `get` require `job_name` parameter. Using positional arguments for optional parameters is error-prone.
fix Use keyword arguments for optional parameters: create_or_update(resource_group_name, job_name, job, if_match=None, if_none_match=None)
gotcha The `list` method on `streaming_jobs` returns an iterator, not a list. Calling len() will fail.
fix Convert to list: jobs = list(client.streaming_jobs.list())

Authenticates using DefaultAzureCredential and lists all Stream Analytics jobs in the subscription.

import os
from azure.identity import DefaultAzureCredential
from azure.mgmt.streamanalytics import StreamAnalyticsManagementClient

subscription_id = os.environ.get('AZURE_SUBSCRIPTION_ID', '')
credential = DefaultAzureCredential()
client = StreamAnalyticsManagementClient(credential, subscription_id)

# List all jobs in the subscription
for job in client.streaming_jobs.list():
    print(job.name, job.properties.job_state)