Skip to content

Commit 55b9e97

Browse files
[Maps] az maps account create: Add default value for --sku (#32711)
1 parent 9a9b4bc commit 55b9e97

4 files changed

Lines changed: 181 additions & 3 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def load_arguments(self, _):
4040
with self.argument_context('maps account') as c:
4141
c.argument('name', options_list=['--sku', '-s'], arg_type=get_enum_type(['S0', 'S1', 'G2']),
4242
help='The name of the SKU, in standard format (such as S0).', arg_group='Sku',
43-
required=True)
43+
required=False)
4444
c.argument('tags', arg_type=tags_type)
4545

4646
with self.argument_context('maps account create') as c:

src/azure-cli/azure/cli/command_modules/maps/custom.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
def maps_account_create(client,
1414
resource_group_name,
1515
account_name,
16-
name,
16+
name=None,
1717
tags=None,
1818
kind=None,
1919
location=None,
@@ -60,7 +60,7 @@ def maps_account_create(client,
6060
if user_assigned_identities is not None:
6161
maps_account['identity']['user_assigned_identities'] = user_assigned_identities
6262
maps_account['sku'] = {}
63-
maps_account['sku']['name'] = name
63+
maps_account['sku']['name'] = name or 'G2'
6464
return client.create_or_update(resource_group_name=resource_group_name,
6565
account_name=account_name,
6666
maps_account=maps_account)
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
Accept:
6+
- application/json
7+
Accept-Encoding:
8+
- gzip, deflate
9+
CommandName:
10+
- maps account create
11+
Connection:
12+
- keep-alive
13+
ParameterSetName:
14+
- -n -g --accept-tos
15+
User-Agent:
16+
- AZURECLI/2.83.0 azsdk-python-core/1.38.0 Python/3.12.3 (Linux-6.14.0-1019-oem-x86_64-with-glibc2.39)
17+
method: GET
18+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/clitest.rg000001?api-version=2024-11-01
19+
response:
20+
body:
21+
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001","name":"clitest.rg000001","type":"Microsoft.Resources/resourceGroups","location":"eastus","tags":{"product":"azurecli","cause":"automation","test":"test_create_maps_account_default_sku","date":"2026-01-30T18:42:50Z","module":"maps"},"properties":{"provisioningState":"Succeeded"}}'
22+
headers:
23+
cache-control:
24+
- no-cache
25+
content-length:
26+
- '372'
27+
content-type:
28+
- application/json; charset=utf-8
29+
date:
30+
- Fri, 30 Jan 2026 18:42:51 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: CDF1126C1CD2479DA5AB450516F4A8D0 Ref B: CO6AA3150220019 Ref C: 2026-01-30T18:42:51Z'
45+
status:
46+
code: 200
47+
message: OK
48+
- request:
49+
body: '{"location": "eastus", "sku": {"name": "G2"}, "kind": "Gen2", "properties":
50+
{"disableLocalAuth": false}}'
51+
headers:
52+
Accept:
53+
- application/json
54+
Accept-Encoding:
55+
- gzip, deflate
56+
CommandName:
57+
- maps account create
58+
Connection:
59+
- keep-alive
60+
Content-Length:
61+
- '104'
62+
Content-Type:
63+
- application/json
64+
ParameterSetName:
65+
- -n -g --accept-tos
66+
User-Agent:
67+
- AZURECLI/2.83.0 azsdk-python-core/1.38.0 Python/3.12.3 (Linux-6.14.0-1019-oem-x86_64-with-glibc2.39)
68+
method: PUT
69+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Maps/accounts/cli-000002?api-version=2021-02-01
70+
response:
71+
body:
72+
string: "{\n \"kind\": \"Gen2\",\n \"type\": \"Microsoft.Maps/accounts\",\n
73+
\ \"sku\": {\n \"name\": \"G2\",\n \"tier\": \"Standard\"\n },\n \"properties\":
74+
{\n \"uniqueId\": \"4f0b64d9-9297-4f82-907d-242d9755a479\",\n \"provisioningState\":
75+
\"Succeeded\",\n \"disableLocalAuth\": false\n },\n \"systemData\": {\n
76+
\ \"createdBy\": \"test@example.com\",\n \"createdByType\": \"User\",\n
77+
\ \"createdAt\": \"2026-01-30T18:42:52.0356936Z\",\n \"lastModifiedBy\":
78+
\"test@example.com\",\n \"lastModifiedByType\": \"User\",\n \"lastModifiedAt\":
79+
\"2026-01-30T18:42:52.0356936Z\"\n },\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Maps/accounts/cli-000002\",\n
80+
\ \"name\": \"cli-000002\",\n \"location\": \"eastus\"\n}"
81+
headers:
82+
cache-control:
83+
- no-cache
84+
content-length:
85+
- '716'
86+
content-type:
87+
- application/json; charset=utf-8
88+
date:
89+
- Fri, 30 Jan 2026 18:42:51 GMT
90+
expires:
91+
- '-1'
92+
pragma:
93+
- no-cache
94+
strict-transport-security:
95+
- max-age=31536000; includeSubDomains
96+
x-cache:
97+
- CONFIG_NOCACHE
98+
x-content-type-options:
99+
- nosniff
100+
x-ms-operation-identifier:
101+
- tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=94556a74-c808-4753-8463-17c50f6f75f7/eastus/89eadfd2-5a0c-4bb6-82b9-82a99e72e7bd
102+
x-ms-ratelimit-remaining-subscription-global-writes:
103+
- '11999'
104+
x-ms-ratelimit-remaining-subscription-writes:
105+
- '799'
106+
x-msedge-ref:
107+
- 'Ref A: ECEBFC9BE5B2474AAB389AA79A323E91 Ref B: CO6AA3150219053 Ref C: 2026-01-30T18:42:51Z'
108+
status:
109+
code: 201
110+
message: Created
111+
- request:
112+
body: null
113+
headers:
114+
Accept:
115+
- application/json
116+
Accept-Encoding:
117+
- gzip, deflate
118+
CommandName:
119+
- maps account delete
120+
Connection:
121+
- keep-alive
122+
Content-Length:
123+
- '0'
124+
ParameterSetName:
125+
- -n -g
126+
User-Agent:
127+
- AZURECLI/2.83.0 azsdk-python-core/1.38.0 Python/3.12.3 (Linux-6.14.0-1019-oem-x86_64-with-glibc2.39)
128+
method: DELETE
129+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Maps/accounts/cli-000002?api-version=2021-02-01
130+
response:
131+
body:
132+
string: ''
133+
headers:
134+
cache-control:
135+
- no-cache
136+
content-length:
137+
- '0'
138+
date:
139+
- Fri, 30 Jan 2026 18:42:52 GMT
140+
expires:
141+
- '-1'
142+
pragma:
143+
- no-cache
144+
strict-transport-security:
145+
- max-age=31536000; includeSubDomains
146+
x-cache:
147+
- CONFIG_NOCACHE
148+
x-content-type-options:
149+
- nosniff
150+
x-ms-operation-identifier:
151+
- tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=94556a74-c808-4753-8463-17c50f6f75f7/eastus/8c565c68-4abc-47e9-9825-637d95898d95
152+
x-ms-ratelimit-remaining-subscription-deletes:
153+
- '799'
154+
x-ms-ratelimit-remaining-subscription-global-deletes:
155+
- '11999'
156+
x-msedge-ref:
157+
- 'Ref A: B44CE51390EE480E8D620223DE45AEEF Ref B: MWH011020809025 Ref C: 2026-01-30T18:42:52Z'
158+
status:
159+
code: 200
160+
message: OK
161+
version: 1

src/azure-cli/azure/cli/command_modules/maps/tests/latest/test_maps_commands.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,23 @@
99

1010

1111
class MapsScenarioTests(ScenarioTest):
12+
@ResourceGroupPreparer(key='rg', location="eastus")
13+
def test_create_maps_account_default_sku(self, resource_group):
14+
"""Test that creating a maps account without --sku defaults to G2."""
15+
self.kwargs.update({
16+
'name': self.create_random_name(prefix='cli-', length=20),
17+
})
18+
19+
# Create account without specifying --sku, should default to G2
20+
account = self.cmd('az maps account create -n {name} -g {rg} --accept-tos',
21+
checks=[
22+
self.check('name', '{name}'),
23+
self.check('resourceGroup', '{rg}'),
24+
self.check('sku.name', 'G2')
25+
]).get_output_in_json()
26+
27+
# Clean up
28+
self.cmd('az maps account delete -n {name} -g {rg}')
1229

1330
@ResourceGroupPreparer(key='rg', location="eastus")
1431
@ResourceGroupPreparer(key='rg1', location="eastus")

0 commit comments

Comments
 (0)