or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

device-operations.mdevent-hub-consumer-groups.mdfailover-operations.mdindex.mdmessage-routing.mdmonitoring-quotas.mdprivate-networking.mdresource-management.mdsecurity-management.mdutility-operations.md
tile.json

tessl/pypi-azure-mgmt-iothub

Microsoft Azure IoT Hub Management Client Library for programmatic management of Azure IoT Hub resources through the Azure Resource Manager API

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/azure-mgmt-iothub@4.0.x

To install, run

npx @tessl/cli install tessl/pypi-azure-mgmt-iothub@4.0.0

index.mddocs/

Azure IoT Hub Management Client

A comprehensive Python library for programmatic management of Azure IoT Hub resources through the Azure Resource Manager API. This library enables creation, configuration, monitoring, and management of IoT Hub instances, device operations, routing configurations, security settings, and advanced IoT Hub features including device-to-cloud messaging, cloud-to-device commands, device twin management, direct methods, file uploads, and routing to various Azure services.

Package Information

  • Package Name: azure-mgmt-iothub
  • Language: Python
  • Installation: pip install azure-mgmt-iothub

Core Imports

from azure.mgmt.iothub import IotHubClient
from azure.mgmt.iothub.models import IotHubDescription, IotHubSkuInfo, IotHubProperties

For async operations:

from azure.mgmt.iothub.aio import IotHubClient

Basic Usage

from azure.identity import DefaultAzureCredential
from azure.mgmt.iothub import IotHubClient
from azure.mgmt.iothub.models import IotHubDescription, IotHubSkuInfo, IotHubProperties

# Initialize client with authentication
credential = DefaultAzureCredential()
subscription_id = "your-subscription-id"
client = IotHubClient(credential, subscription_id)

# List all IoT Hubs in subscription
for hub in client.iot_hub_resource.list_by_subscription():
    print(f"Hub: {hub.name}, Location: {hub.location}")

# Get specific IoT Hub
hub = client.iot_hub_resource.get("resource-group", "hub-name")
print(f"Hub SKU: {hub.sku.name}, Capacity: {hub.sku.capacity}")

# Get IoT Hub statistics
stats = client.iot_hub_resource.get_stats("resource-group", "hub-name")
print(f"Total devices: {stats.total_device_count}")

Architecture

The Azure IoT Hub Management Client follows the Azure SDK for Python patterns:

  • IotHubClient: Main client class supporting multi-API versioning with automatic version selection
  • Operation Groups: Organized by functional area (iot_hub_resource, certificates, etc.)
  • Models: Comprehensive data structures for all IoT Hub resources and configurations
  • Long-Running Operations: Async operations with polling support for resource lifecycle management
  • Authentication: Integrated with Azure Identity for secure access to Azure resources

The client supports multiple API versions (2019-03-22, 2019-07-01-preview, 2023-06-30, 2023-06-30-preview) with automatic selection of the latest stable version (2023-06-30) by default.

Capabilities

IoT Hub Resource Management

Core lifecycle operations for Azure IoT Hub resources including creation, updates, deletion, and listing. Supports comprehensive resource configuration including SKU management, networking, security policies, and operational monitoring.

def get(resource_group_name: str, resource_name: str, **kwargs) -> IotHubDescription: ...
def begin_create_or_update(resource_group_name: str, resource_name: str, iot_hub_description: IotHubDescription, if_match: Optional[str] = None, **kwargs) -> LROPoller[IotHubDescription]: ...
def begin_delete(resource_group_name: str, resource_name: str, **kwargs) -> LROPoller[IotHubDescription]: ...
def list_by_subscription(**kwargs) -> ItemPaged[IotHubDescription]: ...
def list_by_resource_group(resource_group_name: str, **kwargs) -> ItemPaged[IotHubDescription]: ...

Resource Management

Device and Registry Operations

Device lifecycle management operations including bulk import/export of device identities, registry statistics, and device-related job management for large-scale IoT deployments.

def export_devices(resource_group_name: str, resource_name: str, export_devices_parameters: ExportDevicesRequest, **kwargs) -> JobResponse: ...
def import_devices(resource_group_name: str, resource_name: str, import_devices_parameters: ImportDevicesRequest, **kwargs) -> JobResponse: ...
def get_stats(resource_group_name: str, resource_name: str, **kwargs) -> RegistryStatistics: ...
def list_jobs(resource_group_name: str, resource_name: str, **kwargs) -> ItemPaged[JobResponse]: ...

Device Operations

Message Routing and Event Processing

Configuration and management of message routing from devices to various Azure services including Event Hubs, Service Bus, Storage, and CosmosDB. Includes routing rule testing and endpoint health monitoring.

def test_all_routes(iot_hub_name: str, resource_group_name: str, input: TestAllRoutesInput, **kwargs) -> TestAllRoutesResult: ...
def test_route(iot_hub_name: str, resource_group_name: str, input: TestRouteInput, **kwargs) -> TestRouteResult: ...
def get_endpoint_health(resource_group_name: str, iot_hub_name: str, **kwargs) -> Iterable[EndpointHealthData]: ...

Message Routing

Event Hub Consumer Groups

Management of Event Hub consumer groups for device-to-cloud message processing, enabling multiple applications to independently process IoT device messages.

def list_event_hub_consumer_groups(resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs) -> ItemPaged[EventHubConsumerGroupInfo]: ...
def create_event_hub_consumer_group(resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, consumer_group_body: EventHubConsumerGroupBodyDescription, **kwargs) -> EventHubConsumerGroupInfo: ...
def delete_event_hub_consumer_group(resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs) -> None: ...

Event Hub Consumer Groups

Security and Access Management

Comprehensive security management including X.509 certificate operations, shared access signature key management, and certificate verification workflows for device authentication.

def list_keys(resource_group_name: str, resource_name: str, **kwargs) -> ItemPaged[SharedAccessSignatureAuthorizationRule]: ...
def get_keys_for_key_name(resource_group_name: str, resource_name: str, key_name: str, **kwargs) -> SharedAccessSignatureAuthorizationRule: ...
def create_or_update(resource_group_name: str, resource_name: str, certificate_name: str, certificate_description: CertificateDescription, if_match: Optional[str] = None, **kwargs) -> CertificateDescription: ...
def verify(resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, certificate_verification_body: CertificateVerificationDescription, **kwargs) -> CertificateDescription: ...

Security Management

Private Networking

Private endpoint and private link resource management for secure, private connectivity to IoT Hub resources within virtual networks.

def list(resource_group_name: str, resource_name: str, **kwargs) -> List[PrivateEndpointConnection]: ...
def begin_update(resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, private_endpoint_connection: PrivateEndpointConnection, **kwargs) -> LROPoller[PrivateEndpointConnection]: ...
def begin_delete(resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs) -> LROPoller[PrivateEndpointConnection]: ...

Private Networking

Monitoring and Quotas

Monitoring capabilities including quota usage tracking, subscription limits, and operational insights for IoT Hub resource management and capacity planning.

def get_quota_metrics(resource_group_name: str, resource_name: str, **kwargs) -> ItemPaged[IotHubQuotaMetricInfo]: ...
def get_subscription_quota(**kwargs) -> UserSubscriptionQuotaListResult: ...
def get_valid_skus(resource_group_name: str, resource_name: str, **kwargs) -> ItemPaged[IotHubSkuDescription]: ...

Monitoring and Quotas

Failover Operations

Manual failover capabilities for IoT Hub disaster recovery, enabling failover to Azure paired regions for business continuity.

def begin_manual_failover(iot_hub_name: str, resource_group_name: str, failover_input: FailoverInput, **kwargs) -> LROPoller[None]: ...

Failover Operations

Utility Operations

Utility operations including name availability checking and REST API operation discovery for IoT Hub management.

def check_name_availability(operation_inputs: OperationInputs, **kwargs) -> IotHubNameAvailabilityInfo: ...
def list(**kwargs) -> ItemPaged[Operation]: ...

Utility Operations

Core Types

class IotHubClient:
    """
    Multi-API client for Azure IoT Hub management operations.
    
    Args:
        credential: Azure credential for authentication
        subscription_id: Azure subscription ID
        api_version: API version to use (default: 2023-06-30)
        base_url: Azure management endpoint (default: https://management.azure.com)
        profile: API profile for operation group versions
    """
    def __init__(
        self,
        credential: TokenCredential,
        subscription_id: str,
        api_version: Optional[str] = None,
        base_url: str = "https://management.azure.com",
        profile: KnownProfiles = KnownProfiles.default,
        **kwargs
    ): ...

class IotHubDescription:
    """
    Complete IoT Hub resource representation.
    
    Attributes:
        location: Azure region (required)
        sku: SKU information (required)
        properties: Hub configuration details
        identity: Managed identity configuration
        tags: Resource tags for organization
        etag: ETag for concurrency control
    """
    location: str
    sku: IotHubSkuInfo
    properties: Optional[IotHubProperties]
    identity: Optional[ArmIdentity]
    tags: Optional[Dict[str, str]]
    etag: Optional[str]

class IotHubSkuInfo:
    """
    IoT Hub pricing tier and capacity configuration.
    
    Attributes:
        name: SKU name (F1, S1, S2, S3, B1, B2, B3)
        tier: Billing tier (Free, Standard, Basic) - readonly
        capacity: Number of IoT Hub units
    """
    name: IotHubSku
    tier: Optional[IotHubSkuTier]
    capacity: Optional[int]

class IotHubProperties:
    """
    Detailed IoT Hub configuration and runtime properties.
    
    Attributes:
        authorization_policies: Shared access policies
        disable_local_auth: Disable local authentication
        disable_device_sas: Disable device SAS authentication
        disable_module_sas: Disable module SAS authentication
        public_network_access: Network access control
        ip_filter_rules: IP filtering configuration
        network_rule_sets: Network rule configuration
        min_tls_version: Minimum TLS version
        private_endpoint_connections: Private endpoint connections
        event_hub_endpoints: Event Hub endpoint configuration
        routing: Message routing configuration
        storage_endpoints: Storage endpoint configuration
        messaging_endpoints: Messaging endpoint configuration
        enable_file_upload_notifications: File upload notification settings
        cloud_to_device: Cloud-to-device messaging properties
        comments: Hub description
        features: Enabled capabilities
    """
    authorization_policies: Optional[List[SharedAccessSignatureAuthorizationRule]]
    disable_local_auth: Optional[bool]
    disable_device_sas: Optional[bool]
    disable_module_sas: Optional[bool]
    public_network_access: Optional[PublicNetworkAccess]
    ip_filter_rules: Optional[List[IpFilterRule]]
    network_rule_sets: Optional[NetworkRuleSetProperties]
    min_tls_version: Optional[str]
    private_endpoint_connections: Optional[List[PrivateEndpointConnection]]
    event_hub_endpoints: Optional[Dict[str, EventHubProperties]]
    routing: Optional[RoutingProperties]
    storage_endpoints: Optional[Dict[str, StorageEndpointProperties]]
    messaging_endpoints: Optional[Dict[str, MessagingEndpointProperties]]
    enable_file_upload_notifications: Optional[bool]
    cloud_to_device: Optional[CloudToDeviceProperties]
    comments: Optional[str]
    features: Optional[Capabilities]