Azure / Azure/azure-powershell
Start-AzImageBuilderTemplate Deletes Resource Group Deployments
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 3d 14h
- Merged PRs (30d)
- 54
Description
### Description
**This is a behavioral issue.** Resource group deployments are deleted after "Start-AzImageBuilderTemplate" cmdlet fails. This prevents anyone from having the ability to diagnose what went wrong in the event of a failure. That cmdlet will create a resource group in Azure, with an auto-generated name; that's where it provisions a VM and attempts to build the image. Provisioning the resources creates a deployment in the resource group. When the cmdlet finishes or fails, it automatically deletes the deployment from the resource group, preventing further diagnosis.
### Issue script & Debug output
```PowerShell
DEBUG: 4:17:51 PM - GetAzureRMContextCommand begin processing with ParameterSet 'GetSingleContext'.
DEBUG: 4:17:51 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 4:17:51 PM - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 4:17:51 PM - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 4:17:51 PM - GetAzureRMContextCommand end processing.
DEBUG: [CmdletBeginProcessing]: Starting command
DEBUG: CmdletBeginProcessing:
DEBUG: CmdletProcessRecordStart:
DEBUG: CmdletGetPipeline:
DEBUG: CmdletBeforeAPICall:
DEBUG: URLCreated: /subscriptions/[obfuscated]/resourceGroups/[obfuscated]/providers/Microsoft.VirtualMachineImages/imageTemplates/PSEXCEL-2024.02.02.1-my-image/run?api-version=2022-07-01
DEBUG: RequestCreated: /subscriptions/[obfuscated]/resourceGroups/[obfuscated]/providers/Microsoft.VirtualMachineImages/imageTemplates/PSEXCEL-2024.02.02.1-my-image/run?api-version=2022-07-01
DEBUG: HeaderParametersAdded:
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
POST
Absolute Uri:
https://management.azure.com/subscriptions/[obfuscated]/resourceGroups/[obfuscated]/providers/Microsoft.VirtualMachineImages/imageTemplates/PSEXCEL-2024.02.02.1-my-image/run?api-version=2022-07-01
Headers:
x-ms-unique-id : 2
x-ms-client-request-id : 5112cdb4-373a-48c0-b594-***
CommandName : Start-AzImageBuilderTemplate
FullCommandName : Start-AzImageBuilderTemplate_Run
ParameterSetName : __AllParameterSets
User-Agent : AzurePowershell/v9.3.0,PSVersion/v7.4.1,Az.ImageBuilder/0.4.0
Body:
DEBUG: BeforeCall:
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
Accepted
Headers:
Cache-Control : no-cache
Pragma : no-cache
Location : https://management.azure.com/subscriptions/[obfuscated]/providers/Microsoft.VirtualMachineImages/locations/eastus/operations/4968c565-a090-4733-9459-****?api-version=2022-07-01&t=638443018720524990&c=[obfuscated]
x-ms-ratelimit-remaining-subscription-writes: 1199
Azure-AsyncOperation : https://management.azure.com/subscriptions/[obfuscated]/providers/Microsoft.VirtualMachineImages/locations/eastus/operations/4968c565-a090-4733-9459-****?api-version=2022-07-01&t=638443018720359105&c=[obfuscated]
x-ms-correlation-request-id : ef6ba98d-efd3-42cc-bc37-****
x-ms-request-id : 4968c565-a090-4733-9459-****
Strict-Transport-Security : max-age=31536000; includeSubDomains
x-ms-routing-request-id : CENTRALUS:20240223T161752Z:ef6ba98d-efd3-42cc-bc37-****
X-Content-Type-Options : nosniff
X-Cache : CONFIG_NOCACHE
X-MSEdge-Ref : Ref A: 43DBF3514EB848CA902E**** Ref B: CH1AA2020611037 Ref C: 2024-02-23T16:17:51Z
Date : Fri, 23 Feb 2024 16:17:51 GMT
Body:
1mDEBUG: ResponseCreated:
1mDEBUG: DelayBeforePolling: Delaying 30 seconds before polling.
1mDEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
GET
Absolute Uri:
https://management.azure.com/subscriptions/[obfuscated]/providers/Microsoft.VirtualMachineImages/locations/eastus/operations/4968c565-a090-4733-9459-****?api-version=2022-07-01&t=638443018720359105&c=[obfuscated]
Headers:
x-ms-unique-id : 3
x-ms-client-request-id : 5112cdb4-373a-48c0-b594-***
CommandName : Start-AzImageBuilderTemplate
FullCommandName : Start-AzImageBuilderTemplate_Run
ParameterSetName : __AllParameterSets
User-Agent : AzurePowershell/v9.3.0,PSVersion/v7.4.1,Az.ImageBuilder/0.4.0
Body:
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
OK
Headers:
Cache-Control : no-cache
Pragma : no-cache
x-ms-ratelimit-remaining-subscription-reads: 11999
x-ms-correlation-request-id : d09d92ac-34bc-4876-9b92-****
x-ms-request-id : 415f7b5d-2db8-4851-bd6d-****
Strict-Transport-Security : max-age=31536000; includeSubDomains
x-ms-routing-request-id : NORTHCENTRALUS:20240223T161822Z:d09d92ac-34bc-4876-9b92-****
X-Content-Type-Options : nosniff
X-Cache : CONFIG_NOCACHE
X-MSEdge-Ref : Ref A: 1CBF46BF994B420CA2**** Ref B: CH1AA2020611037 Ref C: 2024-02-23T16:18:22Z
Date : Fri, 23 Feb 2024 16:18:21 GMT
Body:
{
"name": "4968C565-A090-4733-9459-****",
"status": "InProgress",
"startTime": "2024-02-23T16:17:51.8938374Z"
}
DEBUG: Polling:
DEBUG: DelayBeforePolling: Delaying 30 seconds before polling.
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
GET
Absolute Uri:
https://management.azure.com/subscriptions/[obfuscated]/providers/Microsoft.VirtualMachineImages/locations/eastus/operations/4968c565-a090-4733-9459-****?api-version=2022-07-01&t=638443018720359105&c=[obfuscated]
Headers:
x-ms-unique-id : 4
x-ms-client-request-id : 5112cdb4-373a-48c0-b594-***
CommandName : Start-AzImageBuilderTemplate
FullCommandName : Start-AzImageBuilderTemplate_Run
ParameterSetName : __AllParameterSets
User-Agent : AzurePowershell/v9.3.0,PSVersion/v7.4.1,Az.ImageBuilder/0.4.0
Body:
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
OK
Headers:
Cache-Control : no-cache
Pragma : no-cache
x-ms-ratelimit-remaining-subscription-reads: 11999
x-ms-correlation-request-id : 31726744-ab74-499a-aadc-****
x-ms-request-id : ad56e94c-1a4d-4183-83ad-****
Strict-Transport-Security : max-age=31536000; includeSubDomains
x-ms-routing-request-id : CENTRALUS:20240223T161852Z:31726744-ab74-499a-aadc-****
X-Content-Type-Options : nosniff
X-Cache : CONFIG_NOCACHE
X-MSEdge-Ref : Ref A: 9C8BC9B1BD6247A9ADA9C8**** Ref B: CH1AA2020611037 Ref C: 2024-02-23T16:18:52Z
Date : Fri, 23 Feb 2024 16:18:51 GMT
Body:
{
"name": "4968C565-A090-4733-9459-****",
"status": "InProgress",
"startTime": "2024-02-23T16:17:51.8938374Z"
}
DEBUG: Polling:
DEBUG: DelayBeforePolling: Delaying 30 seconds before polling.
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
GET
Absolute Uri:
https://management.azure.com/subscriptions/[obfuscated]/providers/Microsoft.VirtualMachineImages/locations/eastus/operations/4968c565-a090-4733-9459-****?api-version=2022-07-01&t=638443018720359105&c=[obfuscated]
Headers:
x-ms-unique-id : 5
x-ms-client-request-id : 5112cdb4-373a-48c0-b594-***
CommandName : Start-AzImageBuilderTemplate
FullCommandName : Start-AzImageBuilderTemplate_Run
ParameterSetName : __AllParameterSets
User-Agent : AzurePowershell/v9.3.0,PSVersion/v7.4.1,Az.ImageBuilder/0.4.0
Body:
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
OK
Headers:
Cache-Control : no-cache
Pragma : no-cache
x-ms-ratelimit-remaining-subscription-reads: 11999
x-ms-correlation-request-id : 16b5df9a-15c7-4cf6-b607-****
x-ms-request-id : 248adc32-d8f5-443f-9a66-****
Strict-Transport-Security : max-age=31536000; includeSubDomains
x-ms-routing-request-id : CENTRALUS:20240223T161922Z:16b5df9a-15c7-4cf6-b607-****
X-Content-Type-Options : nosniff
X-Cache : CONFIG_NOCACHE
X-MSEdge-Ref : Ref A: ED04D179044A4B1F87**** Ref B: CH1AA2020611037 Ref C: 2024-02-23T16:19:22Z
Date : Fri, 23 Feb 2024 16:19:22 GMT
Body:
{
"name": "4968C565-A090-4733-9459-****",
"status": "InProgress",
"startTime": "2024-02-23T16:17:51.8938374Z"
}
DEBUG: Polling:
DEBUG: DelayBeforePolling: Delaying 30 seconds before polling.
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
GET
Absolute Uri:
https://management.azure.com/subscriptions/[obfuscated]/providers/Microsoft.VirtualMachineImages/locations/eastus/operations/4968c565-a090-4733-9459-****?api-version=2022-07-01&t=638443018720359105&c=[obfuscated]
Headers:
x-ms-unique-id : 6
x-ms-client-request-id : 5112cdb4-373a-48c0-b594-***
CommandName : Start-AzImageBuilderTemplate
FullCommandName : Start-AzImageBuilderTemplate_Run
ParameterSetName : __AllParameterSets
User-Agent : AzurePowershell/v9.3.0,PSVersion/v7.4.1,Az.ImageBuilder/0.4.0
Body:
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
OK
Headers:
Cache-Control : no-cache
Pragma : no-cache
x-ms-ratelimit-remaining-subscription-reads: 11999
x-ms-correlation-request-id : dc260e45-4b28-48c6-97ab-****
x-ms-request-id : 2391e598-da33-44dd-b68e-****
Strict-Transport-Security : max-age=31536000; includeSubDomains
x-ms-routing-request-id : CENTRALUS:20240223T161953Z:dc260e45-4b28-48c6-97ab-****
X-Content-Type-Options : nosniff
X-Cache : CONFIG_NOCACHE
X-MSEdge-Ref : Ref A: 450A6418EE3748699A26F**** Ref B: CH1AA2020611037 Ref C: 2024-02-23T16:19:53Z
Date : Fri, 23 Feb 2024 16:19:52 GMT
Body:
{
"name": "4968C565-A090-4733-9459-****",
"status": "InProgress",
"startTime": "2024-02-23T16:17:51.8938374Z"
}
DEBUG: Polling:
DEBUG: DelayBeforePolling: Delaying 30 seconds before polling.
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
GET
Absolute Uri:
https://management.azure.com/subscriptions/[obfuscated]/providers/Microsoft.VirtualMachineImages/locations/eastus/operations/4968c565-a090-4733-9459-****?api-version=2022-07-01&t=638443018720359105&c=[obfuscated]
Headers:
x-ms-unique-id : 7
x-ms-client-request-id : 5112cdb4-373a-48c0-b594-***
CommandName : Start-AzImageBuilderTemplate
FullCommandName : Start-AzImageBuilderTemplate_Run
ParameterSetName : __AllParameterSets
User-Agent : AzurePowershell/v9.3.0,PSVersion/v7.4.1,Az.ImageBuilder/0.4.0
Body:
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
OK
Headers:
Cache-Control : no-cache
Pragma : no-cache
x-ms-ratelimit-remaining-subscription-reads: 11997
x-ms-correlation-request-id : 4783afe9-ff36-438b-bd1a-****
x-ms-request-id : de251a4f-9020-4a6c-b4ea-****
Strict-Transport-Security : max-age=31536000; includeSubDomains
x-ms-routing-request-id : CENTRALUS:20240223T162023Z:4783afe9-ff36-438b-bd1a-****
X-Content-Type-Options : nosniff
X-Cache : CONFIG_NOCACHE
X-MSEdge-Ref : Ref A: A52C70EC11784226B5D**** Ref B: CH1AA2020611037 Ref C: 2024-02-23T16:20:23Z
Date : Fri, 23 Feb 2024 16:20:22 GMT
Body:
{
"name": "4968C565-A090-4733-9459-****",
"status": "InProgress",
"startTime": "2024-02-23T16:17:51.8938374Z"
}
DEBUG: Polling:
DEBUG: DelayBeforePolling: Delaying 30 seconds before polling.
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
GET
Absolute Uri:
https://management.azure.com/subscriptions/[obfuscated]/providers/Microsoft.VirtualMachineImages/locations/eastus/operations/4968c565-a090-4733-9459-****?api-version=2022-07-01&t=638443018720359105&c=[obfuscated]
Headers:
x-ms-unique-id : 8
x-ms-client-request-id : 5112cdb4-373a-48c0-b594-***
CommandName : Start-AzImageBuilderTemplate
FullCommandName : Start-AzImageBuilderTemplate_Run
ParameterSetName : __AllParameterSets
User-Agent : AzurePowershell/v9.3.0,PSVersion/v7.4.1,Az.ImageBuilder/0.4.0
Body:
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
OK
Headers:
Cache-Control : no-cache
Pragma : no-cache
x-ms-ratelimit-remaining-subscription-reads: 11999
x-ms-correlation-request-id : 89db2f04-71df-4c0d-a0fa-****
x-ms-request-id : be07ca82-8a45-4142-b762-****
Strict-Transport-Security : max-age=31536000; includeSubDomains
x-ms-routing-request-id : CENTRALUS:20240223T162053Z:89db2f04-71df-4c0d-a0fa-****
X-Content-Type-Options : nosniff
X-Cache : CONFIG_NOCACHE
X-MSEdge-Ref : Ref A: B6EAA9C7886E4E4B8033CD3**** Ref B: CH1AA2020611037 Ref C: 2024-02-23T16:20:53Z
Date : Fri, 23 Feb 2024 16:20:53 GMT
Body:
{
"name": "4968C565-A090-4733-9459-****",
"status": "InProgress",
"startTime": "2024-02-23T16:17:51.8938374Z"
}
DEBUG: Polling:
DEBUG: DelayBeforePolling: Delaying 30 seconds before polling.
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
GET
Absolute Uri:
https://management.azure.com/subscriptions/[obfuscated]/providers/Microsoft.VirtualMachineImages/locations/eastus/operations/4968c565-a090-4733-9459-****?api-version=2022-07-01&t=638443018720359105&c=[obfuscated]
Headers:
x-ms-unique-id : 9
x-ms-client-request-id : 5112cdb4-373a-48c0-b594-***
CommandName : Start-AzImageBuilderTemplate
FullCommandName : Start-AzImageBuilderTemplate_Run
ParameterSetName : __AllParameterSets
User-Agent : AzurePowershell/v9.3.0,PSVersion/v7.4.1,Az.ImageBuilder/0.4.0
Body:
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
OK
Headers:
Cache-Control : no-cache
Pragma : no-cache
x-ms-ratelimit-remaining-subscription-reads: 11999
x-ms-correlation-request-id : 3aee464b-7420-44a7-b2e7-****
x-ms-request-id : ffe0d0ca-d839-4a5b-be8d-****
Strict-Transport-Security : max-age=31536000; includeSubDomains
x-ms-routing-request-id : NORTHCENTRALUS:20240223T162124Z:3aee464b-7420-44a7-b2e7-****
X-Content-Type-Options : nosniff
X-Cache : CONFIG_NOCACHE
X-MSEdge-Ref : Ref A: 634C9C6776624DCC9E90**** Ref B: CH1AA2020611037 Ref C: 2024-02-23T16:21:24Z
Date : Fri, 23 Feb 2024 16:21:23 GMT
Body:
{
"name": "4968C565-A090-4733-9459-****",
"status": "InProgress",
"startTime": "2024-02-23T16:17:51.8938374Z"
}
DEBUG: Polling:
DEBUG: DelayBeforePolling: Delaying 30 seconds before polling.
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
GET
Absolute Uri:
https://management.azure.com/subscriptions/[obfuscated]/providers/Microsoft.VirtualMachineImages/locations/eastus/operations/4968c565-a090-4733-9459-****?api-version=2022-07-01&t=638443018720359105&c=[obfuscated]
Headers:
x-ms-unique-id : 10
x-ms-client-request-id : 5112cdb4-373a-48c0-b594-***
CommandName : Start-AzImageBuilderTemplate
FullCommandName : Start-AzImageBuilderTemplate_Run
ParameterSetName : __AllParameterSets
User-Agent : AzurePowershell/v9.3.0,PSVersion/v7.4.1,Az.ImageBuilder/0.4.0
Body:
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
OK
Headers:
Cache-Control : no-cache
Pragma : no-cache
x-ms-ratelimit-remaining-subscription-reads: 11999
x-ms-correlation-request-id : 2de806df-3dc6-4735-a863-****
x-ms-request-id : b3334317-0932-4bfe-b1d5-****
Strict-Transport-Security : max-age=31536000; includeSubDomains
x-ms-routing-request-id : CENTRALUS:20240223T162154Z:2de806df-3dc6-4735-a863-****
X-Content-Type-Options : nosniff
X-Cache : CONFIG_NOCACHE
X-MSEdge-Ref : Ref A: A020082A16E04F2A9ABD79**** Ref B: CH1AA2020611037 Ref C: 2024-02-23T16:21:54Z
Date : Fri, 23 Feb 2024 16:21:53 GMT
Body:
{
"name": "4968C565-A090-4733-9459-****",
"status": "Failed",
"startTime": "2024-02-23T16:17:51.8938374Z",
"endTime": "2024-02-23T16:21:29.8223361Z",
"error": {
"code": "PackerBuildFailed",
"message": "During the image build a failure has occurred. Packer build logs are at location /subscriptions/[obfuscated]/resourceGroups/IT_[obfuscated]_PSEXCEL-2_6589927b-3015-44bf-89dd-92ea3d05e39e/providers/Microsoft.Storage/storageAccounts/[obfuscated storage name]/blobServices/default/containers/packerlogs/ef6ba98d-efd3-42cc-bc37-****/customization.log. Please navigate to this location using portal or other tools to download logs for identifying which build/customization step failed. Use this operationId 5e819c65-767c-4722-96c5-15db701d34b1 to search packer logs. For more troubleshooting steps go to https://aka.ms/azvmimagebuilderts."
}
}
DEBUG: Polling:
DEBUG: Finally:
DEBUG: CmdletProcessRecordEnd:
DEBUG: [CmdletProcessRecordAsyncEnd]: Finish HTTP process
DEBUG: CmdletProcessRecordAsyncEnd:
##[error]During the image build a failure has occurred. Packer build logs are at location /subscriptions/[obfuscated]/resourceGroups/IT_[obfuscated]_PSEXCEL-2_6589927b-3015-44bf-89dd-92ea3d05e39e/providers/Microsoft.Storage/storageAccounts/[obfuscated storage name]/blobServices/default/containers/packerlogs/ef6ba98d-efd3-42cc-bc37-****/customization.log. Please navigate to this location using portal or other tools to download logs for identifying which build/customization step failed. Use this operationId 5e819c65-767c-4722-96c5-15db701d34b1 to search packer logs. For more troubleshooting steps go to https://aka.ms/azvmimagebuilderts.
##[error]PowerShell exited with code '1'.
Added TLS 1.2 in session.
##[section]Finishing: Run Image Template (If Needed)
```
### Environment data
```PowerShell
PSVersion 7.4.1
PSEdition Core
GitCommitId 7.4.1
OS Microsoft Windows 10.0.20348
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
```
### Module versions
```PowerShell
0.4.0 Az.ImageBuilder
1.2.0 Az.ManagedServiceIdentity
```
### Error output
```PowerShell
N/A
This is a behavioral issue.
```
Contributor guide
Research direction
Start at the Start-AzImageBuilderTemplate entry point and trace the cleanup performed after the image build operation fails. Reproduce the failure using the issue script and verify that the resource group deployment remains available afterward for diagnosis.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp, powershell
- Domain
- cli, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100