0
# Cloud Services Management
1
2
Management of Azure Cloud Services including roles, update domains, and operating system configurations. Cloud Services provide a platform-as-a-service (PaaS) compute option for deploying highly available, infinitely-scalable applications and APIs.
3
4
## Capabilities
5
6
### Cloud Service Lifecycle Operations
7
8
Core operations for managing Azure Cloud Services.
9
10
```python { .api }
11
class CloudServicesOperations:
12
def begin_create_or_update(
13
resource_group_name: str,
14
cloud_service_name: str,
15
parameters: CloudService
16
) -> LROPoller[CloudService]:
17
"""
18
Create or update a cloud service.
19
20
Args:
21
resource_group_name: Name of the resource group
22
cloud_service_name: Name of the cloud service
23
parameters: Cloud service configuration
24
25
Returns:
26
Long-running operation poller for CloudService
27
"""
28
29
def begin_delete(resource_group_name: str, cloud_service_name: str) -> LROPoller[None]:
30
"""
31
Delete a cloud service.
32
33
Args:
34
resource_group_name: Name of the resource group
35
cloud_service_name: Name of the cloud service
36
37
Returns:
38
Long-running operation poller
39
"""
40
41
def get(resource_group_name: str, cloud_service_name: str) -> CloudService:
42
"""
43
Get cloud service details.
44
45
Args:
46
resource_group_name: Name of the resource group
47
cloud_service_name: Name of the cloud service
48
49
Returns:
50
Cloud service details
51
"""
52
53
def list(resource_group_name: str) -> Iterable[CloudService]:
54
"""
55
List cloud services in a resource group.
56
57
Args:
58
resource_group_name: Name of the resource group
59
60
Returns:
61
Iterable of cloud services
62
"""
63
64
def list_all() -> Iterable[CloudService]:
65
"""
66
List all cloud services in the subscription.
67
68
Returns:
69
Iterable of all cloud services
70
"""
71
```
72
73
### Cloud Service Power Management
74
75
Operations for controlling cloud service power state.
76
77
```python { .api }
78
def begin_start(resource_group_name: str, cloud_service_name: str) -> LROPoller[None]:
79
"""
80
Start a cloud service.
81
82
Args:
83
resource_group_name: Name of the resource group
84
cloud_service_name: Name of the cloud service
85
86
Returns:
87
Long-running operation poller
88
"""
89
90
def begin_power_off(resource_group_name: str, cloud_service_name: str) -> LROPoller[None]:
91
"""
92
Power off a cloud service.
93
94
Args:
95
resource_group_name: Name of the resource group
96
cloud_service_name: Name of the cloud service
97
98
Returns:
99
Long-running operation poller
100
"""
101
102
def begin_restart(resource_group_name: str, cloud_service_name: str) -> LROPoller[None]:
103
"""
104
Restart a cloud service.
105
106
Args:
107
resource_group_name: Name of the resource group
108
cloud_service_name: Name of the cloud service
109
110
Returns:
111
Long-running operation poller
112
"""
113
114
def begin_rebuild(resource_group_name: str, cloud_service_name: str) -> LROPoller[None]:
115
"""
116
Rebuild a cloud service.
117
118
Args:
119
resource_group_name: Name of the resource group
120
cloud_service_name: Name of the cloud service
121
122
Returns:
123
Long-running operation poller
124
"""
125
```
126
127
### Cloud Service Role Management
128
129
Operations for managing roles within cloud services.
130
131
```python { .api }
132
class CloudServiceRolesOperations:
133
def get(
134
resource_group_name: str,
135
cloud_service_name: str,
136
role_name: str
137
) -> CloudServiceRole:
138
"""
139
Get cloud service role details.
140
141
Args:
142
resource_group_name: Name of the resource group
143
cloud_service_name: Name of the cloud service
144
role_name: Name of the role
145
146
Returns:
147
Cloud service role details
148
"""
149
150
def list(
151
resource_group_name: str,
152
cloud_service_name: str
153
) -> Iterable[CloudServiceRole]:
154
"""
155
List roles in a cloud service.
156
157
Args:
158
resource_group_name: Name of the resource group
159
cloud_service_name: Name of the cloud service
160
161
Returns:
162
Iterable of cloud service roles
163
"""
164
```
165
166
### Cloud Service Role Instance Management
167
168
Operations for managing individual role instances.
169
170
```python { .api }
171
class CloudServiceRoleInstancesOperations:
172
def begin_delete(
173
resource_group_name: str,
174
cloud_service_name: str,
175
role_instance_name: str
176
) -> LROPoller[None]:
177
"""
178
Delete a role instance.
179
180
Args:
181
resource_group_name: Name of the resource group
182
cloud_service_name: Name of the cloud service
183
role_instance_name: Name of the role instance
184
185
Returns:
186
Long-running operation poller
187
"""
188
189
def get(
190
resource_group_name: str,
191
cloud_service_name: str,
192
role_instance_name: str
193
) -> RoleInstance:
194
"""
195
Get role instance details.
196
197
Args:
198
resource_group_name: Name of the resource group
199
cloud_service_name: Name of the cloud service
200
role_instance_name: Name of the role instance
201
202
Returns:
203
Role instance details
204
"""
205
206
def list(
207
resource_group_name: str,
208
cloud_service_name: str
209
) -> Iterable[RoleInstance]:
210
"""
211
List role instances in a cloud service.
212
213
Args:
214
resource_group_name: Name of the resource group
215
cloud_service_name: Name of the cloud service
216
217
Returns:
218
Iterable of role instances
219
"""
220
221
def begin_restart(
222
resource_group_name: str,
223
cloud_service_name: str,
224
role_instance_name: str
225
) -> LROPoller[None]:
226
"""
227
Restart a role instance.
228
229
Args:
230
resource_group_name: Name of the resource group
231
cloud_service_name: Name of the cloud service
232
role_instance_name: Name of the role instance
233
234
Returns:
235
Long-running operation poller
236
"""
237
238
def begin_reimage(
239
resource_group_name: str,
240
cloud_service_name: str,
241
role_instance_name: str
242
) -> LROPoller[None]:
243
"""
244
Reimage a role instance.
245
246
Args:
247
resource_group_name: Name of the resource group
248
cloud_service_name: Name of the cloud service
249
role_instance_name: Name of the role instance
250
251
Returns:
252
Long-running operation poller
253
"""
254
```
255
256
### Update Domain Management
257
258
Operations for managing update domains in cloud services.
259
260
```python { .api }
261
class CloudServicesUpdateDomainOperations:
262
def walk_update_domain(
263
resource_group_name: str,
264
cloud_service_name: str,
265
update_domain: int
266
) -> None:
267
"""
268
Walk an update domain to apply updates.
269
270
Args:
271
resource_group_name: Name of the resource group
272
cloud_service_name: Name of the cloud service
273
update_domain: Update domain number
274
"""
275
276
def get_update_domain(
277
resource_group_name: str,
278
cloud_service_name: str,
279
update_domain: int
280
) -> UpdateDomain:
281
"""
282
Get update domain details.
283
284
Args:
285
resource_group_name: Name of the resource group
286
cloud_service_name: Name of the cloud service
287
update_domain: Update domain number
288
289
Returns:
290
Update domain details
291
"""
292
293
def list_update_domains(
294
resource_group_name: str,
295
cloud_service_name: str
296
) -> Iterable[UpdateDomain]:
297
"""
298
List update domains in a cloud service.
299
300
Args:
301
resource_group_name: Name of the resource group
302
cloud_service_name: Name of the cloud service
303
304
Returns:
305
Iterable of update domains
306
"""
307
```
308
309
### Operating System Management
310
311
Operations for managing operating systems in cloud services.
312
313
```python { .api }
314
class CloudServiceOperatingSystemsOperations:
315
def get_os_version(
316
location: str,
317
os_version_name: str
318
) -> OSVersion:
319
"""
320
Get details of a specific OS version.
321
322
Args:
323
location: Azure region name
324
os_version_name: OS version name
325
326
Returns:
327
OS version details
328
"""
329
330
def list_os_versions(location: str) -> Iterable[OSVersion]:
331
"""
332
List available OS versions for cloud services.
333
334
Args:
335
location: Azure region name
336
337
Returns:
338
Iterable of available OS versions
339
"""
340
341
def get_os_family(
342
location: str,
343
os_family_name: str
344
) -> OSFamily:
345
"""
346
Get details of a specific OS family.
347
348
Args:
349
location: Azure region name
350
os_family_name: OS family name
351
352
Returns:
353
OS family details
354
"""
355
356
def list_os_families(location: str) -> Iterable[OSFamily]:
357
"""
358
List available OS families for cloud services.
359
360
Args:
361
location: Azure region name
362
363
Returns:
364
Iterable of available OS families
365
"""
366
```
367
368
## Data Types
369
370
```python { .api }
371
class CloudService:
372
"""Describes the cloud service."""
373
id: Optional[str]
374
name: Optional[str]
375
type: Optional[str]
376
location: str
377
tags: Optional[Dict[str, str]]
378
system_data: Optional[SystemData]
379
properties: Optional[CloudServiceProperties]
380
381
class CloudServiceProperties:
382
"""Cloud service properties."""
383
package_url: Optional[str]
384
configuration: Optional[str]
385
configuration_url: Optional[str]
386
start_cloud_service: Optional[bool]
387
allow_model_override: Optional[bool]
388
upgrade_mode: Optional[CloudServiceUpgradeMode]
389
role_profile: Optional[CloudServiceRoleProfile]
390
os_profile: Optional[CloudServiceOsProfile]
391
network_profile: Optional[CloudServiceNetworkProfile]
392
extension_profile: Optional[CloudServiceExtensionProfile]
393
provisioning_state: Optional[str]
394
unique_id: Optional[str]
395
396
class CloudServiceRole:
397
"""Describes a role of the cloud service."""
398
id: Optional[str]
399
name: Optional[str]
400
type: Optional[str]
401
location: Optional[str]
402
sku: Optional[CloudServiceRoleSku]
403
properties: Optional[CloudServiceRoleProperties]
404
405
class RoleInstance:
406
"""Describes the cloud service role instance."""
407
id: Optional[str]
408
name: Optional[str]
409
type: Optional[str]
410
location: Optional[str]
411
tags: Optional[Dict[str, str]]
412
sku: Optional[InstanceSku]
413
properties: Optional[RoleInstanceProperties]
414
415
class CloudServiceRoleProfile:
416
"""Describes the role profile for the cloud service."""
417
roles: Optional[List[CloudServiceRoleProfileProperties]]
418
419
class CloudServiceOsProfile:
420
"""Describes the OS profile for the cloud service."""
421
secrets: Optional[List[CloudServiceVaultSecretGroup]]
422
423
class CloudServiceNetworkProfile:
424
"""Network Profile for the cloud service."""
425
load_balancer_configurations: Optional[List[LoadBalancerConfiguration]]
426
slot_type: Optional[CloudServiceSlotType]
427
swap_slot_configuration: Optional[CloudServiceSlotConfiguration]
428
429
class CloudServiceExtensionProfile:
430
"""Describes a cloud service extension profile."""
431
extensions: Optional[List[Extension]]
432
433
class UpdateDomain:
434
"""Defines an update domain for the cloud service."""
435
id: Optional[str]
436
name: Optional[str]
437
438
class OSVersion:
439
"""Describes a cloud service OS version."""
440
id: Optional[str]
441
name: Optional[str]
442
type: Optional[str]
443
location: Optional[str]
444
properties: Optional[OSVersionProperties]
445
446
class OSFamily:
447
"""Describes a cloud service OS family."""
448
id: Optional[str]
449
name: Optional[str]
450
type: Optional[str]
451
location: Optional[str]
452
properties: Optional[OSFamilyProperties]
453
```
454
455
## Usage Examples
456
457
### Deploy Cloud Service
458
459
```python
460
from azure.identity import DefaultAzureCredential
461
from azure.mgmt.compute import ComputeManagementClient
462
463
credential = DefaultAzureCredential()
464
compute_client = ComputeManagementClient(credential, "subscription-id")
465
466
# Create cloud service
467
cloud_service_parameters = {
468
'location': 'East US',
469
'properties': {
470
'package_url': 'https://mystorageaccount.blob.core.windows.net/packages/service.cspkg',
471
'configuration_url': 'https://mystorageaccount.blob.core.windows.net/configs/service.cscfg',
472
'start_cloud_service': True,
473
'upgrade_mode': 'Auto',
474
'role_profile': {
475
'roles': [
476
{
477
'name': 'WebRole1',
478
'sku': {
479
'name': 'Standard_D1_v2',
480
'capacity': 2
481
}
482
},
483
{
484
'name': 'WorkerRole1',
485
'sku': {
486
'name': 'Standard_D2_v2',
487
'capacity': 1
488
}
489
}
490
]
491
},
492
'os_profile': {
493
'secrets': []
494
},
495
'network_profile': {
496
'load_balancer_configurations': [
497
{
498
'name': 'myLB',
499
'properties': {
500
'frontend_ip_configurations': [
501
{
502
'name': 'myFrontEnd',
503
'properties': {
504
'public_ip_address': {
505
'id': '/subscriptions/.../publicIPAddresses/myPublicIP'
506
}
507
}
508
}
509
]
510
}
511
}
512
]
513
}
514
},
515
'tags': {
516
'environment': 'production',
517
'application': 'web-service'
518
}
519
}
520
521
operation = compute_client.cloud_services.begin_create_or_update(
522
'myResourceGroup',
523
'myCloudService',
524
cloud_service_parameters
525
)
526
cloud_service = operation.result()
527
print(f"Cloud service deployed: {cloud_service.name}")
528
```
529
530
### Manage Cloud Service Roles
531
532
```python
533
# List roles in the cloud service
534
roles = compute_client.cloud_service_roles.list(
535
'myResourceGroup',
536
'myCloudService'
537
)
538
539
for role in roles:
540
print(f"Role: {role.name}")
541
print(f" SKU: {role.sku.name}")
542
print(f" Capacity: {role.sku.capacity}")
543
544
# List role instances
545
role_instances = compute_client.cloud_service_role_instances.list(
546
'myResourceGroup',
547
'myCloudService'
548
)
549
550
for instance in role_instances:
551
print(f"Instance: {instance.name}")
552
print(f" State: {instance.properties.instance_view.statuses}")
553
print(f" Update Domain: {instance.properties.instance_view.update_domain}")
554
print(f" Fault Domain: {instance.properties.instance_view.fault_domain}")
555
```
556
557
### Perform Rolling Updates
558
559
```python
560
# List update domains
561
update_domains = compute_client.cloud_services_update_domain.list_update_domains(
562
'myResourceGroup',
563
'myCloudService'
564
)
565
566
print("Available update domains:")
567
for domain in update_domains:
568
print(f" Update Domain: {domain.id}")
569
570
# Walk update domain to apply updates
571
compute_client.cloud_services_update_domain.walk_update_domain(
572
'myResourceGroup',
573
'myCloudService',
574
0 # Update domain 0
575
)
576
print("Update domain 0 walked successfully")
577
578
# Check status after update
579
cloud_service = compute_client.cloud_services.get(
580
'myResourceGroup',
581
'myCloudService'
582
)
583
print(f"Service provisioning state: {cloud_service.properties.provisioning_state}")
584
```
585
586
### Manage Operating Systems
587
588
```python
589
# List available OS families
590
os_families = compute_client.cloud_service_operating_systems.list_os_families('East US')
591
592
print("Available OS families:")
593
for family in os_families:
594
print(f" Family: {family.name}")
595
print(f" Label: {family.properties.label}")
596
print(f" Type: {family.properties.type}")
597
598
# List available OS versions for a specific family
599
os_versions = compute_client.cloud_service_operating_systems.list_os_versions('East US')
600
601
print("\nAvailable OS versions:")
602
for version in os_versions:
603
print(f" Version: {version.name}")
604
print(f" Family: {version.properties.family}")
605
print(f" Family Label: {version.properties.family_label}")
606
print(f" Active: {version.properties.is_active}")
607
print(f" Default: {version.properties.is_default}")
608
```
609
610
### Monitor and Control Cloud Service
611
612
```python
613
# Get detailed instance view
614
cloud_service = compute_client.cloud_services.get(
615
'myResourceGroup',
616
'myCloudService'
617
)
618
619
if cloud_service.properties:
620
print(f"Unique ID: {cloud_service.properties.unique_id}")
621
print(f"Provisioning State: {cloud_service.properties.provisioning_state}")
622
623
# Power operations
624
print("Stopping cloud service...")
625
operation = compute_client.cloud_services.begin_power_off(
626
'myResourceGroup',
627
'myCloudService'
628
)
629
operation.result()
630
631
print("Starting cloud service...")
632
operation = compute_client.cloud_services.begin_start(
633
'myResourceGroup',
634
'myCloudService'
635
)
636
operation.result()
637
638
# Restart specific role instance
639
operation = compute_client.cloud_service_role_instances.begin_restart(
640
'myResourceGroup',
641
'myCloudService',
642
'WebRole1_IN_0' # Instance name
643
)
644
operation.result()
645
print("Role instance restarted")
646
647
# Reimage role instance (reinstall OS)
648
operation = compute_client.cloud_service_role_instances.begin_reimage(
649
'myResourceGroup',
650
'myCloudService',
651
'WebRole1_IN_0'
652
)
653
operation.result()
654
print("Role instance reimaged")
655
```