0
# Media Services Account Management
1
2
Management operations for Azure Media Services accounts including account lifecycle, configuration, storage integration, and edge policies. These operations provide the foundational infrastructure management capabilities for media processing services.
3
4
## Capabilities
5
6
### Account Listing and Retrieval
7
8
List and retrieve media service accounts within resource groups and subscriptions.
9
10
```python { .api }
11
def list(resource_group_name: str) -> Iterable[MediaService]:
12
"""
13
List all media services in a resource group.
14
15
Parameters:
16
- resource_group_name: Name of the resource group (str)
17
18
Returns:
19
Iterable of MediaService objects
20
"""
21
22
def get(resource_group_name: str, account_name: str) -> MediaService:
23
"""
24
Get a specific media service account.
25
26
Parameters:
27
- resource_group_name: Name of the resource group (str)
28
- account_name: Name of the media service account (str)
29
30
Returns:
31
MediaService object containing account details
32
"""
33
34
def list_by_subscription() -> Iterable[MediaService]:
35
"""
36
List all media services in the current subscription.
37
38
Returns:
39
Iterable of MediaService objects across all resource groups
40
"""
41
```
42
43
### Account Creation and Updates
44
45
Create new media service accounts and update existing account configurations with long-running operation support.
46
47
```python { .api }
48
def begin_create_or_update(
49
resource_group_name: str,
50
account_name: str,
51
parameters: MediaService
52
) -> LROPoller[MediaService]:
53
"""
54
Create or update a media service account.
55
56
Parameters:
57
- resource_group_name: Name of the resource group (str)
58
- account_name: Name of the media service account (str)
59
- parameters: Media service configuration (MediaService)
60
61
Returns:
62
LROPoller for long-running operation tracking
63
"""
64
65
def begin_update(
66
resource_group_name: str,
67
account_name: str,
68
parameters: MediaService
69
) -> LROPoller[MediaService]:
70
"""
71
Update an existing media service account.
72
73
Parameters:
74
- resource_group_name: Name of the resource group (str)
75
- account_name: Name of the media service account (str)
76
- parameters: Updated media service configuration (MediaService)
77
78
Returns:
79
LROPoller for long-running operation tracking
80
"""
81
```
82
83
### Account Deletion
84
85
Remove media service accounts and associated resources.
86
87
```python { .api }
88
def delete(resource_group_name: str, account_name: str) -> None:
89
"""
90
Delete a media service account.
91
92
Parameters:
93
- resource_group_name: Name of the resource group (str)
94
- account_name: Name of the media service account (str)
95
96
Returns:
97
None
98
"""
99
```
100
101
### Storage Key Management
102
103
Synchronize storage account keys for media service accounts.
104
105
```python { .api }
106
def sync_storage_keys(
107
resource_group_name: str,
108
account_name: str,
109
parameters: SyncStorageKeysInput
110
) -> None:
111
"""
112
Synchronize storage account keys with the media service.
113
114
Parameters:
115
- resource_group_name: Name of the resource group (str)
116
- account_name: Name of the media service account (str)
117
- parameters: Storage key synchronization parameters (SyncStorageKeysInput)
118
119
Returns:
120
None
121
"""
122
```
123
124
### Edge Policies Management
125
126
Manage edge policies for content delivery network integration.
127
128
```python { .api }
129
def list_edge_policies(
130
resource_group_name: str,
131
account_name: str,
132
parameters: ListEdgePoliciesInput
133
) -> EdgePolicies:
134
"""
135
List edge policies for the media service account.
136
137
Parameters:
138
- resource_group_name: Name of the resource group (str)
139
- account_name: Name of the media service account (str)
140
- parameters: Edge policy listing parameters (ListEdgePoliciesInput)
141
142
Returns:
143
EdgePolicies containing policy configurations
144
"""
145
```
146
147
## Data Types
148
149
```python { .api }
150
class MediaService:
151
"""Azure Media Services account resource."""
152
name: str
153
location: str
154
resource_group: str
155
tags: dict
156
storage_accounts: List[StorageAccount]
157
encryption: MediaServiceEncryption
158
key_delivery: KeyDelivery
159
public_network_access: str
160
provisioning_state: str
161
162
class StorageAccount:
163
"""Storage account configuration for media service."""
164
type: str # Primary or Secondary
165
id: str
166
identity: MediaServiceIdentity
167
168
class SyncStorageKeysInput:
169
"""Parameters for storage key synchronization."""
170
id: str
171
172
class ListEdgePoliciesInput:
173
"""Parameters for listing edge policies."""
174
device_id: str
175
176
class EdgePolicies:
177
"""Edge policies configuration."""
178
usage_data_collection_policy: EdgeUsageDataCollectionPolicy
179
```
180
181
## Usage Examples
182
183
### Create a Media Service Account
184
185
```python
186
from azure.mgmt.media import AzureMediaServices
187
from azure.mgmt.media.models import MediaService, StorageAccount
188
from azure.identity import DefaultAzureCredential
189
190
client = AzureMediaServices(
191
credential=DefaultAzureCredential(),
192
subscription_id="your-subscription-id"
193
)
194
195
# Configure storage account
196
storage_account = StorageAccount(
197
type="Primary",
198
id="/subscriptions/sub-id/resourceGroups/rg/providers/Microsoft.Storage/storageAccounts/storage"
199
)
200
201
# Create media service
202
media_service = MediaService(
203
location="East US",
204
storage_accounts=[storage_account]
205
)
206
207
# Start creation (long-running operation)
208
operation = client.mediaservices.begin_create_or_update(
209
resource_group_name="my-resource-group",
210
account_name="my-media-service",
211
parameters=media_service
212
)
213
214
# Wait for completion
215
result = operation.result()
216
print(f"Media Service created: {result.name}")
217
```
218
219
### List and Manage Media Services
220
221
```python
222
# List all media services in a resource group
223
media_services = client.mediaservices.list("my-resource-group")
224
225
for service in media_services:
226
print(f"Service: {service.name}")
227
print(f"Location: {service.location}")
228
print(f"Storage Accounts: {len(service.storage_accounts)}")
229
230
# Sync storage keys if needed
231
if service.storage_accounts:
232
storage_id = service.storage_accounts[0].id
233
sync_input = SyncStorageKeysInput(id=storage_id)
234
235
client.mediaservices.sync_storage_keys(
236
resource_group_name="my-resource-group",
237
account_name=service.name,
238
parameters=sync_input
239
)
240
print(f"Storage keys synchronized for {service.name}")
241
```