or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

tessl/pypi-azure-mgmt-servicebus

Microsoft Azure Service Bus Management Client Library for programmatic control of Service Bus namespaces, queues, topics, subscriptions, and authorization rules

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

To install, run

npx @tessl/cli install tessl/pypi-azure-mgmt-servicebus@9.0.0

0

# Azure Service Bus Management Client

1

2

A comprehensive Python client library for managing Azure Service Bus resources through the Azure Resource Manager API. This library enables programmatic creation, configuration, and management of Service Bus namespaces, queues, topics, subscriptions, and authorization rules within Azure subscriptions.

3

4

## Package Information

5

6

- **Package Name**: azure-mgmt-servicebus

7

- **Language**: Python

8

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

9

- **Additional Requirements**: `pip install azure-identity` (for authentication)

10

11

## Core Imports

12

13

```python

14

from azure.mgmt.servicebus import ServiceBusManagementClient

15

from azure.identity import DefaultAzureCredential

16

from azure.core.polling import LROPoller

17

```

18

19

Async client:

20

21

```python

22

from azure.mgmt.servicebus.aio import ServiceBusManagementClient

23

from azure.identity.aio import DefaultAzureCredential

24

from azure.core.polling import LROPoller

25

```

26

27

## Basic Usage

28

29

```python

30

from azure.mgmt.servicebus import ServiceBusManagementClient

31

from azure.identity import DefaultAzureCredential

32

import os

33

34

# Initialize the client

35

credential = DefaultAzureCredential()

36

subscription_id = os.getenv("AZURE_SUBSCRIPTION_ID")

37

client = ServiceBusManagementClient(credential, subscription_id)

38

39

# Create a namespace

40

namespace_params = {

41

"location": "East US",

42

"sku": {

43

"name": "Standard",

44

"tier": "Standard"

45

}

46

}

47

48

namespace_operation = client.namespaces.begin_create_or_update(

49

resource_group_name="my-resource-group",

50

namespace_name="my-servicebus-namespace",

51

parameters=namespace_params

52

)

53

54

# Wait for the operation to complete

55

namespace = namespace_operation.result()

56

57

# Create a queue

58

queue_params = {

59

"max_size_in_megabytes": 5120,

60

"default_message_time_to_live": "P14D" # 14 days

61

}

62

63

queue = client.queues.create_or_update(

64

resource_group_name="my-resource-group",

65

namespace_name="my-servicebus-namespace",

66

queue_name="my-queue",

67

parameters=queue_params

68

)

69

70

# Close the client

71

client.close()

72

```

73

74

## Architecture

75

76

The Azure Service Bus Management Client follows the Azure SDK design principles:

77

78

- **Multi-API Version Support**: Supports multiple Service Bus API versions (2021-11-01 default, 2022-10-01-preview)

79

- **Operation Groups**: Organizes functionality into logical operation groups (namespaces, queues, topics, etc.)

80

- **ARM Integration**: Built on Azure Resource Manager (ARM) patterns with long-running operation support

81

- **Authentication**: Uses Azure Active Directory token-based authentication via `azure.identity`

82

- **Async Support**: Provides both synchronous and asynchronous client implementations

83

84

## Capabilities

85

86

### Namespace Management

87

88

Comprehensive namespace lifecycle management including creation, configuration, monitoring, network security, and disaster recovery setup.

89

90

```python { .api }

91

class NamespacesOperations:

92

def list(self) -> ItemPaged[SBNamespace]: ...

93

def list_by_resource_group(self, resource_group_name: str) -> ItemPaged[SBNamespace]: ...

94

def begin_create_or_update(self, resource_group_name: str, namespace_name: str, parameters: SBNamespace) -> LROPoller[SBNamespace]: ...

95

def get(self, resource_group_name: str, namespace_name: str) -> SBNamespace: ...

96

def begin_delete(self, resource_group_name: str, namespace_name: str) -> LROPoller[None]: ...

97

def check_name_availability(self, parameters: CheckNameAvailability) -> CheckNameAvailabilityResult: ...

98

```

99

100

[Namespace Management](./namespace-management.md)

101

102

### Queue Operations

103

104

Queue lifecycle management, configuration, and authorization rule management for point-to-point messaging scenarios.

105

106

```python { .api }

107

class QueuesOperations:

108

def list_by_namespace(self, resource_group_name: str, namespace_name: str) -> ItemPaged[SBQueue]: ...

109

def create_or_update(self, resource_group_name: str, namespace_name: str, queue_name: str, parameters: SBQueue) -> SBQueue: ...

110

def get(self, resource_group_name: str, namespace_name: str, queue_name: str) -> SBQueue: ...

111

def delete(self, resource_group_name: str, namespace_name: str, queue_name: str) -> None: ...

112

```

113

114

[Queue Operations](./queue-operations.md)

115

116

### Topic and Subscription Management

117

118

Topic creation and management, subscription handling, and message filtering rules for publish-subscribe messaging patterns.

119

120

```python { .api }

121

class TopicsOperations:

122

def list_by_namespace(self, resource_group_name: str, namespace_name: str) -> ItemPaged[SBTopic]: ...

123

def create_or_update(self, resource_group_name: str, namespace_name: str, topic_name: str, parameters: SBTopic) -> SBTopic: ...

124

def get(self, resource_group_name: str, namespace_name: str, topic_name: str) -> SBTopic: ...

125

def delete(self, resource_group_name: str, namespace_name: str, topic_name: str) -> None: ...

126

127

class SubscriptionsOperations:

128

def list_by_topic(self, resource_group_name: str, namespace_name: str, topic_name: str) -> ItemPaged[SBSubscription]: ...

129

def create_or_update(self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, parameters: SBSubscription) -> SBSubscription: ...

130

def get(self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str) -> SBSubscription: ...

131

def delete(self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str) -> None: ...

132

```

133

134

[Topic and Subscription Management](./topic-subscription-management.md)

135

136

### Message Filtering Rules

137

138

Message filtering and routing configuration using SQL filters and correlation filters for subscription-based message processing.

139

140

```python { .api }

141

class RulesOperations:

142

def list_by_subscriptions(self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str) -> ItemPaged[Rule]: ...

143

def create_or_update(self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, rule_name: str, parameters: Rule) -> Rule: ...

144

def get(self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, rule_name: str) -> Rule: ...

145

def delete(self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, rule_name: str) -> None: ...

146

```

147

148

[Message Filtering Rules](./message-filtering-rules.md)

149

150

### Authorization and Security

151

152

Access control through authorization rules, access key management, private endpoint configuration, and network security rules.

153

154

```python { .api }

155

def list_authorization_rules(self, resource_group_name: str, namespace_name: str) -> ItemPaged[SBAuthorizationRule]: ...

156

def create_or_update_authorization_rule(self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: SBAuthorizationRule) -> SBAuthorizationRule: ...

157

def list_keys(self, resource_group_name: str, namespace_name: str, authorization_rule_name: str) -> AccessKeys: ...

158

def regenerate_keys(self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: RegenerateAccessKeyParameters) -> AccessKeys: ...

159

```

160

161

[Authorization and Security](./authorization-security.md)

162

163

### Disaster Recovery

164

165

Geo-disaster recovery configuration, pairing management, failover operations, and data replication control.

166

167

```python { .api }

168

class DisasterRecoveryConfigsOperations:

169

def list(self, resource_group_name: str, namespace_name: str) -> ItemPaged[ArmDisasterRecovery]: ...

170

def create_or_update(self, resource_group_name: str, namespace_name: str, alias: str, parameters: ArmDisasterRecovery) -> ArmDisasterRecovery: ...

171

def get(self, resource_group_name: str, namespace_name: str, alias: str) -> ArmDisasterRecovery: ...

172

def break_pairing(self, resource_group_name: str, namespace_name: str, alias: str) -> None: ...

173

def fail_over(self, resource_group_name: str, namespace_name: str, alias: str) -> None: ...

174

```

175

176

[Disaster Recovery](./disaster-recovery.md)

177

178

### Migration and Monitoring

179

180

Standard to Premium namespace migration operations and operational monitoring through operation listings and private networking.

181

182

```python { .api }

183

class MigrationConfigsOperations:

184

def create_and_start_migration(self, resource_group_name: str, namespace_name: str, config_name: str, parameters: MigrationConfigProperties) -> LROPoller[MigrationConfigProperties]: ...

185

def complete_migration(self, resource_group_name: str, namespace_name: str, config_name: str) -> None: ...

186

def revert(self, resource_group_name: str, namespace_name: str, config_name: str) -> None: ...

187

188

class Operations:

189

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

190

```

191

192

[Migration and Monitoring](./migration-monitoring.md)

193

194

## Core Types

195

196

```python { .api }

197

class ServiceBusManagementClient:

198

def __init__(

199

self,

200

credential: TokenCredential,

201

subscription_id: str,

202

api_version: Optional[str] = None,

203

base_url: Optional[str] = None,

204

**kwargs: Any

205

): ...

206

207

# Operation group properties

208

disaster_recovery_configs: DisasterRecoveryConfigsOperations

209

migration_configs: MigrationConfigsOperations

210

namespaces: NamespacesOperations

211

operations: Operations

212

private_endpoint_connections: PrivateEndpointConnectionsOperations

213

private_link_resources: PrivateLinkResourcesOperations

214

queues: QueuesOperations

215

rules: RulesOperations

216

subscriptions: SubscriptionsOperations

217

topics: TopicsOperations

218

219

def close(self) -> None: ...

220

def __enter__(self) -> "ServiceBusManagementClient": ...

221

def __exit__(self, *exc_details) -> None: ...

222

223

class SBNamespace:

224

def __init__(self, **kwargs): ...

225

226

# Standard Azure resource properties

227

id: Optional[str]

228

name: Optional[str]

229

type: Optional[str]

230

location: Optional[str]

231

tags: Optional[Dict[str, str]]

232

233

# Service Bus specific properties

234

sku: Optional[SBSku]

235

identity: Optional[Identity]

236

provisioning_state: Optional[str]

237

status: Optional[str]

238

created_at: Optional[datetime]

239

updated_at: Optional[datetime]

240

service_bus_endpoint: Optional[str]

241

zone_redundant: Optional[bool]

242

encryption: Optional[Encryption]

243

private_endpoint_connections: Optional[List[PrivateEndpointConnection]]

244

disable_local_auth: Optional[bool]

245

alternate_name: Optional[str]

246

247

class SBSku:

248

def __init__(self, **kwargs): ...

249

250

name: Union[str, SkuName] # "Basic", "Standard", "Premium"

251

tier: Optional[Union[str, SkuTier]] # "Basic", "Standard", "Premium"

252

capacity: Optional[int] # 1, 2, 4 for Premium; ignored for Basic/Standard

253

254

from enum import Enum

255

256

class SkuName(str, Enum):

257

BASIC = "Basic"

258

STANDARD = "Standard"

259

PREMIUM = "Premium"

260

261

class SkuTier(str, Enum):

262

BASIC = "Basic"

263

STANDARD = "Standard"

264

PREMIUM = "Premium"

265

266

class EntityStatus(str, Enum):

267

ACTIVE = "Active"

268

DISABLED = "Disabled"

269

RESTORING = "Restoring"

270

SEND_DISABLED = "SendDisabled"

271

RECEIVE_DISABLED = "ReceiveDisabled"

272

CREATING = "Creating"

273

DELETING = "Deleting"

274

RENAMING = "Renaming"

275

UNKNOWN = "Unknown"

276

277

class AccessRights(str, Enum):

278

MANAGE = "Manage"

279

SEND = "Send"

280

LISTEN = "Listen"

281

```

282

283

## Error Handling

284

285

The client uses standard Azure SDK error handling patterns. Common exceptions include:

286

287

- `HttpResponseError`: For HTTP-level errors (4xx, 5xx responses)

288

- `ResourceNotFoundError`: When requested resources don't exist

289

- `ResourceExistsError`: When trying to create resources that already exist

290

- `ClientAuthenticationError`: For authentication failures

291

292

```python

293

from azure.core.exceptions import HttpResponseError, ResourceNotFoundError

294

295

try:

296

namespace = client.namespaces.get("resource-group", "namespace-name")

297

except ResourceNotFoundError:

298

print("Namespace not found")

299

except HttpResponseError as e:

300

print(f"HTTP error: {e.status_code} - {e.message}")

301

```