or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

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

resource-management.mddocs/

0

# Resource Management

1

2

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.

3

4

## Capabilities

5

6

### IoT Hub Resource CRUD Operations

7

8

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

9

10

```python { .api }

11

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

12

"""

13

Get the non-security related metadata of an IoT hub.

14

15

Args:

16

resource_group_name: Name of the resource group containing the IoT hub

17

resource_name: Name of the IoT hub resource

18

19

Returns:

20

IotHubDescription: Complete IoT hub resource metadata without security details

21

"""

22

23

def begin_create_or_update(

24

resource_group_name: str,

25

resource_name: str,

26

iot_hub_description: IotHubDescription,

27

if_match: Optional[str] = None,

28

**kwargs

29

) -> LROPoller[IotHubDescription]:

30

"""

31

Create or update the metadata of an IoT hub (Long Running Operation).

32

33

Args:

34

resource_group_name: Name of the resource group

35

resource_name: Name of the IoT hub resource

36

iot_hub_description: IoT hub metadata and configuration

37

if_match: ETag for conditional updates (optional)

38

39

Returns:

40

LROPoller[IotHubDescription]: Long-running operation poller

41

"""

42

43

def begin_update(

44

resource_group_name: str,

45

resource_name: str,

46

iot_hub_tags: TagsResource,

47

**kwargs

48

) -> LROPoller[IotHubDescription]:

49

"""

50

Update an existing IoT Hub's tags only (Long Running Operation).

51

52

Args:

53

resource_group_name: Name of the resource group

54

resource_name: Name of the IoT hub resource

55

iot_hub_tags: Resource tags to update

56

57

Returns:

58

LROPoller[IotHubDescription]: Long-running operation poller

59

"""

60

61

def begin_delete(

62

resource_group_name: str,

63

resource_name: str,

64

**kwargs

65

) -> LROPoller[IotHubDescription]:

66

"""

67

Delete an IoT hub (Long Running Operation).

68

69

Args:

70

resource_group_name: Name of the resource group

71

resource_name: Name of the IoT hub resource

72

73

Returns:

74

LROPoller[IotHubDescription]: Long-running operation poller

75

"""

76

```

77

78

### IoT Hub Listing Operations

79

80

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

81

82

```python { .api }

83

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

84

"""

85

Get all IoT hubs in a subscription.

86

87

Returns:

88

ItemPaged[IotHubDescription]: Paginated list of IoT hub resources

89

"""

90

91

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

92

"""

93

Get all IoT hubs in a resource group.

94

95

Args:

96

resource_group_name: Name of the resource group

97

98

Returns:

99

ItemPaged[IotHubDescription]: Paginated list of IoT hub resources

100

"""

101

```

102

103

### SKU and Capacity Management

104

105

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

106

107

```python { .api }

108

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

109

"""

110

Get list of valid SKUs for an IoT hub.

111

112

Args:

113

resource_group_name: Name of the resource group

114

resource_name: Name of the IoT hub resource

115

116

Returns:

117

ItemPaged[IotHubSkuDescription]: Available SKU options with pricing tiers

118

"""

119

```

120

121

### Name Validation

122

123

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

124

125

```python { .api }

126

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

127

"""

128

Check if an IoT hub name is available.

129

130

Args:

131

operation_inputs: Name availability check parameters

132

133

Returns:

134

IotHubNameAvailabilityInfo: Availability status and reason if unavailable

135

"""

136

```

137

138

## Usage Examples

139

140

### Creating a new IoT Hub

141

142

```python

143

from azure.identity import DefaultAzureCredential

144

from azure.mgmt.iothub import IotHubClient

145

from azure.mgmt.iothub.models import (

146

IotHubDescription, IotHubSkuInfo, IotHubProperties,

147

IotHubSku, PublicNetworkAccess, Capabilities

148

)

149

150

credential = DefaultAzureCredential()

151

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

152

153

# Define IoT Hub configuration

154

hub_description = IotHubDescription(

155

location="East US",

156

sku=IotHubSkuInfo(

157

name=IotHubSku.S1,

158

capacity=1

159

),

160

properties=IotHubProperties(

161

public_network_access=PublicNetworkAccess.ENABLED,

162

features=Capabilities.NONE,

163

comments="Production IoT Hub for device telemetry"

164

),

165

tags={

166

"environment": "production",

167

"project": "iot-platform"

168

}

169

)

170

171

# Create IoT Hub (long-running operation)

172

create_operation = client.iot_hub_resource.begin_create_or_update(

173

"my-resource-group",

174

"my-iot-hub",

175

hub_description

176

)

177

178

# Wait for completion

179

hub = create_operation.result()

180

print(f"Created IoT Hub: {hub.name} in {hub.location}")

181

```

182

183

### Updating IoT Hub tags

184

185

```python

186

from azure.mgmt.iothub.models import TagsResource

187

188

# Update only tags

189

tags = TagsResource(tags={

190

"environment": "production",

191

"project": "iot-platform",

192

"cost-center": "engineering"

193

})

194

195

update_operation = client.iot_hub_resource.begin_update(

196

"my-resource-group",

197

"my-iot-hub",

198

tags

199

)

200

201

updated_hub = update_operation.result()

202

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

203

```

204

205

### Listing IoT Hubs with filtering

206

207

```python

208

# List all hubs in subscription

209

all_hubs = list(client.iot_hub_resource.list_by_subscription())

210

print(f"Total IoT Hubs in subscription: {len(all_hubs)}")

211

212

# Filter by resource group

213

rg_hubs = list(client.iot_hub_resource.list_by_resource_group("my-resource-group"))

214

for hub in rg_hubs:

215

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

216

```

217

218

## Types

219

220

```python { .api }

221

class TagsResource:

222

"""

223

Resource tags update payload.

224

225

Attributes:

226

tags: Dictionary of tag key-value pairs

227

"""

228

tags: Optional[Dict[str, str]]

229

230

class IotHubNameAvailabilityInfo:

231

"""

232

IoT Hub name availability check result.

233

234

Attributes:

235

name_available: Whether the name is available

236

reason: Reason if name is unavailable

237

message: Detailed message about availability status

238

"""

239

name_available: Optional[bool]

240

reason: Optional[IotHubNameUnavailabilityReason]

241

message: Optional[str]

242

243

class IotHubSkuDescription:

244

"""

245

Available SKU option for IoT Hub.

246

247

Attributes:

248

resource_type: Resource type (readonly)

249

sku: SKU information including name, tier, and capacity

250

capacity: Capacity configuration options

251

"""

252

resource_type: Optional[str]

253

sku: Optional[IotHubSkuInfo]

254

capacity: Optional[IotHubCapacity]

255

256

class OperationInputs:

257

"""

258

Name availability check parameters.

259

260

Attributes:

261

name: IoT Hub name to check

262

"""

263

name: str

264

```