@@ -7,7 +7,7 @@ ms.custom: mode-api, devx-track-azurecli, devx-track-azurepowershell, devx-track
7
7
# Customer intent: As a developer I want to use Bicep to create a deployment stack from a template spec.
8
8
---
9
9
10
- # Quickstart: Create and deploy a deployment stack with Bicep from template specs (Preview)
10
+ # Quickstart: Create and deploy a deployment stack with Bicep from template specs
11
11
12
12
This quickstart describes how to create a [ deployment stack] ( deployment-stacks.md ) from a template spec.
13
13
@@ -26,7 +26,7 @@ param resourceGroupLocation string = resourceGroup().location
26
26
param storageAccountName string = 'store${uniqueString(resourceGroup().id)}'
27
27
param vnetName string = 'vnet${uniqueString(resourceGroup().id)}'
28
28
29
- resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09 -01' = {
29
+ resource storageAccount 'Microsoft.Storage/storageAccounts@2023-04 -01' = {
30
30
name: storageAccountName
31
31
location: resourceGroupLocation
32
32
kind: 'StorageV2'
@@ -35,7 +35,7 @@ resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' = {
35
35
}
36
36
}
37
37
38
- resource virtualNetwork 'Microsoft.Network/virtualNetworks@2022 -11-01' = {
38
+ resource virtualNetwork 'Microsoft.Network/virtualNetworks@2023 -11-01' = {
39
39
name: vnetName
40
40
location: resourceGroupLocation
41
41
properties: {
@@ -113,7 +113,7 @@ az group create \
113
113
--name 'demoRg' \
114
114
--location 'centralus'
115
115
116
- id=$(az ts show --name stackSpec --resource-group templateSpecRG --version " 1.0" --query "id" )
116
+ id=$(az ts show --name ' stackSpec' --resource-group ' templateSpecRG' --version ' 1.0' --query 'id' )
117
117
118
118
az stack group create \
119
119
--name demoStack \
@@ -130,14 +130,14 @@ New-AzResourceGroup `
130
130
-Name "demoRg" `
131
131
-Location "eastus"
132
132
133
- $id = (Get-AzTemplateSpec -ResourceGroupName templateSpecRG -Name stackSpec -Version "1.0").Versions.Id
133
+ $id = (Get-AzTemplateSpec -ResourceGroupName " templateSpecRG" -Name " stackSpec" -Version "1.0").Versions.Id
134
134
135
135
New-AzResourceGroupDeploymentStack `
136
- -Name ' demoStack' `
137
- -ResourceGroupName ' demoRg' `
136
+ -Name " demoStack" `
137
+ -ResourceGroupName " demoRg" `
138
138
-TemplateSpecId $id `
139
139
-ActionOnUnmanage "detachAll" `
140
- -DenySettingsMode none
140
+ -DenySettingsMode " none"
141
141
```
142
142
143
143
---
@@ -171,14 +171,14 @@ The output shows two managed resources - one storage account and one virtual net
171
171
"excludedPrincipals": null,
172
172
"mode": "none"
173
173
},
174
- "deploymentId": "/subscriptions/00000000-0000-0000-0000-000000000000/demoRg/providers/Microsoft.Resources/deployments/demoStack-2023-06-08-14-58-28-fd6bb ",
174
+ "deploymentId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ demoRg/providers/Microsoft.Resources/deployments/demoStack-240517162aqmf ",
175
175
"deploymentScope": null,
176
176
"description": null,
177
177
"detachedResources": [],
178
- "duration": "PT30.1685405S ",
178
+ "duration": "PT30.5642429S ",
179
179
"error": null,
180
180
"failedResources": [],
181
- "id": "/subscriptions/00000000-0000-0000-0000-000000000000/demoRg/providers/Microsoft.Resources/deploymentStacks/demoStack",
181
+ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ demoRg/providers/Microsoft.Resources/deploymentStacks/demoStack",
182
182
"location": null,
183
183
"name": "demoStack",
184
184
"outputs": null,
@@ -189,51 +189,62 @@ The output shows two managed resources - one storage account and one virtual net
189
189
"resources": [
190
190
{
191
191
"denyStatus": "none",
192
- "id": "/subscriptions/00000000-0000-0000-0000-000000000000/demoRg/providers/Microsoft.Network/virtualNetworks/vnetthmimleef5fwk",
192
+ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ demoRg/providers/Microsoft.Network/virtualNetworks/vnetthmimleef5fwk",
193
193
"resourceGroup": "demoRg",
194
194
"status": "managed"
195
195
},
196
196
{
197
197
"denyStatus": "none",
198
- "id": "/subscriptions/00000000-0000-0000-0000-000000000000/demoRg/providers/Microsoft.Storage/storageAccounts/storethmimleef5fwk",
198
+ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ demoRg/providers/Microsoft.Storage/storageAccounts/storethmimleef5fwk",
199
199
"resourceGroup": "demoRg",
200
200
"status": "managed"
201
201
}
202
202
],
203
203
"systemData": {
204
- "createdAt": "2023-06-08T14:58:28.377564 +00:00",
205
- "createdBy": "johndole@contoso .com",
204
+ "createdAt": "2024-05-17T16:07:51.172012 +00:00",
205
+ "createdBy": "jgao@microsoft .com",
206
206
"createdByType": "User",
207
- "lastModifiedAt": "2023-06-08T14:58:28.377564 +00:00",
208
- "lastModifiedBy": "johndole@contoso .com",
207
+ "lastModifiedAt": "2024-05-17T16:07:51.172012 +00:00",
208
+ "lastModifiedBy": "jgao@microsoft .com",
209
209
"lastModifiedByType": "User"
210
210
},
211
- "tags": null ,
211
+ "tags": {} ,
212
212
"template": null,
213
- "templateLink": null,
213
+ "templateLink": {
214
+ "contentVersion": null,
215
+ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/templateSpecRG/providers/Microsoft.Resources/templateSpecs/stackSpec/versions/1.0",
216
+ "queryString": null,
217
+ "relativePath": null,
218
+ "resourceGroup": "templateSpecRG",
219
+ "uri": null
220
+ },
214
221
"type": "Microsoft.Resources/deploymentStacks"
215
222
}
216
223
```
217
224
218
225
# [ PowerShell] ( #tab/azure-powershell )
219
226
220
227
``` azurepowershell
221
- Get-AzResourceGroupDeploymentStack -ResourceGroupName demoRg -Name demoStack
228
+ Get-AzResourceGroupDeploymentStack `
229
+ -ResourceGroupName "demoRg" `
230
+ -Name "demoStack"
222
231
```
223
232
224
233
The output shows two managed resources - one virtual network, and one storage account:
225
234
226
235
``` output
227
- Id : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/demoRg/providers/Microsoft.Resources/deploymentStacks/demoStack
228
- Name : demoStack
229
- ProvisioningState : succeeded
230
- ResourcesCleanupAction : detach
231
- ResourceGroupsCleanupAction : detach
232
- DenySettingsMode : none
233
- CreationTime(UTC) : 6/5/2023 8:55:48 PM
234
- DeploymentId : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/demoRg/providers/Microsoft.Resources/deployments/demoStack-2023-06-05-20-55-48-38d09
235
- Resources : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/demoRg/providers/Microsoft.Network/virtualNetworks/vnetzu6pnx54hqubm
236
- /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/demoRg/providers/Microsoft.Storage/storageAccounts/storezu6pnx54hqubm
236
+ Id : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/demoRg/providers/Microsoft.Resources/deploymentStacks/demoStack
237
+ Name : demoStack
238
+ ProvisioningState : succeeded
239
+ resourcesCleanupAction : detach
240
+ resourceGroupsCleanupAction : detach
241
+ managementGroupsCleanupAction : detach
242
+ CorrelationId : e91d07b8-90f0-48f4-b876-07fcadcc4c66
243
+ DenySettingsMode : none
244
+ CreationTime(UTC) : 5/17/2024 3:53:52 PM
245
+ DeploymentId : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/demoRg/providers/Microsoft.Resources/deployments/demoStack-24051715frp6o
246
+ Resources : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/demoRg/providers/Microsoft.Network/virtualNetworks/vnetthmimleef5fwk
247
+ /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/demoRg/providers/Microsoft.Storage/storageAccounts/storethmimleef5fwk
237
248
```
238
249
239
250
---
@@ -244,8 +255,8 @@ You can also verify the deployment by list the managed resources in the deployme
244
255
245
256
``` azurecli
246
257
az stack group show \
247
- --name 'demoStack'
248
- --resource-group 'demoRg'
258
+ --name 'demoStack' \
259
+ --resource-group 'demoRg' \
249
260
--output 'json'
250
261
```
251
262
@@ -266,11 +277,11 @@ The output is similar to:
266
277
"excludedPrincipals": null,
267
278
"mode": "none"
268
279
},
269
- "deploymentId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/demoRg/providers/Microsoft.Resources/deployments/demoStack-2023-06-05-20-55-48-38d09 ",
280
+ "deploymentId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/demoRg/providers/Microsoft.Resources/deployments/demoStack-240517162aqmf ",
270
281
"deploymentScope": null,
271
282
"description": null,
272
283
"detachedResources": [],
273
- "duration": "PT29.006353S ",
284
+ "duration": "PT30.5642429S ",
274
285
"error": null,
275
286
"failedResources": [],
276
287
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/demoRg/providers/Microsoft.Resources/deploymentStacks/demoStack",
@@ -284,28 +295,35 @@ The output is similar to:
284
295
"resources": [
285
296
{
286
297
"denyStatus": "none",
287
- "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/demoRg/providers/Microsoft.Network/virtualNetworks/vnetzu6pnx54hqubm ",
298
+ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/demoRg/providers/Microsoft.Network/virtualNetworks/vnetthmimleef5fwk ",
288
299
"resourceGroup": "demoRg",
289
300
"status": "managed"
290
301
},
291
302
{
292
303
"denyStatus": "none",
293
- "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/demoRg/providers/Microsoft.Storage/storageAccounts/storezu6pnx54hqubm ",
304
+ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/demoRg/providers/Microsoft.Storage/storageAccounts/storethmimleef5fwk ",
294
305
"resourceGroup": "demoRg",
295
306
"status": "managed"
296
307
}
297
308
],
298
309
"systemData": {
299
- "createdAt": "2023-06-05T20:55:48.006789 +00:00",
300
- "createdBy": "johndole@contoso .com",
310
+ "createdAt": "2024-05-17T16:07:51.172012 +00:00",
311
+ "createdBy": "jgao@microsoft .com",
301
312
"createdByType": "User",
302
- "lastModifiedAt": "2023-06-05T20:55:48.006789 +00:00",
303
- "lastModifiedBy": "johndole@contoso .com",
313
+ "lastModifiedAt": "2024-05-17T16:07:51.172012 +00:00",
314
+ "lastModifiedBy": "jgao@microsoft .com",
304
315
"lastModifiedByType": "User"
305
316
},
306
- "tags": null ,
317
+ "tags": {} ,
307
318
"template": null,
308
- "templateLink": null,
319
+ "templateLink": {
320
+ "contentVersion": null,
321
+ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/templateSpecRG/providers/Microsoft.Resources/templateSpecs/stackSpec/versions/1.0",
322
+ "queryString": null,
323
+ "relativePath": null,
324
+ "resourceGroup": "templateSpecRG",
325
+ "uri": null
326
+ },
309
327
"type": "Microsoft.Resources/deploymentStacks"
310
328
}
311
329
```
@@ -321,8 +339,8 @@ The output is similar to:
321
339
``` output
322
340
Status DenyStatus Id
323
341
------ ---------- --
324
- managed none /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/demoRg/providers/Microsoft.Network/virtualNetworks/vnetzu6pnx54hqubm
325
- managed none /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/demoRg/providers/Microsoft.Storage/storageAccounts/storezu6pnx54hqubm
342
+ managed none /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/demoRg/providers/Microsoft.Network/virtualNetworks/vnetthmimleef5fwk
343
+ managed none /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/demoRg/providers/Microsoft.Storage/storageAccounts/storethmimleef5fwk
326
344
```
327
345
328
346
---
@@ -355,8 +373,8 @@ For more information, see [Delete deployment stacks](./deployment-stacks.md#dele
355
373
356
374
``` azurepowershell
357
375
Remove-AzResourceGroupDeploymentStack `
358
- -Name demoStack `
359
- -ResourceGroupName demoRg `
376
+ -Name " demoStack" `
377
+ -ResourceGroupName " demoRg" `
360
378
-ActionOnUnmanage "deleteAll"
361
379
```
362
380
@@ -383,20 +401,36 @@ For more information, see [Delete deployment stacks](./deployment-stacks.md#dele
383
401
384
402
The remove command only remove the managed resources and managed resource groups. You still need to delete the resource group.
385
403
386
- # [ CLI] ( #tab/CLI )
404
+ # [ CLI] ( #tab/azure-cli )
387
405
388
406
``` azurecli
389
407
az group delete --name 'demoRg'
390
408
```
391
409
392
- # [ PowerShell] ( #tab/PowerShell )
410
+ # [ PowerShell] ( #tab/azure-powershell )
393
411
394
412
``` azurepowershell
395
413
Remove-AzResourceGroup -Name "demoRg"
396
414
```
397
415
398
416
---
399
417
418
+ To delete the template spec and the resource group:
419
+
420
+ # [ CLI] ( #tab/azure-cli )
421
+
422
+ ``` azurecli
423
+ az group delete --name 'templateSpecRG'
424
+ ```
425
+
426
+ # [ PowerShell] ( #tab/azure-powershell )
427
+
428
+ ``` azurepowershell
429
+ Remove-AzResourceGroup -Name "templateSpecRG"
430
+ ```
431
+
432
+ ---
433
+
400
434
## Next steps
401
435
402
436
> [ !div class="nextstepaction"]
0 commit comments