Skip to content

Commit 4cb0d0a

Browse files
committed
address comments
1 parent 584c8c6 commit 4cb0d0a

File tree

7 files changed

+669
-227
lines changed

7 files changed

+669
-227
lines changed

src/azure-cli/azure/cli/command_modules/vm/_params.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ def load_arguments(self, _):
765765
c.argument('data_disk_delete_option', arg_type=get_enum_type(self.get_models('DiskDeleteOptionTypes')), min_api='2022-03-01', arg_group='Storage', help='Specify whether data disk should be deleted or detached upon VMSS Flex deletion (This feature is only for VMSS with flexible orchestration mode)')
766766
c.argument('skuprofile_vmsizes', nargs='+', min_api='2024-07-01', help='A list of VM sizes in the scale set. See https://azure.microsoft.com/pricing/details/virtual-machines/ for size info.')
767767
c.argument('skuprofile_allostrat', options_list=['--skuprofile-allocation-strategy', '--sku-allocat-strat'], arg_type=get_enum_type(['LowestPrice', 'CapacityOptimized', 'Prioritized']), min_api='2024-07-01', help='Allocation strategy for vm sizes in SKU profile.')
768-
c.argument('skuprofile_rank', nargs='+', min_api='2024-11-01', help='A list for ranks associated with the skuprofile vmsizes.')
768+
c.argument('skuprofile_rank', nargs='+', min_api='2024-11-01', help='A list for ranks associated with the SKU profile vm sizes.')
769769

770770
with self.argument_context('vmss create', arg_group='Network Balancer') as c:
771771
c.argument('application_gateway', help='Name to use when creating a new application gateway (default) or referencing an existing one. Can also reference an existing application gateway by ID or specify "" for none.', options_list=['--app-gateway'])
@@ -815,7 +815,7 @@ def load_arguments(self, _):
815815
c.argument('zones', zones_type, min_api='2023-03-01')
816816
c.argument('skuprofile_vmsizes', nargs='+', min_api='2024-07-01', help='A list of VM sizes in the scale set. See https://azure.microsoft.com/pricing/details/virtual-machines/ for size info.')
817817
c.argument('skuprofile_allostrat', options_list=['--skuprofile-allocation-strategy', '--sku-allocat-strat'], arg_type=get_enum_type(['LowestPrice', 'CapacityOptimized', 'Prioritized']), min_api='2024-07-01', help='Allocation strategy for vm sizes in SKU profile.')
818-
c.argument('skuprofile_rank', nargs='+', min_api='2024-11-01', help='A list for ranks associated with the skuprofile vmsizes.')
818+
c.argument('skuprofile_rank', nargs='+', min_api='2024-11-01', help='A list for ranks associated with the SKU profile vm sizes.')
819819

820820
with self.argument_context('vmss update', min_api='2018-10-01', arg_group='Automatic Repairs') as c:
821821

src/azure-cli/azure/cli/command_modules/vm/_template_builder.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,6 +1652,11 @@ def build_vmss_resource(cmd, name, computer_name_prefix, location, tags, overpro
16521652
sku_profile_vmsizes_list.append(vmsize_obj)
16531653

16541654
if skuprofile_rank:
1655+
if len(skuprofile_rank) != len(skuprofile_vmsizes):
1656+
raise ValidationError(
1657+
'The SKU profile rank list does not specify a rank for every VM size. ' +
1658+
'The number of ranks must match the number of VM sizes.')
1659+
16551660
for vm_size, rank in zip(sku_profile_vmsizes_list, skuprofile_rank):
16561661
vm_size['rank'] = rank
16571662

src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vmss_create_sku_profile.yaml

Lines changed: 95 additions & 49 deletions
Large diffs are not rendered by default.

src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vmss_create_sku_profile_prioritized.yaml

Lines changed: 137 additions & 91 deletions
Large diffs are not rendered by default.
Lines changed: 334 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,334 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
Accept:
6+
- application/json
7+
Accept-Encoding:
8+
- gzip, deflate
9+
CommandName:
10+
- vmss create
11+
Connection:
12+
- keep-alive
13+
ParameterSetName:
14+
- -n -g --image --vm-sku --skuprofile-vmsizes --skuprofile-rank --skuprofile-allocation-strategy
15+
User-Agent:
16+
- AZURECLI/2.71.0 azsdk-python-core/1.31.0 Python/3.10.11 (Windows-10-10.0.26100-SP0)
17+
method: GET
18+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vmss_create_sku_profile_prioritized_validation000001?api-version=2022-09-01
19+
response:
20+
body:
21+
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_create_sku_profile_prioritized_validation000001","name":"cli_test_vmss_create_sku_profile_prioritized_validation000001","type":"Microsoft.Resources/resourceGroups","location":"eastus2","tags":{"product":"azurecli","cause":"automation","test":"test_vmss_create_sku_profile_prioritized_validation","date":"2025-04-29T21:31:47Z","module":"vm"},"properties":{"provisioningState":"Succeeded"}}'
22+
headers:
23+
cache-control:
24+
- no-cache
25+
content-length:
26+
- '476'
27+
content-type:
28+
- application/json; charset=utf-8
29+
date:
30+
- Tue, 29 Apr 2025 21:31:46 GMT
31+
expires:
32+
- '-1'
33+
pragma:
34+
- no-cache
35+
strict-transport-security:
36+
- max-age=31536000; includeSubDomains
37+
x-cache:
38+
- CONFIG_NOCACHE
39+
x-content-type-options:
40+
- nosniff
41+
x-ms-ratelimit-remaining-subscription-global-reads:
42+
- '16499'
43+
x-msedge-ref:
44+
- 'Ref A: A3D8D36DC4D44D9FB0FEAAE5C8E2E109 Ref B: MWH011020806060 Ref C: 2025-04-29T21:31:47Z'
45+
status:
46+
code: 200
47+
message: OK
48+
- request:
49+
body: null
50+
headers:
51+
Accept:
52+
- '*/*'
53+
Accept-Encoding:
54+
- gzip, deflate
55+
Connection:
56+
- keep-alive
57+
User-Agent:
58+
- python-requests/2.32.3
59+
method: GET
60+
uri: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/arm-compute/quickstart-templates/aliases.json
61+
response:
62+
body:
63+
string: "{\n \"$schema\": \"http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json\"\
64+
,\n \"contentVersion\": \"1.0.0.0\",\n \"parameters\": {},\n \"variables\"\
65+
: {},\n \"resources\": [],\n \"outputs\": {\n \"aliases\": {\n \"\
66+
type\": \"object\",\n \"value\": {\n \"Linux\": {\n \"\
67+
CentOS85Gen2\": {\n \"publisher\": \"OpenLogic\",\n \
68+
\ \"offer\": \"CentOS\",\n \"sku\": \"8_5-gen2\",\n \
69+
\ \"version\": \"latest\",\n \"architecture\": \"x64\"\n \
70+
\ },\n \"Debian11\": {\n \"publisher\": \"Debian\"\
71+
,\n \"offer\": \"debian-11\",\n \"sku\": \"11-backports-gen2\"\
72+
,\n \"version\": \"latest\",\n \"architecture\": \"\
73+
x64\"\n },\n \"OpenSuseLeap154Gen2\": {\n \"\
74+
publisher\": \"SUSE\",\n \"offer\": \"openSUSE-leap-15-4\",\n \
75+
\ \"sku\": \"gen2\",\n \"version\": \"latest\",\n \
76+
\ \"architecture\": \"x64\"\n },\n \"RHELRaw8LVMGen2\"\
77+
: {\n \"publisher\": \"RedHat\",\n \"offer\": \"RHEL\"\
78+
,\n \"sku\": \"8-lvm-gen2\",\n \"version\": \"latest\"\
79+
,\n \"architecture\": \"x64\"\n },\n \"SuseSles15SP5\"\
80+
: {\n \"publisher\": \"SUSE\",\n \"offer\": \"sles-15-sp5\"\
81+
,\n \"sku\": \"gen2\",\n \"version\": \"latest\",\n\
82+
\ \"architecture\": \"x64\"\n },\n \"Ubuntu2204\"\
83+
: {\n \"publisher\": \"Canonical\",\n \"offer\": \"\
84+
0001-com-ubuntu-server-jammy\",\n \"sku\": \"22_04-lts-gen2\",\n\
85+
\ \"version\": \"latest\",\n \"architecture\": \"x64\"\
86+
\n },\n \"Ubuntu2404\": {\n \"publisher\": \"\
87+
Canonical\",\n \"offer\": \"ubuntu-24_04-lts\",\n \"\
88+
sku\": \"server\",\n \"version\": \"latest\",\n \"architecture\"\
89+
: \"x64\"\n },\n \"Ubuntu2404Pro\": {\n \"publisher\"\
90+
: \"Canonical\",\n \"offer\": \"ubuntu-24_04-lts\",\n \
91+
\ \"sku\": \"ubuntu-pro\",\n \"version\": \"latest\",\n \
92+
\ \"architecture\": \"x64\"\n },\n \"FlatcarLinuxFreeGen2\"\
93+
: {\n \"publisher\": \"kinvolk\",\n \"offer\": \"flatcar-container-linux-free\"\
94+
,\n \"sku\": \"stable-gen2\",\n \"version\": \"latest\"\
95+
,\n \"architecture\": \"x64\"\n }\n },\n \
96+
\ \"Windows\": {\n \"Win2022Datacenter\": {\n \"publisher\"\
97+
: \"MicrosoftWindowsServer\",\n \"offer\": \"WindowsServer\",\n\
98+
\ \"sku\": \"2022-datacenter-g2\",\n \"version\": \"\
99+
latest\",\n \"architecture\": \"x64\"\n },\n \
100+
\ \"Win2022AzureEditionCore\": {\n \"publisher\": \"MicrosoftWindowsServer\"\
101+
,\n \"offer\": \"WindowsServer\",\n \"sku\": \"2022-datacenter-azure-edition-core\"\
102+
,\n \"version\": \"latest\",\n \"architecture\": \"\
103+
x64\"\n },\n \"Win2019Datacenter\": {\n \"publisher\"\
104+
: \"MicrosoftWindowsServer\",\n \"offer\": \"WindowsServer\",\n\
105+
\ \"sku\": \"2019-datacenter-gensecond\",\n \"version\"\
106+
: \"latest\",\n \"architecture\": \"x64\"\n },\n \
107+
\ \"Win2016Datacenter\": {\n \"publisher\": \"MicrosoftWindowsServer\"\
108+
,\n \"offer\": \"WindowsServer\",\n \"sku\": \"2016-datacenter-gensecond\"\
109+
,\n \"version\": \"latest\",\n \"architecture\": \"\
110+
x64\"\n },\n \"Win2012R2Datacenter\": {\n \"\
111+
publisher\": \"MicrosoftWindowsServer\",\n \"offer\": \"WindowsServer\"\
112+
,\n \"sku\": \"2012-R2-Datacenter\",\n \"version\":\
113+
\ \"latest\",\n \"architecture\": \"x64\"\n },\n \
114+
\ \"Win2012Datacenter\": {\n \"publisher\": \"MicrosoftWindowsServer\"\
115+
,\n \"offer\": \"WindowsServer\",\n \"sku\": \"2012-Datacenter\"\
116+
,\n \"version\": \"latest\",\n \"architecture\": \"\
117+
x64\"\n }\n }\n }\n }\n }\n}\n"
118+
headers:
119+
accept-ranges:
120+
- bytes
121+
access-control-allow-origin:
122+
- '*'
123+
cache-control:
124+
- max-age=300
125+
connection:
126+
- keep-alive
127+
content-length:
128+
- '3790'
129+
content-security-policy:
130+
- default-src 'none'; style-src 'unsafe-inline'; sandbox
131+
content-type:
132+
- text/plain; charset=utf-8
133+
cross-origin-resource-policy:
134+
- cross-origin
135+
date:
136+
- Tue, 29 Apr 2025 21:31:47 GMT
137+
etag:
138+
- W/"0f53b56eda413b90fc6365dd4848831171968adfbf5b440c8da07b5866a97d67"
139+
expires:
140+
- Tue, 29 Apr 2025 21:36:47 GMT
141+
source-age:
142+
- '0'
143+
strict-transport-security:
144+
- max-age=31536000
145+
vary:
146+
- Authorization,Accept-Encoding,Origin
147+
via:
148+
- 1.1 varnish
149+
x-cache:
150+
- HIT
151+
x-cache-hits:
152+
- '0'
153+
x-content-type-options:
154+
- nosniff
155+
x-fastly-request-id:
156+
- 012ef96f60eb7e1cb63c2dc7dd7ca0b255bf7185
157+
x-frame-options:
158+
- deny
159+
x-github-request-id:
160+
- 8693:1682B3:EEE8DC:1177C76:6810FF81
161+
x-served-by:
162+
- cache-bfi-krnt7300071-BFI
163+
x-timer:
164+
- S1745962307.458515,VS0,VE151
165+
x-xss-protection:
166+
- 1; mode=block
167+
status:
168+
code: 200
169+
message: OK
170+
- request:
171+
body: null
172+
headers:
173+
Accept:
174+
- application/json
175+
Accept-Encoding:
176+
- gzip, deflate
177+
CommandName:
178+
- vmss create
179+
Connection:
180+
- keep-alive
181+
ParameterSetName:
182+
- -n -g --image --vm-sku --skuprofile-vmsizes --skuprofile-rank --skuprofile-allocation-strategy
183+
User-Agent:
184+
- AZURECLI/2.71.0 azsdk-python-core/1.31.0 Python/3.10.11 (Windows-10-10.0.26100-SP0)
185+
method: GET
186+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus2/publishers/Canonical/artifacttypes/vmimage/offers/0001-com-ubuntu-server-jammy/skus/22_04-lts-gen2/versions?$top=1&$orderby=name%20desc&api-version=2024-11-01
187+
response:
188+
body:
189+
string: "[\r\n {\r\n \"location\": \"eastus2\",\r\n \"name\": \"22.04.202504250\"\
190+
,\r\n \"id\": \"/Subscriptions/00000000-0000-0000-0000-000000000000/Providers/Microsoft.Compute/Locations/eastus2/Publishers/Canonical/ArtifactTypes/VMImage/Offers/0001-com-ubuntu-server-jammy/Skus/22_04-lts-gen2/Versions/22.04.202504250\"\
191+
\r\n }\r\n]"
192+
headers:
193+
cache-control:
194+
- no-cache
195+
content-length:
196+
- '309'
197+
content-type:
198+
- application/json; charset=utf-8
199+
date:
200+
- Tue, 29 Apr 2025 21:31:47 GMT
201+
expires:
202+
- '-1'
203+
pragma:
204+
- no-cache
205+
strict-transport-security:
206+
- max-age=31536000; includeSubDomains
207+
x-cache:
208+
- CONFIG_NOCACHE
209+
x-content-type-options:
210+
- nosniff
211+
x-ms-operation-identifier:
212+
- tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=12346924-f56c-4d61-b610-f67437f7ab4d/westus2/17398b9f-b7c0-45a8-894f-5bf2118821a6
213+
x-ms-ratelimit-remaining-resource:
214+
- Microsoft.Compute/ListVMImagesVersionsFromLocation3Min;15996,Microsoft.Compute/ListVMImagesVersionsFromLocation30Min;43973
215+
x-ms-ratelimit-remaining-subscription-global-reads:
216+
- '16499'
217+
x-msedge-ref:
218+
- 'Ref A: A1075A422DD8442786028CFF2DCEEFE6 Ref B: MWH011020806062 Ref C: 2025-04-29T21:31:47Z'
219+
status:
220+
code: 200
221+
message: OK
222+
- request:
223+
body: null
224+
headers:
225+
Accept:
226+
- application/json
227+
Accept-Encoding:
228+
- gzip, deflate
229+
CommandName:
230+
- vmss create
231+
Connection:
232+
- keep-alive
233+
ParameterSetName:
234+
- -n -g --image --vm-sku --skuprofile-vmsizes --skuprofile-rank --skuprofile-allocation-strategy
235+
User-Agent:
236+
- AZURECLI/2.71.0 azsdk-python-core/1.31.0 Python/3.10.11 (Windows-10-10.0.26100-SP0)
237+
method: GET
238+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus2/publishers/Canonical/artifacttypes/vmimage/offers/0001-com-ubuntu-server-jammy/skus/22_04-lts-gen2/versions/22.04.202504250?api-version=2024-11-01
239+
response:
240+
body:
241+
string: "{\r\n \"properties\": {\r\n \"hyperVGeneration\": \"V2\",\r\n \
242+
\ \"architecture\": \"x64\",\r\n \"replicaType\": \"Managed\",\r\n \
243+
\ \"replicaCount\": 10,\r\n \"disallowed\": {\r\n \"vmDiskType\"\
244+
: \"Unmanaged\"\r\n },\r\n \"automaticOSUpgradeProperties\": {\r\n \
245+
\ \"automaticOSUpgradeSupported\": false\r\n },\r\n \"imageDeprecationStatus\"\
246+
: {\r\n \"imageState\": \"Active\"\r\n },\r\n \"features\": [\r\
247+
\n {\r\n \"name\": \"SecurityType\",\r\n \"value\": \"\
248+
TrustedLaunchSupported\"\r\n },\r\n {\r\n \"name\": \"IsAcceleratedNetworkSupported\"\
249+
,\r\n \"value\": \"True\"\r\n },\r\n {\r\n \"name\"\
250+
: \"DiskControllerTypes\",\r\n \"value\": \"SCSI, NVMe\"\r\n },\r\
251+
\n {\r\n \"name\": \"IsHibernateSupported\",\r\n \"value\"\
252+
: \"True\"\r\n }\r\n ],\r\n \"osDiskImage\": {\r\n \"operatingSystem\"\
253+
: \"Linux\",\r\n \"sizeInGb\": 30\r\n },\r\n \"dataDiskImages\"\
254+
: [],\r\n \"goLiveDate\": \"2025-04-26T00:00:00+00:00\"\r\n },\r\n \"\
255+
location\": \"eastus2\",\r\n \"name\": \"22.04.202504250\",\r\n \"id\":\
256+
\ \"/Subscriptions/00000000-0000-0000-0000-000000000000/Providers/Microsoft.Compute/Locations/eastus2/Publishers/Canonical/ArtifactTypes/VMImage/Offers/0001-com-ubuntu-server-jammy/Skus/22_04-lts-gen2/Versions/22.04.202504250\"\
257+
\r\n}"
258+
headers:
259+
cache-control:
260+
- no-cache
261+
content-length:
262+
- '1208'
263+
content-type:
264+
- application/json; charset=utf-8
265+
date:
266+
- Tue, 29 Apr 2025 21:31:48 GMT
267+
expires:
268+
- '-1'
269+
pragma:
270+
- no-cache
271+
strict-transport-security:
272+
- max-age=31536000; includeSubDomains
273+
x-cache:
274+
- CONFIG_NOCACHE
275+
x-content-type-options:
276+
- nosniff
277+
x-ms-operation-identifier:
278+
- tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=12346924-f56c-4d61-b610-f67437f7ab4d/westus2/0a7d6825-37c6-4367-bab2-5da53ac07df7
279+
x-ms-ratelimit-remaining-resource:
280+
- Microsoft.Compute/GetVMImageFromLocation3Min;12996,Microsoft.Compute/GetVMImageFromLocation30Min;73988
281+
x-ms-ratelimit-remaining-subscription-global-reads:
282+
- '16499'
283+
x-msedge-ref:
284+
- 'Ref A: 605DAC1DDB5448BF9E5BE7E1AC81EA6E Ref B: CO6AA3150217011 Ref C: 2025-04-29T21:31:48Z'
285+
status:
286+
code: 200
287+
message: OK
288+
- request:
289+
body: null
290+
headers:
291+
Accept:
292+
- application/json
293+
Accept-Encoding:
294+
- gzip, deflate
295+
CommandName:
296+
- vmss create
297+
Connection:
298+
- keep-alive
299+
ParameterSetName:
300+
- -n -g --image --vm-sku --skuprofile-vmsizes --skuprofile-rank --skuprofile-allocation-strategy
301+
User-Agent:
302+
- AZURECLI/2.71.0 azsdk-python-core/1.31.0 Python/3.10.11 (Windows-10-10.0.26100-SP0)
303+
method: GET
304+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_create_sku_profile_prioritized_validation000001/providers/Microsoft.Network/virtualNetworks?api-version=2022-01-01
305+
response:
306+
body:
307+
string: '{"value":[]}'
308+
headers:
309+
cache-control:
310+
- no-cache
311+
content-length:
312+
- '12'
313+
content-type:
314+
- application/json; charset=utf-8
315+
date:
316+
- Tue, 29 Apr 2025 21:31:48 GMT
317+
expires:
318+
- '-1'
319+
pragma:
320+
- no-cache
321+
strict-transport-security:
322+
- max-age=31536000; includeSubDomains
323+
x-cache:
324+
- CONFIG_NOCACHE
325+
x-content-type-options:
326+
- nosniff
327+
x-ms-ratelimit-remaining-subscription-global-reads:
328+
- '16499'
329+
x-msedge-ref:
330+
- 'Ref A: F4AC570E355F4C3B8602BD9B7F609100 Ref B: CO6AA3150220023 Ref C: 2025-04-29T21:31:49Z'
331+
status:
332+
code: 200
333+
message: OK
334+
version: 1

0 commit comments

Comments
 (0)