or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

authentication.mdcontainer-groups.mdcontainers.mdindex.mdlocation.mdmodels.mdoperations.mdsubnet-operations.md

index.mddocs/

0

# Azure Container Instance Management Library

1

2

## Overview

3

4

The `azure-mgmt-containerinstance` package provides a comprehensive Python client library for managing Azure Container Instances. It enables developers to programmatically create, configure, and manage containerized applications in the Azure cloud through a complete API wrapper for Azure Container Instance REST endpoints.

5

6

## Package Information

7

8

- **Package Name**: azure-mgmt-containerinstance

9

- **Package Type**: pypi

10

- **Language**: Python

11

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

12

13

14

## Core Imports

15

16

```python

17

# Main client

18

from azure.mgmt.containerinstance import ContainerInstanceManagementClient

19

20

# Authentication

21

from azure.identity import DefaultAzureCredential

22

23

# Core models

24

from azure.mgmt.containerinstance.models import (

25

ContainerGroup,

26

Container,

27

ContainerGroupProperties,

28

ResourceRequirements,

29

ResourceRequests,

30

IpAddress,

31

ContainerPort

32

)

33

```

34

35

## Basic Usage

36

37

### Client Setup and Authentication

38

39

```python

40

from azure.identity import DefaultAzureCredential

41

from azure.mgmt.containerinstance import ContainerInstanceManagementClient

42

import os

43

44

# Setup authentication - requires AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET

45

credential = DefaultAzureCredential()

46

subscription_id = os.getenv("AZURE_SUBSCRIPTION_ID")

47

48

# Create client

49

client = ContainerInstanceManagementClient(

50

credential=credential,

51

subscription_id=subscription_id

52

)

53

```

54

55

### Simple Container Group Creation

56

57

```python

58

from azure.mgmt.containerinstance.models import (

59

ContainerGroup,

60

Container,

61

ContainerGroupProperties,

62

ResourceRequirements,

63

ResourceRequests,

64

IpAddress,

65

ContainerPort

66

)

67

68

# Define container

69

container = Container(

70

name="my-container",

71

image="nginx:latest",

72

resources=ResourceRequirements(

73

requests=ResourceRequests(memory_in_gb=1.0, cpu=1.0)

74

),

75

ports=[ContainerPort(port=80)]

76

)

77

78

# Define container group

79

container_group = ContainerGroup(

80

location="East US",

81

containers=[container],

82

os_type="Linux",

83

ip_address=IpAddress(

84

type="Public",

85

ports=[ContainerPort(port=80, protocol="TCP")]

86

)

87

)

88

89

# Create container group

90

operation = client.container_groups.begin_create_or_update(

91

resource_group_name="my-resource-group",

92

container_group_name="my-container-group",

93

container_group=container_group

94

)

95

result = operation.result()

96

```

97

98

## Architecture

99

100

The Azure Container Instance Management Client follows the standard Azure SDK patterns:

101

102

- **Client**: `ContainerInstanceManagementClient` - Main entry point for all operations

103

- **Operations**: Specialized operation classes for different resource types

104

- **Models**: Data classes representing Azure resources and configurations

105

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

106

107

## Capabilities

108

109

### Container Group Management

110

111

Comprehensive CRUD operations for Azure Container Groups including creation, updates, deletion, and lifecycle management.

112

113

```python { .api }

114

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

115

"""List all container groups in the subscription."""

116

117

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

118

"""List container groups in a specific resource group."""

119

120

def get(resource_group_name: str, container_group_name: str, **kwargs) -> ContainerGroup:

121

"""Get details of a specific container group."""

122

123

def begin_create_or_update(

124

resource_group_name: str,

125

container_group_name: str,

126

container_group: ContainerGroup,

127

**kwargs

128

) -> LROPoller[ContainerGroup]:

129

"""Create a new container group or update an existing one."""

130

131

def update(

132

resource_group_name: str,

133

container_group_name: str,

134

resource: Resource,

135

**kwargs

136

) -> ContainerGroup:

137

"""Update container group tags."""

138

139

def begin_delete(

140

resource_group_name: str,

141

container_group_name: str,

142

**kwargs

143

) -> LROPoller[ContainerGroup]:

144

"""Delete a container group and all its containers."""

145

146

def begin_restart(

147

resource_group_name: str,

148

container_group_name: str,

149

**kwargs

150

) -> LROPoller[None]:

151

"""Restart all containers in a container group."""

152

153

def stop(resource_group_name: str, container_group_name: str, **kwargs) -> None:

154

"""Stop all containers in a container group."""

155

156

def begin_start(

157

resource_group_name: str,

158

container_group_name: str,

159

**kwargs

160

) -> LROPoller[None]:

161

"""Start all containers in a stopped container group."""

162

163

def get_outbound_network_dependencies_endpoints(

164

resource_group_name: str,

165

container_group_name: str,

166

**kwargs

167

) -> List[str]:

168

"""Get outbound network dependencies for a container group."""

169

```

170

171

[Container Group Operations](./container-groups.md)

172

173

### Container Management

174

175

Direct container operations including log retrieval, command execution, and container attachment.

176

177

```python { .api }

178

def list_logs(

179

resource_group_name: str,

180

container_group_name: str,

181

container_name: str,

182

**kwargs

183

) -> Logs:

184

"""Retrieve logs from a specific container."""

185

186

def execute_command(

187

resource_group_name: str,

188

container_group_name: str,

189

container_name: str,

190

container_exec_request: ContainerExecRequest,

191

**kwargs

192

) -> ContainerExecResponse:

193

"""Execute a command inside a running container."""

194

195

def attach(

196

resource_group_name: str,

197

container_group_name: str,

198

container_name: str,

199

**kwargs

200

) -> ContainerAttachResponse:

201

"""Attach to a container's main process for interactive access."""

202

```

203

204

[Container Operations](./containers.md)

205

206

### Authentication and Configuration

207

208

Azure Active Directory authentication setup and client configuration options.

209

210

```python { .api }

211

class ContainerInstanceManagementClient:

212

"""

213

ContainerInstanceManagementClient.

214

215

Args:

216

credential (TokenCredential): Credential needed for the client to connect to Azure

217

subscription_id (str): Subscription credentials which uniquely identify Microsoft Azure subscription

218

base_url (str, optional): Service URL. Default value is "https://management.azure.com"

219

api_version (str, optional): Api Version. Default value is "2023-05-01"

220

polling_interval (int, optional): Default waiting time between two polls for LRO operations

221

"""

222

```

223

224

[Authentication Guide](./authentication.md)

225

226

### Resource Models and Types

227

228

Complete type definitions for all Azure Container Instance resources including container groups, containers, volumes, and networking configurations.

229

230

```python { .api }

231

class ContainerGroup:

232

"""Primary resource representing a collection of containers that share lifecycle and resources."""

233

234

class Container:

235

"""Individual container definition with image, resources, and configuration."""

236

237

class ResourceRequirements:

238

"""Container resource requirements including CPU and memory."""

239

240

class ResourceRequests:

241

"""Minimum resources required for container execution."""

242

243

class ResourceLimits:

244

"""Maximum resources a container can consume."""

245

246

class IpAddress:

247

"""Public IP address configuration for container group."""

248

249

class ContainerPort:

250

"""Port configuration for container networking."""

251

252

class Volume:

253

"""Storage volume that can be mounted to containers."""

254

255

class VolumeMount:

256

"""Volume mount point configuration for containers."""

257

```

258

259

[Resource Models](./models.md)

260

261

### Location and Capabilities

262

263

Query Azure regions and container capabilities for deployment planning.

264

265

```python { .api }

266

def list_usage(location: str, **kwargs) -> Iterable[Usage]:

267

"""Get resource usage information for a specific Azure region."""

268

269

def list_cached_images(location: str, **kwargs) -> Iterable[CachedImages]:

270

"""Get list of cached container images available in a specific Azure region."""

271

272

def list_capabilities(location: str, **kwargs) -> Iterable[Capabilities]:

273

"""Get container capabilities and features available in a specific Azure region."""

274

```

275

276

[Location Operations](./location.md)

277

278

### Available Operations

279

280

List all available operations for the Azure Container Instance resource provider.

281

282

```python { .api }

283

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

284

"""List all available operations for the Microsoft.ContainerInstance resource provider."""

285

```

286

287

[Operations Reference](./operations.md)

288

289

### Subnet Service Association Links

290

291

Manage virtual network subnet service association links for container groups.

292

293

```python { .api }

294

def begin_delete(

295

resource_group_name: str,

296

virtual_network_name: str,

297

subnet_name: str,

298

service_association_link_name: str,

299

**kwargs

300

) -> LROPoller[None]:

301

"""Delete a subnet service association link."""

302

```

303

304

[Subnet Operations](./subnet-operations.md)