CtrlK
BlogDocsLog inGet started
Tessl Logo

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

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

resource-management.mddocs/

Resource Management

Core lifecycle operations for Azure IoT Hub resources including creation, configuration updates, deletion, and listing. This module provides comprehensive resource management capabilities with support for long-running operations, ETag-based concurrency control, and detailed resource configuration.

Capabilities

IoT Hub Resource CRUD Operations

Full lifecycle management for IoT Hub resources with support for complex configurations including SKU settings, networking, security policies, and feature enablement.

def get(resource_group_name: str, resource_name: str, **kwargs) -> IotHubDescription:
    """
    Get the non-security related metadata of an IoT hub.
    
    Args:
        resource_group_name: Name of the resource group containing the IoT hub
        resource_name: Name of the IoT hub resource
        
    Returns:
        IotHubDescription: Complete IoT hub resource metadata without security details
    """

def begin_create_or_update(
    resource_group_name: str, 
    resource_name: str, 
    iot_hub_description: IotHubDescription, 
    if_match: Optional[str] = None, 
    **kwargs
) -> LROPoller[IotHubDescription]:
    """
    Create or update the metadata of an IoT hub (Long Running Operation).
    
    Args:
        resource_group_name: Name of the resource group
        resource_name: Name of the IoT hub resource
        iot_hub_description: IoT hub metadata and configuration
        if_match: ETag for conditional updates (optional)
        
    Returns:
        LROPoller[IotHubDescription]: Long-running operation poller
    """

def begin_update(
    resource_group_name: str, 
    resource_name: str, 
    iot_hub_tags: TagsResource, 
    **kwargs
) -> LROPoller[IotHubDescription]:
    """
    Update an existing IoT Hub's tags only (Long Running Operation).
    
    Args:
        resource_group_name: Name of the resource group
        resource_name: Name of the IoT hub resource
        iot_hub_tags: Resource tags to update
        
    Returns:
        LROPoller[IotHubDescription]: Long-running operation poller
    """

def begin_delete(
    resource_group_name: str, 
    resource_name: str, 
    **kwargs
) -> LROPoller[IotHubDescription]:
    """
    Delete an IoT hub (Long Running Operation).
    
    Args:
        resource_group_name: Name of the resource group
        resource_name: Name of the IoT hub resource
        
    Returns:
        LROPoller[IotHubDescription]: Long-running operation poller
    """

IoT Hub Listing Operations

Discover and enumerate IoT Hub resources across subscription and resource group scopes with automatic pagination support.

def list_by_subscription(**kwargs) -> ItemPaged[IotHubDescription]:
    """
    Get all IoT hubs in a subscription.
    
    Returns:
        ItemPaged[IotHubDescription]: Paginated list of IoT hub resources
    """

def list_by_resource_group(resource_group_name: str, **kwargs) -> ItemPaged[IotHubDescription]:
    """
    Get all IoT hubs in a resource group.
    
    Args:
        resource_group_name: Name of the resource group
        
    Returns:
        ItemPaged[IotHubDescription]: Paginated list of IoT hub resources
    """

SKU and Capacity Management

Query available SKU options and validate scaling configurations for IoT Hub resources.

def get_valid_skus(resource_group_name: str, resource_name: str, **kwargs) -> ItemPaged[IotHubSkuDescription]:
    """
    Get list of valid SKUs for an IoT hub.
    
    Args:
        resource_group_name: Name of the resource group
        resource_name: Name of the IoT hub resource
        
    Returns:
        ItemPaged[IotHubSkuDescription]: Available SKU options with pricing tiers
    """

Name Validation

Validate IoT Hub resource names before creation to ensure compliance with naming rules and availability.

def check_name_availability(operation_inputs: OperationInputs, **kwargs) -> IotHubNameAvailabilityInfo:
    """
    Check if an IoT hub name is available.
    
    Args:
        operation_inputs: Name availability check parameters
        
    Returns:
        IotHubNameAvailabilityInfo: Availability status and reason if unavailable
    """

Usage Examples

Creating a new IoT Hub

from azure.identity import DefaultAzureCredential
from azure.mgmt.iothub import IotHubClient
from azure.mgmt.iothub.models import (
    IotHubDescription, IotHubSkuInfo, IotHubProperties, 
    IotHubSku, PublicNetworkAccess, Capabilities
)

credential = DefaultAzureCredential()
client = IotHubClient(credential, "subscription-id")

# Define IoT Hub configuration
hub_description = IotHubDescription(
    location="East US",
    sku=IotHubSkuInfo(
        name=IotHubSku.S1,
        capacity=1
    ),
    properties=IotHubProperties(
        public_network_access=PublicNetworkAccess.ENABLED,
        features=Capabilities.NONE,
        comments="Production IoT Hub for device telemetry"
    ),
    tags={
        "environment": "production",
        "project": "iot-platform"
    }
)

# Create IoT Hub (long-running operation)
create_operation = client.iot_hub_resource.begin_create_or_update(
    "my-resource-group",
    "my-iot-hub",
    hub_description
)

# Wait for completion
hub = create_operation.result()
print(f"Created IoT Hub: {hub.name} in {hub.location}")

Updating IoT Hub tags

from azure.mgmt.iothub.models import TagsResource

# Update only tags
tags = TagsResource(tags={
    "environment": "production",
    "project": "iot-platform",
    "cost-center": "engineering"
})

update_operation = client.iot_hub_resource.begin_update(
    "my-resource-group",
    "my-iot-hub", 
    tags
)

updated_hub = update_operation.result()
print(f"Updated tags: {updated_hub.tags}")

Listing IoT Hubs with filtering

# List all hubs in subscription
all_hubs = list(client.iot_hub_resource.list_by_subscription())
print(f"Total IoT Hubs in subscription: {len(all_hubs)}")

# Filter by resource group
rg_hubs = list(client.iot_hub_resource.list_by_resource_group("my-resource-group"))
for hub in rg_hubs:
    print(f"Hub: {hub.name}, SKU: {hub.sku.name}, Capacity: {hub.sku.capacity}")

Types

class TagsResource:
    """
    Resource tags update payload.
    
    Attributes:
        tags: Dictionary of tag key-value pairs
    """
    tags: Optional[Dict[str, str]]

class IotHubNameAvailabilityInfo:
    """
    IoT Hub name availability check result.
    
    Attributes:
        name_available: Whether the name is available
        reason: Reason if name is unavailable
        message: Detailed message about availability status
    """
    name_available: Optional[bool]
    reason: Optional[IotHubNameUnavailabilityReason]
    message: Optional[str]

class IotHubSkuDescription:
    """
    Available SKU option for IoT Hub.
    
    Attributes:
        resource_type: Resource type (readonly)
        sku: SKU information including name, tier, and capacity
        capacity: Capacity configuration options
    """
    resource_type: Optional[str]
    sku: Optional[IotHubSkuInfo]
    capacity: Optional[IotHubCapacity]

class OperationInputs:
    """
    Name availability check parameters.
    
    Attributes:
        name: IoT Hub name to check
    """
    name: str

Install with Tessl CLI

npx tessl i tessl/pypi-azure-mgmt-iothub

docs

device-operations.md

event-hub-consumer-groups.md

failover-operations.md

index.md

message-routing.md

monitoring-quotas.md

private-networking.md

resource-management.md

security-management.md

utility-operations.md

tile.json