or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

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

0

# Azure IoT Hub Management Client

1

2

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.

3

4

## Package Information

5

6

- **Package Name**: azure-mgmt-iothub

7

- **Language**: Python

8

- **Installation**: `pip install azure-mgmt-iothub`

9

10

## Core Imports

11

12

```python

13

from azure.mgmt.iothub import IotHubClient

14

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

15

```

16

17

For async operations:

18

19

```python

20

from azure.mgmt.iothub.aio import IotHubClient

21

```

22

23

## Basic Usage

24

25

```python

26

from azure.identity import DefaultAzureCredential

27

from azure.mgmt.iothub import IotHubClient

28

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

29

30

# Initialize client with authentication

31

credential = DefaultAzureCredential()

32

subscription_id = "your-subscription-id"

33

client = IotHubClient(credential, subscription_id)

34

35

# List all IoT Hubs in subscription

36

for hub in client.iot_hub_resource.list_by_subscription():

37

print(f"Hub: {hub.name}, Location: {hub.location}")

38

39

# Get specific IoT Hub

40

hub = client.iot_hub_resource.get("resource-group", "hub-name")

41

print(f"Hub SKU: {hub.sku.name}, Capacity: {hub.sku.capacity}")

42

43

# Get IoT Hub statistics

44

stats = client.iot_hub_resource.get_stats("resource-group", "hub-name")

45

print(f"Total devices: {stats.total_device_count}")

46

```

47

48

## Architecture

49

50

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

51

52

- **IotHubClient**: Main client class supporting multi-API versioning with automatic version selection

53

- **Operation Groups**: Organized by functional area (iot_hub_resource, certificates, etc.)

54

- **Models**: Comprehensive data structures for all IoT Hub resources and configurations

55

- **Long-Running Operations**: Async operations with polling support for resource lifecycle management

56

- **Authentication**: Integrated with Azure Identity for secure access to Azure resources

57

58

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.

59

60

## Capabilities

61

62

### IoT Hub Resource Management

63

64

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.

65

66

```python { .api }

67

def get(resource_group_name: str, resource_name: str, **kwargs) -> IotHubDescription: ...

68

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

69

def begin_delete(resource_group_name: str, resource_name: str, **kwargs) -> LROPoller[IotHubDescription]: ...

70

def list_by_subscription(**kwargs) -> ItemPaged[IotHubDescription]: ...

71

def list_by_resource_group(resource_group_name: str, **kwargs) -> ItemPaged[IotHubDescription]: ...

72

```

73

74

[Resource Management](./resource-management.md)

75

76

### Device and Registry Operations

77

78

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

79

80

```python { .api }

81

def export_devices(resource_group_name: str, resource_name: str, export_devices_parameters: ExportDevicesRequest, **kwargs) -> JobResponse: ...

82

def import_devices(resource_group_name: str, resource_name: str, import_devices_parameters: ImportDevicesRequest, **kwargs) -> JobResponse: ...

83

def get_stats(resource_group_name: str, resource_name: str, **kwargs) -> RegistryStatistics: ...

84

def list_jobs(resource_group_name: str, resource_name: str, **kwargs) -> ItemPaged[JobResponse]: ...

85

```

86

87

[Device Operations](./device-operations.md)

88

89

### Message Routing and Event Processing

90

91

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.

92

93

```python { .api }

94

def test_all_routes(iot_hub_name: str, resource_group_name: str, input: TestAllRoutesInput, **kwargs) -> TestAllRoutesResult: ...

95

def test_route(iot_hub_name: str, resource_group_name: str, input: TestRouteInput, **kwargs) -> TestRouteResult: ...

96

def get_endpoint_health(resource_group_name: str, iot_hub_name: str, **kwargs) -> Iterable[EndpointHealthData]: ...

97

```

98

99

[Message Routing](./message-routing.md)

100

101

### Event Hub Consumer Groups

102

103

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

104

105

```python { .api }

106

def list_event_hub_consumer_groups(resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs) -> ItemPaged[EventHubConsumerGroupInfo]: ...

107

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: ...

108

def delete_event_hub_consumer_group(resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs) -> None: ...

109

```

110

111

[Event Hub Consumer Groups](./event-hub-consumer-groups.md)

112

113

### Security and Access Management

114

115

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

116

117

```python { .api }

118

def list_keys(resource_group_name: str, resource_name: str, **kwargs) -> ItemPaged[SharedAccessSignatureAuthorizationRule]: ...

119

def get_keys_for_key_name(resource_group_name: str, resource_name: str, key_name: str, **kwargs) -> SharedAccessSignatureAuthorizationRule: ...

120

def create_or_update(resource_group_name: str, resource_name: str, certificate_name: str, certificate_description: CertificateDescription, if_match: Optional[str] = None, **kwargs) -> CertificateDescription: ...

121

def verify(resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, certificate_verification_body: CertificateVerificationDescription, **kwargs) -> CertificateDescription: ...

122

```

123

124

[Security Management](./security-management.md)

125

126

### Private Networking

127

128

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

129

130

```python { .api }

131

def list(resource_group_name: str, resource_name: str, **kwargs) -> List[PrivateEndpointConnection]: ...

132

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

133

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

134

```

135

136

[Private Networking](./private-networking.md)

137

138

### Monitoring and Quotas

139

140

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

141

142

```python { .api }

143

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

144

def get_subscription_quota(**kwargs) -> UserSubscriptionQuotaListResult: ...

145

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

146

```

147

148

[Monitoring and Quotas](./monitoring-quotas.md)

149

150

### Failover Operations

151

152

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

153

154

```python { .api }

155

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

156

```

157

158

[Failover Operations](./failover-operations.md)

159

160

### Utility Operations

161

162

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

163

164

```python { .api }

165

def check_name_availability(operation_inputs: OperationInputs, **kwargs) -> IotHubNameAvailabilityInfo: ...

166

def list(**kwargs) -> ItemPaged[Operation]: ...

167

```

168

169

[Utility Operations](./utility-operations.md)

170

171

## Core Types

172

173

```python { .api }

174

class IotHubClient:

175

"""

176

Multi-API client for Azure IoT Hub management operations.

177

178

Args:

179

credential: Azure credential for authentication

180

subscription_id: Azure subscription ID

181

api_version: API version to use (default: 2023-06-30)

182

base_url: Azure management endpoint (default: https://management.azure.com)

183

profile: API profile for operation group versions

184

"""

185

def __init__(

186

self,

187

credential: TokenCredential,

188

subscription_id: str,

189

api_version: Optional[str] = None,

190

base_url: str = "https://management.azure.com",

191

profile: KnownProfiles = KnownProfiles.default,

192

**kwargs

193

): ...

194

195

class IotHubDescription:

196

"""

197

Complete IoT Hub resource representation.

198

199

Attributes:

200

location: Azure region (required)

201

sku: SKU information (required)

202

properties: Hub configuration details

203

identity: Managed identity configuration

204

tags: Resource tags for organization

205

etag: ETag for concurrency control

206

"""

207

location: str

208

sku: IotHubSkuInfo

209

properties: Optional[IotHubProperties]

210

identity: Optional[ArmIdentity]

211

tags: Optional[Dict[str, str]]

212

etag: Optional[str]

213

214

class IotHubSkuInfo:

215

"""

216

IoT Hub pricing tier and capacity configuration.

217

218

Attributes:

219

name: SKU name (F1, S1, S2, S3, B1, B2, B3)

220

tier: Billing tier (Free, Standard, Basic) - readonly

221

capacity: Number of IoT Hub units

222

"""

223

name: IotHubSku

224

tier: Optional[IotHubSkuTier]

225

capacity: Optional[int]

226

227

class IotHubProperties:

228

"""

229

Detailed IoT Hub configuration and runtime properties.

230

231

Attributes:

232

authorization_policies: Shared access policies

233

disable_local_auth: Disable local authentication

234

disable_device_sas: Disable device SAS authentication

235

disable_module_sas: Disable module SAS authentication

236

public_network_access: Network access control

237

ip_filter_rules: IP filtering configuration

238

network_rule_sets: Network rule configuration

239

min_tls_version: Minimum TLS version

240

private_endpoint_connections: Private endpoint connections

241

event_hub_endpoints: Event Hub endpoint configuration

242

routing: Message routing configuration

243

storage_endpoints: Storage endpoint configuration

244

messaging_endpoints: Messaging endpoint configuration

245

enable_file_upload_notifications: File upload notification settings

246

cloud_to_device: Cloud-to-device messaging properties

247

comments: Hub description

248

features: Enabled capabilities

249

"""

250

authorization_policies: Optional[List[SharedAccessSignatureAuthorizationRule]]

251

disable_local_auth: Optional[bool]

252

disable_device_sas: Optional[bool]

253

disable_module_sas: Optional[bool]

254

public_network_access: Optional[PublicNetworkAccess]

255

ip_filter_rules: Optional[List[IpFilterRule]]

256

network_rule_sets: Optional[NetworkRuleSetProperties]

257

min_tls_version: Optional[str]

258

private_endpoint_connections: Optional[List[PrivateEndpointConnection]]

259

event_hub_endpoints: Optional[Dict[str, EventHubProperties]]

260

routing: Optional[RoutingProperties]

261

storage_endpoints: Optional[Dict[str, StorageEndpointProperties]]

262

messaging_endpoints: Optional[Dict[str, MessagingEndpointProperties]]

263

enable_file_upload_notifications: Optional[bool]

264

cloud_to_device: Optional[CloudToDeviceProperties]

265

comments: Optional[str]

266

features: Optional[Capabilities]

267

```