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

asset-management.mddocs/

0

# Asset Management

1

2

Comprehensive management of media assets, the fundamental containers for audio and video content in Azure Media Services. Assets represent logical containers that reference media files stored in Azure Storage accounts, providing metadata management, access control, and integration with encoding and streaming workflows.

3

4

## Capabilities

5

6

### Asset Listing and Retrieval

7

8

List and retrieve assets within media service accounts with comprehensive metadata.

9

10

```python { .api }

11

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

12

"""

13

List all assets 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 Asset objects with metadata and properties

21

"""

22

23

def get(resource_group_name: str, account_name: str, asset_name: str) -> Asset:

24

"""

25

Get a specific asset with full details.

26

27

Parameters:

28

- resource_group_name: Name of the resource group (str)

29

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

30

- asset_name: Name of the asset (str)

31

32

Returns:

33

Asset object containing metadata and configuration

34

"""

35

```

36

37

### Asset Creation and Updates

38

39

Create new assets and update existing asset configurations and metadata.

40

41

```python { .api }

42

def create_or_update(

43

resource_group_name: str,

44

account_name: str,

45

asset_name: str,

46

parameters: Asset

47

) -> Asset:

48

"""

49

Create or update an asset.

50

51

Parameters:

52

- resource_group_name: Name of the resource group (str)

53

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

54

- asset_name: Name of the asset (str)

55

- parameters: Asset configuration and metadata (Asset)

56

57

Returns:

58

Created or updated Asset object

59

"""

60

61

def update(

62

resource_group_name: str,

63

account_name: str,

64

asset_name: str,

65

parameters: Asset

66

) -> Asset:

67

"""

68

Update an existing asset's metadata.

69

70

Parameters:

71

- resource_group_name: Name of the resource group (str)

72

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

73

- asset_name: Name of the asset (str)

74

- parameters: Updated asset configuration (Asset)

75

76

Returns:

77

Updated Asset object

78

"""

79

```

80

81

### Asset Deletion

82

83

Remove assets and optionally delete associated storage content.

84

85

```python { .api }

86

def delete(resource_group_name: str, account_name: str, asset_name: str) -> None:

87

"""

88

Delete an asset.

89

90

Parameters:

91

- resource_group_name: Name of the resource group (str)

92

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

93

- asset_name: Name of the asset (str)

94

95

Returns:

96

None

97

98

Note:

99

This operation deletes the asset metadata but not the underlying storage files.

100

"""

101

```

102

103

### Storage Container Access

104

105

Generate SAS URLs for direct storage access to upload or download media files.

106

107

```python { .api }

108

def list_container_sas(

109

resource_group_name: str,

110

account_name: str,

111

asset_name: str,

112

parameters: ListContainerSasInput

113

) -> AssetContainerSas:

114

"""

115

Generate SAS URLs for asset container access.

116

117

Parameters:

118

- resource_group_name: Name of the resource group (str)

119

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

120

- asset_name: Name of the asset (str)

121

- parameters: SAS generation parameters (ListContainerSasInput)

122

123

Returns:

124

AssetContainerSas containing SAS URLs and container information

125

"""

126

```

127

128

### Encryption Key Management

129

130

Retrieve decryption keys for storage-encrypted assets.

131

132

```python { .api }

133

def get_encryption_key(

134

resource_group_name: str,

135

account_name: str,

136

asset_name: str

137

) -> StorageEncryptedAssetDecryptionData:

138

"""

139

Get encryption key information for a storage-encrypted asset.

140

141

Parameters:

142

- resource_group_name: Name of the resource group (str)

143

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

144

- asset_name: Name of the asset (str)

145

146

Returns:

147

StorageEncryptedAssetDecryptionData containing decryption information

148

"""

149

```

150

151

### Streaming Locator Association

152

153

List streaming locators associated with an asset for content publishing.

154

155

```python { .api }

156

def list_streaming_locators(

157

resource_group_name: str,

158

account_name: str,

159

asset_name: str

160

) -> ListStreamingLocatorsResponse:

161

"""

162

List streaming locators associated with an asset.

163

164

Parameters:

165

- resource_group_name: Name of the resource group (str)

166

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

167

- asset_name: Name of the asset (str)

168

169

Returns:

170

ListStreamingLocatorsResponse containing associated streaming locators

171

"""

172

```

173

174

## Data Types

175

176

```python { .api }

177

class Asset:

178

"""Media asset container for audio/video files."""

179

name: str

180

description: str

181

asset_id: str

182

created: str

183

last_modified: str

184

alternate_id: str

185

storage_account_name: str

186

container: str

187

storage_encryption_format: str # AssetStorageEncryptionFormat enum

188

189

class ListContainerSasInput:

190

"""Parameters for generating asset container SAS URLs."""

191

permissions: str # AssetContainerPermission enum (Read, ReadWrite, ReadWriteDelete)

192

expiry_time: str # ISO 8601 datetime

193

194

class AssetContainerSas:

195

"""Asset container SAS information."""

196

asset_container_sas_urls: List[str]

197

198

class StorageEncryptedAssetDecryptionData:

199

"""Asset decryption information for storage-encrypted assets."""

200

key: bytes

201

initialization_vector: bytes

202

203

class ListStreamingLocatorsResponse:

204

"""Response containing streaming locators for an asset."""

205

streaming_locators: List[AssetStreamingLocator]

206

207

class AssetStreamingLocator:

208

"""Streaming locator associated with an asset."""

209

name: str

210

asset_name: str

211

created: str

212

start_time: str

213

end_time: str

214

streaming_locator_id: str

215

streaming_policy_name: str

216

default_content_key_policy_name: str

217

```

218

219

## Usage Examples

220

221

### Create and Upload to Asset

222

223

```python

224

from azure.mgmt.media import AzureMediaServices

225

from azure.mgmt.media.models import Asset, ListContainerSasInput, AssetContainerPermission

226

from azure.identity import DefaultAzureCredential

227

from azure.storage.blob import BlobServiceClient

228

import os

229

230

client = AzureMediaServices(

231

credential=DefaultAzureCredential(),

232

subscription_id="your-subscription-id"

233

)

234

235

# Create a new asset

236

asset = Asset(

237

description="Sample video asset for encoding"

238

)

239

240

created_asset = client.assets.create_or_update(

241

resource_group_name="my-resource-group",

242

account_name="my-media-service",

243

asset_name="sample-video-asset",

244

parameters=asset

245

)

246

247

print(f"Asset created: {created_asset.name}")

248

print(f"Container: {created_asset.container}")

249

250

# Get SAS URL for upload

251

sas_input = ListContainerSasInput(

252

permissions=AssetContainerPermission.READ_WRITE,

253

expiry_time="2024-12-31T23:59:59Z"

254

)

255

256

sas_response = client.assets.list_container_sas(

257

resource_group_name="my-resource-group",

258

account_name="my-media-service",

259

asset_name="sample-video-asset",

260

parameters=sas_input

261

)

262

263

# Use SAS URL to upload files

264

sas_url = sas_response.asset_container_sas_urls[0]

265

blob_client = BlobServiceClient(account_url=sas_url)

266

267

# Upload a file

268

with open("sample-video.mp4", "rb") as data:

269

blob_client.get_blob_client(blob="sample-video.mp4").upload_blob(data)

270

271

print("File uploaded to asset container")

272

```

273

274

### List Assets and Associated Streaming Locators

275

276

```python

277

# List all assets

278

assets = client.assets.list(

279

resource_group_name="my-resource-group",

280

account_name="my-media-service"

281

)

282

283

for asset in assets:

284

print(f"Asset: {asset.name}")

285

print(f"Created: {asset.created}")

286

print(f"Storage Account: {asset.storage_account_name}")

287

288

# Check streaming locators

289

locators_response = client.assets.list_streaming_locators(

290

resource_group_name="my-resource-group",

291

account_name="my-media-service",

292

asset_name=asset.name

293

)

294

295

if locators_response.streaming_locators:

296

print(f" Streaming Locators:")

297

for locator in locators_response.streaming_locators:

298

print(f" - {locator.name} (Policy: {locator.streaming_policy_name})")

299

else:

300

print(" No streaming locators associated")

301

302

print()

303

```

304

305

### Manage Asset Metadata

306

307

```python

308

# Get asset details

309

asset = client.assets.get(

310

resource_group_name="my-resource-group",

311

account_name="my-media-service",

312

asset_name="sample-video-asset"

313

)

314

315

print(f"Original description: {asset.description}")

316

317

# Update asset metadata

318

asset.description = "Updated sample video asset with new metadata"

319

asset.alternate_id = "external-id-12345"

320

321

updated_asset = client.assets.update(

322

resource_group_name="my-resource-group",

323

account_name="my-media-service",

324

asset_name="sample-video-asset",

325

parameters=asset

326

)

327

328

print(f"Updated description: {updated_asset.description}")

329

print(f"Alternate ID: {updated_asset.alternate_id}")

330

```