Azure SignalR Management Client Library for Python

1.2.0 · active · verified Thu Apr 09

The `azure-mgmt-signalr` library is the Microsoft Azure SignalR Client Library for Python, enabling programmatic management of Azure SignalR Service resources. It supports operations like creating, updating, deleting, and listing SignalR instances. The current stable version is 1.2.0, released in March 2023. This library is part of the broader Azure SDK for Python, which generally follows a consistent release cadence with frequent updates across its various service-specific packages.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to authenticate with Azure using `DefaultAzureCredential` and list all Azure SignalR Service resources within a specified subscription. Ensure you have the necessary environment variables (`AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`, `AZURE_SUBSCRIPTION_ID`) set for `DefaultAzureCredential` to work.

import os
from azure.identity import DefaultAzureCredential
from azure.mgmt.signalr import SignalRManagementClient

# Set environment variables for authentication and subscription ID
# AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET
# AZURE_SUBSCRIPTION_ID

subscription_id = os.environ.get('AZURE_SUBSCRIPTION_ID', 'your_subscription_id')

if subscription_id == 'your_subscription_id':
    print("Please set the AZURE_SUBSCRIPTION_ID environment variable.")
    exit(1)

try:
    # Authenticate using DefaultAzureCredential
    # This credential will attempt to authenticate via environment variables, managed identity, or Azure CLI.
    credential = DefaultAzureCredential()

    # Create a SignalRManagementClient
    signalr_client = SignalRManagementClient(credential, subscription_id)

    print(f"Listing SignalR resources in subscription: {subscription_id}")

    # List all SignalR services in the subscription
    for resource in signalr_client.signal_r.list_by_subscription():
        print(f"  - SignalR Resource: {resource.name}, Location: {resource.location}")

except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →