or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

asset-management.mdasset-tracks.mdcontent-delivery-streaming.mdcontent-protection.mdencoding-transforms.mdindex.mdlive-streaming.mdlocation-management.mdmedia-filters.mdmedia-services-management.mdnetwork-security.mdoperations-monitoring.md

live-streaming.mddocs/

0

# Live Streaming

1

2

Comprehensive live streaming capabilities for real-time content delivery including live event management, input configuration, preview settings, and output publishing. Supports RTMP and fragmented MP4 ingest with adaptive bitrate encoding and global distribution through Azure's content delivery network.

3

4

## Capabilities

5

6

### Live Event Management

7

8

Create and manage live streaming events with complete lifecycle control and long-running operation support.

9

10

```python { .api }

11

def list(resource_group_name: str, account_name: str) -> Iterable[LiveEvent]:

12

"""

13

List all live events in a media service account.

14

15

Parameters:

16

- resource_group_name: Name of the resource group (str)

17

- account_name: Name of the media service account (str)

18

19

Returns:

20

Iterable of LiveEvent objects with configuration and status

21

"""

22

23

def get(

24

resource_group_name: str,

25

account_name: str,

26

live_event_name: str

27

) -> LiveEvent:

28

"""

29

Get a specific live event with complete configuration details.

30

31

Parameters:

32

- resource_group_name: Name of the resource group (str)

33

- account_name: Name of the media service account (str)

34

- live_event_name: Name of the live event (str)

35

36

Returns:

37

LiveEvent object with current state and configuration

38

"""

39

40

def begin_create(

41

resource_group_name: str,

42

account_name: str,

43

live_event_name: str,

44

parameters: LiveEvent

45

) -> LROPoller[LiveEvent]:

46

"""

47

Create a new live event with specified configuration.

48

49

Parameters:

50

- resource_group_name: Name of the resource group (str)

51

- account_name: Name of the media service account (str)

52

- live_event_name: Name for the new live event (str)

53

- parameters: Live event configuration (LiveEvent)

54

55

Returns:

56

LROPoller for tracking the creation operation

57

"""

58

59

def begin_update(

60

resource_group_name: str,

61

account_name: str,

62

live_event_name: str,

63

parameters: LiveEvent

64

) -> LROPoller[LiveEvent]:

65

"""

66

Update an existing live event configuration.

67

68

Parameters:

69

- resource_group_name: Name of the resource group (str)

70

- account_name: Name of the media service account (str)

71

- live_event_name: Name of the live event (str)

72

- parameters: Updated live event configuration (LiveEvent)

73

74

Returns:

75

LROPoller for tracking the update operation

76

"""

77

78

def begin_delete(

79

resource_group_name: str,

80

account_name: str,

81

live_event_name: str

82

) -> LROPoller[None]:

83

"""

84

Delete a live event.

85

86

Parameters:

87

- resource_group_name: Name of the resource group (str)

88

- account_name: Name of the media service account (str)

89

- live_event_name: Name of the live event (str)

90

91

Returns:

92

LROPoller for tracking the deletion operation

93

"""

94

```

95

96

### Live Event Lifecycle Operations

97

98

Control live event state transitions with resource allocation and streaming control.

99

100

```python { .api }

101

def begin_allocate(

102

resource_group_name: str,

103

account_name: str,

104

live_event_name: str

105

) -> LROPoller[None]:

106

"""

107

Allocate resources for a live event.

108

109

Parameters:

110

- resource_group_name: Name of the resource group (str)

111

- account_name: Name of the media service account (str)

112

- live_event_name: Name of the live event (str)

113

114

Returns:

115

LROPoller for tracking the allocation operation

116

"""

117

118

def begin_start(

119

resource_group_name: str,

120

account_name: str,

121

live_event_name: str

122

) -> LROPoller[None]:

123

"""

124

Start a live event to begin accepting ingest streams.

125

126

Parameters:

127

- resource_group_name: Name of the resource group (str)

128

- account_name: Name of the media service account (str)

129

- live_event_name: Name of the live event (str)

130

131

Returns:

132

LROPoller for tracking the start operation

133

"""

134

135

def begin_stop(

136

resource_group_name: str,

137

account_name: str,

138

live_event_name: str,

139

parameters: LiveEventActionInput

140

) -> LROPoller[None]:

141

"""

142

Stop a live event and optionally remove streaming endpoints.

143

144

Parameters:

145

- resource_group_name: Name of the resource group (str)

146

- account_name: Name of the media service account (str)

147

- live_event_name: Name of the live event (str)

148

- parameters: Stop action configuration (LiveEventActionInput)

149

150

Returns:

151

LROPoller for tracking the stop operation

152

"""

153

154

def begin_reset(

155

resource_group_name: str,

156

account_name: str,

157

live_event_name: str

158

) -> LROPoller[None]:

159

"""

160

Reset a live event, clearing any cached state.

161

162

Parameters:

163

- resource_group_name: Name of the resource group (str)

164

- account_name: Name of the media service account (str)

165

- live_event_name: Name of the live event (str)

166

167

Returns:

168

LROPoller for tracking the reset operation

169

"""

170

```

171

172

### Live Output Management

173

174

Manage live outputs for archiving live streams to assets with automatic recording capabilities.

175

176

```python { .api }

177

def list(

178

resource_group_name: str,

179

account_name: str,

180

live_event_name: str

181

) -> Iterable[LiveOutput]:

182

"""

183

List all live outputs for a live event.

184

185

Parameters:

186

- resource_group_name: Name of the resource group (str)

187

- account_name: Name of the media service account (str)

188

- live_event_name: Name of the live event (str)

189

190

Returns:

191

Iterable of LiveOutput objects with archiving configuration

192

"""

193

194

def get(

195

resource_group_name: str,

196

account_name: str,

197

live_event_name: str,

198

live_output_name: str

199

) -> LiveOutput:

200

"""

201

Get a specific live output with configuration details.

202

203

Parameters:

204

- resource_group_name: Name of the resource group (str)

205

- account_name: Name of the media service account (str)

206

- live_event_name: Name of the live event (str)

207

- live_output_name: Name of the live output (str)

208

209

Returns:

210

LiveOutput object with current state and configuration

211

"""

212

213

def begin_create(

214

resource_group_name: str,

215

account_name: str,

216

live_event_name: str,

217

live_output_name: str,

218

parameters: LiveOutput

219

) -> LROPoller[LiveOutput]:

220

"""

221

Create a live output for archiving live streams.

222

223

Parameters:

224

- resource_group_name: Name of the resource group (str)

225

- account_name: Name of the media service account (str)

226

- live_event_name: Name of the live event (str)

227

- live_output_name: Name for the new live output (str)

228

- parameters: Live output configuration (LiveOutput)

229

230

Returns:

231

LROPoller for tracking the creation operation

232

"""

233

234

def begin_delete(

235

resource_group_name: str,

236

account_name: str,

237

live_event_name: str,

238

live_output_name: str

239

) -> LROPoller[None]:

240

"""

241

Delete a live output.

242

243

Parameters:

244

- resource_group_name: Name of the resource group (str)

245

- account_name: Name of the media service account (str)

246

- live_event_name: Name of the live event (str)

247

- live_output_name: Name of the live output (str)

248

249

Returns:

250

LROPoller for tracking the deletion operation

251

"""

252

```

253

254

### Async Operation Monitoring

255

256

Monitor long-running live streaming operations with status tracking and result retrieval.

257

258

```python { .api }

259

def async_operation(

260

resource_group_name: str,

261

account_name: str,

262

operation_id: str

263

) -> AsyncOperationResult:

264

"""

265

Get the result of an asynchronous live streaming operation.

266

267

Parameters:

268

- resource_group_name: Name of the resource group (str)

269

- account_name: Name of the media service account (str)

270

- operation_id: Identifier of the async operation (str)

271

272

Returns:

273

AsyncOperationResult with operation status and details

274

"""

275

276

def operation_location(

277

resource_group_name: str,

278

account_name: str,

279

live_event_name: str,

280

operation_id: str

281

) -> LiveEvent:

282

"""

283

Get live event operation result by location.

284

285

Parameters:

286

- resource_group_name: Name of the resource group (str)

287

- account_name: Name of the media service account (str)

288

- live_event_name: Name of the live event (str)

289

- operation_id: Identifier of the operation (str)

290

291

Returns:

292

LiveEvent object with updated state

293

"""

294

```

295

296

## Data Types

297

298

```python { .api }

299

class LiveEvent:

300

"""Live streaming event configuration and state."""

301

name: str

302

description: str

303

location: str

304

resource_state: str # LiveEventResourceState enum

305

input: LiveEventInput

306

preview: LiveEventPreview

307

encoding: LiveEventEncoding

308

hostname_prefix: str

309

use_static_hostname: bool

310

stream_options: List[str] # StreamOptionsFlag enum

311

created: str

312

last_modified: str

313

provisioning_state: str

314

315

class LiveEventInput:

316

"""Live event input configuration."""

317

streaming_protocol: str # LiveEventInputProtocol enum (FragmentedMP4, RTMP)

318

access_control: LiveEventInputAccessControl

319

key_frame_interval_duration: str

320

access_token: str

321

endpoints: List[LiveEventEndpoint]

322

323

class LiveEventInputAccessControl:

324

"""Access control for live event input."""

325

ip: IPAccessControl

326

327

class IPAccessControl:

328

"""IP-based access control configuration."""

329

allow: List[IPRange]

330

331

class IPRange:

332

"""IP address range for access control."""

333

name: str

334

address: str

335

subnet_prefix_length: int

336

337

class LiveEventEndpoint:

338

"""Live event streaming endpoint."""

339

protocol: str

340

url: str

341

342

class LiveEventPreview:

343

"""Live event preview configuration."""

344

endpoints: List[LiveEventEndpoint]

345

access_control: LiveEventPreviewAccessControl

346

preview_locator: str

347

streaming_policy_name: str

348

alternative_media_id: str

349

350

class LiveEventPreviewAccessControl:

351

"""Access control for live event preview."""

352

ip: IPAccessControl

353

354

class LiveEventEncoding:

355

"""Live event encoding configuration."""

356

encoding_type: str # LiveEventEncodingType enum

357

preset_name: str

358

stretch_mode: str # StretchMode enum

359

key_frame_interval: str

360

361

class LiveOutput:

362

"""Live output for archiving live streams."""

363

name: str

364

description: str

365

asset_name: str

366

archive_window_length: str

367

manifest_name: str

368

hls: Hls

369

output_snap_time: int

370

created: str

371

last_modified: str

372

provisioning_state: str

373

resource_state: str # LiveOutputResourceState enum

374

375

class Hls:

376

"""HLS-specific live output configuration."""

377

fragments_per_ts_segment: int

378

379

class LiveEventActionInput:

380

"""Input parameters for live event actions."""

381

remove_outputs_on_stop: bool

382

383

class AsyncOperationResult:

384

"""Result of an asynchronous operation."""

385

name: str

386

status: str # AsyncOperationStatus enum

387

properties: dict

388

error: dict

389

```

390

391

## Usage Examples

392

393

### Create and Start Live Event

394

395

```python

396

from azure.mgmt.media import AzureMediaServices

397

from azure.mgmt.media.models import (

398

LiveEvent, LiveEventInput, LiveEventPreview, LiveEventEncoding,

399

LiveEventInputProtocol, LiveEventEncodingType, IPAccessControl, IPRange

400

)

401

from azure.identity import DefaultAzureCredential

402

403

client = AzureMediaServices(

404

credential=DefaultAzureCredential(),

405

subscription_id="your-subscription-id"

406

)

407

408

# Configure input access control (allow all IPs - use restrictive rules in production)

409

ip_range = IPRange(

410

name="AllowAll",

411

address="0.0.0.0",

412

subnet_prefix_length=0

413

)

414

415

input_access_control = LiveEventInputAccessControl(

416

ip=IPAccessControl(allow=[ip_range])

417

)

418

419

# Configure live event input

420

live_input = LiveEventInput(

421

streaming_protocol=LiveEventInputProtocol.RTMP,

422

access_control=input_access_control,

423

key_frame_interval_duration="PT2S"

424

)

425

426

# Configure preview

427

preview = LiveEventPreview(

428

access_control=LiveEventPreviewAccessControl(

429

ip=IPAccessControl(allow=[ip_range])

430

)

431

)

432

433

# Configure encoding

434

encoding = LiveEventEncoding(

435

encoding_type=LiveEventEncodingType.STANDARD,

436

preset_name="Default720p"

437

)

438

439

# Create live event

440

live_event = LiveEvent(

441

location="East US",

442

description="Sample live streaming event",

443

input=live_input,

444

preview=preview,

445

encoding=encoding,

446

use_static_hostname=True

447

)

448

449

# Start creation

450

create_operation = client.live_events.begin_create(

451

resource_group_name="my-resource-group",

452

account_name="my-media-service",

453

live_event_name="sample-live-event",

454

parameters=live_event

455

)

456

457

# Wait for creation to complete

458

created_event = create_operation.result()

459

print(f"Live event created: {created_event.name}")

460

461

# Start the live event

462

start_operation = client.live_events.begin_start(

463

resource_group_name="my-resource-group",

464

account_name="my-media-service",

465

live_event_name="sample-live-event"

466

)

467

468

start_operation.result()

469

print("Live event started and ready for ingest")

470

471

# Get updated live event with ingest URLs

472

running_event = client.live_events.get(

473

resource_group_name="my-resource-group",

474

account_name="my-media-service",

475

live_event_name="sample-live-event"

476

)

477

478

print(f"Live event state: {running_event.resource_state}")

479

print("Ingest endpoints:")

480

for endpoint in running_event.input.endpoints:

481

print(f" {endpoint.protocol}: {endpoint.url}")

482

```

483

484

### Create Live Output for Recording

485

486

```python

487

from azure.mgmt.media.models import LiveOutput, Hls

488

489

# Create asset for recording

490

from azure.mgmt.media.models import Asset

491

492

recording_asset = Asset(

493

description="Live stream recording"

494

)

495

496

client.assets.create_or_update(

497

resource_group_name="my-resource-group",

498

account_name="my-media-service",

499

asset_name="live-recording-asset",

500

parameters=recording_asset

501

)

502

503

# Create live output

504

live_output = LiveOutput(

505

description="Archive live stream",

506

asset_name="live-recording-asset",

507

archive_window_length="PT1H", # 1 hour archive window

508

manifest_name="output",

509

hls=Hls(fragments_per_ts_segment=5)

510

)

511

512

output_operation = client.live_outputs.begin_create(

513

resource_group_name="my-resource-group",

514

account_name="my-media-service",

515

live_event_name="sample-live-event",

516

live_output_name="archive-output",

517

parameters=live_output

518

)

519

520

created_output = output_operation.result()

521

print(f"Live output created: {created_output.name}")

522

print(f"Recording to asset: {created_output.asset_name}")

523

```

524

525

### Monitor and Stop Live Event

526

527

```python

528

from azure.mgmt.media.models import LiveEventActionInput

529

import time

530

531

# Monitor live event status

532

while True:

533

event_status = client.live_events.get(

534

resource_group_name="my-resource-group",

535

account_name="my-media-service",

536

live_event_name="sample-live-event"

537

)

538

539

print(f"Live event state: {event_status.resource_state}")

540

541

if event_status.resource_state == "Running":

542

print("Live event is running successfully")

543

break

544

elif event_status.resource_state in ["Error", "Stopped"]:

545

print("Live event failed or stopped")

546

break

547

548

time.sleep(10)

549

550

# Later: Stop the live event

551

stop_input = LiveEventActionInput(remove_outputs_on_stop=False)

552

553

stop_operation = client.live_events.begin_stop(

554

resource_group_name="my-resource-group",

555

account_name="my-media-service",

556

live_event_name="sample-live-event",

557

parameters=stop_input

558

)

559

560

stop_operation.result()

561

print("Live event stopped")

562

```