File: fleets_update.py

package info (click to toggle)
python-azure 20250603%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 851,724 kB
  • sloc: python: 7,362,925; ansic: 804; javascript: 287; makefile: 195; sh: 145; xml: 109
file content (355 lines) | stat: -rw-r--r-- 22,329 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) Python Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from azure.identity import DefaultAzureCredential

from azure.mgmt.computefleet import ComputeFleetMgmtClient

"""
# PREREQUISITES
    pip install azure-identity
    pip install azure-mgmt-computefleet
# USAGE
    python fleets_update.py

    Before run the sample, please set the values of the client ID, tenant ID and client secret
    of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
    AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
    https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""


def main():
    client = ComputeFleetMgmtClient(
        credential=DefaultAzureCredential(),
        subscription_id="SUBSCRIPTION_ID",
    )

    response = client.fleets.begin_update(
        resource_group_name="rgazurefleet",
        fleet_name="testFleet",
        properties={
            "identity": {"type": "UserAssigned", "userAssignedIdentities": {}},
            "plan": {
                "name": "jwgrcrnrtfoxn",
                "product": "cgopbyvdyqikahwyxfpzwaqk",
                "promotionCode": "naglezezplcaruqogtxnuizslqnnbr",
                "publisher": "iozjbiqqckqm",
                "version": "wa",
            },
            "properties": {
                "computeProfile": {
                    "baseVirtualMachineProfile": {
                        "applicationProfile": {
                            "galleryApplications": [
                                {
                                    "configurationReference": "ulztmiavpojpbpbddgnuuiimxcpau",
                                    "enableAutomaticUpgrade": True,
                                    "order": 5,
                                    "packageReferenceId": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{applicationName}/versions/{versionName}",
                                    "tags": "eyrqjbib",
                                    "treatFailureAsDeploymentFailure": True,
                                }
                            ]
                        },
                        "capacityReservation": {
                            "capacityReservationGroup": {
                                "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}"
                            }
                        },
                        "diagnosticsProfile": {
                            "bootDiagnostics": {
                                "enabled": True,
                                "storageUri": "http://myStorageAccountName.blob.core.windows.net",
                            }
                        },
                        "extensionProfile": {
                            "extensions": [
                                {
                                    "name": "bndxuxx",
                                    "properties": {
                                        "autoUpgradeMinorVersion": True,
                                        "enableAutomaticUpgrade": True,
                                        "forceUpdateTag": "yhgxw",
                                        "protectedSettings": {},
                                        "protectedSettingsFromKeyVault": {
                                            "secretUrl": "https://myVaultName.vault.azure.net/secrets/secret/mySecretName",
                                            "sourceVault": {
                                                "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}"
                                            },
                                        },
                                        "provisionAfterExtensions": ["nftzosroolbcwmpupujzqwqe"],
                                        "publisher": "kpxtirxjfprhs",
                                        "settings": {},
                                        "suppressFailures": True,
                                        "type": "pgjilctjjwaa",
                                        "typeHandlerVersion": "zevivcoilxmbwlrihhhibq",
                                    },
                                }
                            ],
                            "extensionsTimeBudget": "mbhjahtdygwgyszdwjtvlvtgchdwil",
                        },
                        "hardwareProfile": {"vmSizeProperties": {"vCPUsAvailable": 16, "vCPUsPerCore": 23}},
                        "licenseType": "v",
                        "networkProfile": {
                            "healthProbe": {
                                "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}"
                            },
                            "networkApiVersion": "2020-11-01",
                            "networkInterfaceConfigurations": [
                                {
                                    "name": "i",
                                    "properties": {
                                        "auxiliaryMode": "None",
                                        "auxiliarySku": "None",
                                        "deleteOption": "Delete",
                                        "disableTcpStateTracking": True,
                                        "dnsSettings": {"dnsServers": ["nxmmfolhclsesu"]},
                                        "enableAcceleratedNetworking": True,
                                        "enableFpga": True,
                                        "enableIPForwarding": True,
                                        "ipConfigurations": [
                                            {
                                                "name": "oezqhkidfhyywlfzwuotilrpbqnjg",
                                                "properties": {
                                                    "applicationGatewayBackendAddressPools": [
                                                        {
                                                            "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}/backendAddressPools/{backendAddressPoolName}"
                                                        }
                                                    ],
                                                    "applicationSecurityGroups": [
                                                        {
                                                            "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationSecurityGroups/{applicationSecurityGroupName}"
                                                        }
                                                    ],
                                                    "loadBalancerBackendAddressPools": [
                                                        {
                                                            "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/backendAddressPools/{backendAddressPoolName}"
                                                        }
                                                    ],
                                                    "loadBalancerInboundNatPools": [
                                                        {
                                                            "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/inboundNatPools/{inboundNatPoolName}"
                                                        }
                                                    ],
                                                    "primary": True,
                                                    "privateIPAddressVersion": "IPv4",
                                                    "publicIPAddressConfiguration": {
                                                        "name": "fvpqf",
                                                        "properties": {
                                                            "deleteOption": "Delete",
                                                            "dnsSettings": {
                                                                "domainNameLabel": "ukrddzvmorpmfsczjwtbvp",
                                                                "domainNameLabelScope": "TenantReuse",
                                                            },
                                                            "idleTimeoutInMinutes": 9,
                                                            "ipTags": [
                                                                {
                                                                    "ipTagType": "sddgsoemnzgqizale",
                                                                    "tag": "wufmhrjsakbiaetyara",
                                                                }
                                                            ],
                                                            "publicIPAddressVersion": "IPv4",
                                                            "publicIPPrefix": {
                                                                "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPPrefixes/{publicIPPrefixName}"
                                                            },
                                                        },
                                                        "sku": {"name": "Basic", "tier": "Regional"},
                                                    },
                                                    "subnet": {
                                                        "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}"
                                                    },
                                                },
                                            }
                                        ],
                                        "networkSecurityGroup": {
                                            "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}"
                                        },
                                        "primary": True,
                                    },
                                }
                            ],
                        },
                        "osProfile": {
                            "adminPassword": "adfbrdxpv",
                            "adminUsername": "nrgzqciiaaxjrqldbmjbqkyhntp",
                            "allowExtensionOperations": True,
                            "computerNamePrefix": "o",
                            "customData": "xjjib",
                            "linuxConfiguration": {
                                "disablePasswordAuthentication": True,
                                "enableVMAgentPlatformUpdates": True,
                                "patchSettings": {
                                    "assessmentMode": "ImageDefault",
                                    "automaticByPlatformSettings": {
                                        "bypassPlatformSafetyChecksOnUserSchedule": True,
                                        "rebootSetting": "Unknown",
                                    },
                                    "patchMode": "ImageDefault",
                                },
                                "provisionVMAgent": True,
                                "ssh": {"publicKeys": [{"keyData": "kivgsubusvpprwqaqpjcmhsv", "path": "kmqz"}]},
                            },
                            "requireGuestProvisionSignal": True,
                            "secrets": [
                                {
                                    "sourceVault": {
                                        "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}"
                                    },
                                    "vaultCertificates": [
                                        {
                                            "certificateStore": "nlxrwavpzhueffxsshlun",
                                            "certificateUrl": "https://myVaultName.vault.azure.net/secrets/myCertName",
                                        }
                                    ],
                                }
                            ],
                            "windowsConfiguration": {
                                "additionalUnattendContent": [
                                    {
                                        "componentName": "Microsoft-Windows-Shell-Setup",
                                        "content": "bubmqbxjkj",
                                        "passName": "OobeSystem",
                                        "settingName": "AutoLogon",
                                    }
                                ],
                                "enableAutomaticUpdates": True,
                                "enableVMAgentPlatformUpdates": True,
                                "patchSettings": {
                                    "assessmentMode": "ImageDefault",
                                    "automaticByPlatformSettings": {
                                        "bypassPlatformSafetyChecksOnUserSchedule": True,
                                        "rebootSetting": "Unknown",
                                    },
                                    "enableHotpatching": True,
                                    "patchMode": "Manual",
                                },
                                "provisionVMAgent": True,
                                "timeZone": "hlyjiqcfksgrpjrct",
                                "winRM": {
                                    "listeners": [
                                        {
                                            "certificateUrl": "https://myVaultName.vault.azure.net/secrets/myCertName",
                                            "protocol": "Http",
                                        }
                                    ]
                                },
                            },
                        },
                        "scheduledEventsProfile": {
                            "osImageNotificationProfile": {
                                "enable": True,
                                "notBeforeTimeout": "olbpadmevekyczfokodtfprxti",
                            },
                            "terminateNotificationProfile": {"enable": True, "notBeforeTimeout": "iljppmmw"},
                        },
                        "securityPostureReference": {
                            "excludeExtensions": ["{securityPostureVMExtensionName}"],
                            "id": "/CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|{major.*}|latest",
                            "isOverridable": True,
                        },
                        "securityProfile": {
                            "encryptionAtHost": True,
                            "encryptionIdentity": {
                                "userAssignedIdentityResourceId": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{userAssignedIdentityName}"
                            },
                            "proxyAgentSettings": {"enabled": True, "keyIncarnationId": 20, "mode": "Audit"},
                            "securityType": "TrustedLaunch",
                            "uefiSettings": {"secureBootEnabled": True, "vTpmEnabled": True},
                        },
                        "serviceArtifactReference": {
                            "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/serviceArtifacts/{serviceArtifactsName}/vmArtifactsProfiles/{vmArtifactsProfileName}"
                        },
                        "storageProfile": {
                            "dataDisks": [
                                {
                                    "caching": "None",
                                    "createOption": "FromImage",
                                    "deleteOption": "Delete",
                                    "diskIOPSReadWrite": 27,
                                    "diskMBpsReadWrite": 2,
                                    "diskSizeGB": 6,
                                    "lun": 14,
                                    "managedDisk": {
                                        "diskEncryptionSet": {
                                            "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"
                                        },
                                        "securityProfile": {
                                            "diskEncryptionSet": {
                                                "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"
                                            },
                                            "securityEncryptionType": "VMGuestStateOnly",
                                        },
                                        "storageAccountType": "Standard_LRS",
                                    },
                                    "name": "eogiykmdmeikswxmigjws",
                                    "writeAcceleratorEnabled": True,
                                }
                            ],
                            "diskControllerType": "uzb",
                            "imageReference": {
                                "communityGalleryImageId": "vlqe",
                                "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageName}/versions/{versionName}",
                                "offer": "isxgumkarlkomp",
                                "publisher": "mqxgwbiyjzmxavhbkd",
                                "sharedGalleryImageId": "kmkgihoxwlawuuhcinfirktdwkmx",
                                "sku": "eojmppqcrnpmxirtp",
                                "version": "wvpcqefgtmqdgltiuz",
                            },
                            "osDisk": {
                                "caching": "None",
                                "createOption": "FromImage",
                                "deleteOption": "Delete",
                                "diffDiskSettings": {"option": "Local", "placement": "CacheDisk"},
                                "diskSizeGB": 14,
                                "image": {
                                    "uri": "https://myStorageAccountName.blob.core.windows.net/myContainerName/myVhdName.vhd"
                                },
                                "managedDisk": {
                                    "diskEncryptionSet": {
                                        "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"
                                    },
                                    "securityProfile": {
                                        "diskEncryptionSet": {
                                            "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"
                                        },
                                        "securityEncryptionType": "VMGuestStateOnly",
                                    },
                                    "storageAccountType": "Standard_LRS",
                                },
                                "name": "wfttw",
                                "osType": "Windows",
                                "vhdContainers": ["tkzcwddtinkfpnfklatw"],
                                "writeAcceleratorEnabled": True,
                            },
                        },
                        "userData": "s",
                    },
                    "computeApiVersion": "2023-07-01",
                    "platformFaultDomainCount": 1,
                },
                "regularPriorityProfile": {"allocationStrategy": "LowestPrice", "capacity": 20, "minCapacity": 10},
                "spotPriorityProfile": {
                    "allocationStrategy": "PriceCapacityOptimized",
                    "capacity": 20,
                    "evictionPolicy": "Delete",
                    "maintain": True,
                    "maxPricePerVM": 0.00865,
                    "minCapacity": 10,
                },
                "vmSizesProfile": [{"name": "Standard_d1_v2", "rank": 19225}],
            },
            "tags": {},
        },
    ).result()
    print(response)


# x-ms-original-file: 2024-11-01/Fleets_Update.json
if __name__ == "__main__":
    main()