Skip to content

Commit 954f528

Browse files
authored
Merge pull request #202174 from davidsmatlak/ds-update-debug-logging
Updates ARM troubleshooting article about debug logging
2 parents 330f4a4 + 90601e7 commit 954f528

File tree

1 file changed

+92
-14
lines changed

1 file changed

+92
-14
lines changed

articles/azure-resource-manager/troubleshooting/enable-debug-logging.md

Lines changed: 92 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,65 @@
11
---
22
title: Enable debug logging
3-
description: Describes how to enable debug logging to troubleshoot Azure resources deployed with Azure Resource Manager templates (ARM templates) or Bicep files.
3+
description: Describes how to enable debug logging to troubleshoot Azure resources deployed with Bicep files or Azure Resource Manager templates (ARM templates).
44
tags: top-support-issue
55
ms.topic: troubleshooting
6-
ms.date: 11/05/2021
6+
ms.date: 06/20/2022
77
ms.custom: devx-track-azurepowershell
88
---
99

1010
# Enable debug logging
1111

12-
To troubleshoot a deployment error, it helps to gather more information. Use Azure PowerShell to enable debug logging. You can get data about a deployment's request and response to learn the cause of the problem. Debug logging works with Azure Resource Manager templates (ARM templates) and Bicep files.
12+
To troubleshoot a deployment error, enable debug logging to get more information. Debug logging works for deployments using Bicep files or Azure Resource Manager templates (ARM templates). You can get data about a deployment's request and response to learn the cause of a problem.
1313

14-
## Get debug information
14+
> [!WARNING]
15+
> Debug logging can expose secrets like passwords or `listKeys`. Only enable debug logging when you need to troubleshoot a deployment error.
16+
17+
## Set up debug logging
18+
19+
Use Azure PowerShell to enable debug logging and view the results with Azure PowerShell or Azure CLI.
1520

1621
# [PowerShell](#tab/azure-powershell)
1722

18-
Use [New-AzResourceGroupDeployment](/powershell/module/az.resources/new-azresourcegroupdeployment) to set the `DeploymentDebugLogLevel` parameter to `All`, `ResponseContent`, or `RequestContent`. When debug logging is enabled, a warning is displayed that secrets like passwords or `listKeys` can be logged by commands like [Get-AzResourceGroupDeploymentOperation](/powershell/module/az.resources/get-azresourcegroupdeploymentoperation).
23+
For a resource group deployment, use [New-AzResourceGroupDeployment](/powershell/module/az.resources/new-azresourcegroupdeployment) to set the `DeploymentDebugLogLevel` parameter to `All`, `ResponseContent`, or `RequestContent`.
24+
25+
When debug logging is enabled, a warning is displayed that secrets like passwords or `listKeys` can be logged and displayed when you get deployment operations with commands like `Get-AzResourceGroupDeploymentOperation`.
26+
1927

2028
```azurepowershell
2129
New-AzResourceGroupDeployment `
2230
-Name exampledeployment `
2331
-ResourceGroupName examplegroup `
24-
-TemplateFile azuredeploy.json `
32+
-TemplateFile main.bicep `
2533
-DeploymentDebugLogLevel All
2634
```
2735

28-
The output shows the debug logging:
36+
The output shows the debug logging level.
2937

3038
```Output
3139
DeploymentDebugLogLevel : RequestContent, ResponseContent
3240
```
3341

34-
To view all the properties for deployment operations:
42+
The `DeploymentDebugLogLevel` parameter is available for other deployment scopes: subscription, management group, and tenant.
43+
44+
- [New-AzDeployment](/powershell/module/az.resources/new-azdeployment)
45+
- [New-AzManagementGroupDeployment](/powershell/module/az.resources/new-azmanagementgroupdeployment)
46+
- [New-AzTenantDeployment](/powershell/module/az.resources/new-aztenantdeployment)
47+
48+
# [Azure CLI](#tab/azure-cli)
49+
50+
You can't enable debug logging with Azure CLI but you can get debug logging data using the `request` and `response` properties.
51+
52+
53+
---
54+
55+
56+
## Get debug information
57+
58+
After debug logging is enabled, you can get more information from the deployment operations.
59+
60+
# [PowerShell](#tab/azure-powershell)
61+
62+
For a resource group deployment, use [Get-AzResourceGroupDeploymentOperation](/powershell/module/az.resources/get-azresourcegroupdeploymentoperation) to get deployment operations.
3563

3664
```azurepowershell
3765
Get-AzResourceGroupDeploymentOperation `
@@ -47,19 +75,24 @@ You can specify a property, like `StatusMessage` or `StatusCode` to filter the o
4775
-ResourceGroupName examplegroup).StatusMessage
4876
```
4977

78+
For more information, see the documentation for deployment operation scopes: subscription, management group, and tenant.
79+
80+
- [Get-AzDeploymentOperation](/powershell/module/az.resources/get-azdeploymentoperation)
81+
- [Get-AzManagementGroupDeploymentOperation](/powershell/module/az.resources/get-azmanagementgroupdeploymentoperation)
82+
- [Get-AzTenantDeploymentOperation](/powershell/module/az.resources/get-aztenantdeploymentoperation)
83+
5084
# [Azure CLI](#tab/azure-cli)
5185

52-
You can't enable debug logging with Azure CLI but you can retrieve debug logging data.
86+
For a resource group deployment, use [az deployment operation group list](/cli/azure/deployment/operation/group#az-deployment-operation-group-list) to get deployment operations.
5387

54-
Get the deployment operations with the [az deployment operation group list](/cli/azure/deployment/operation/group#az-deployment-operation-group-list) command:
5588

5689
```azurecli
5790
az deployment operation group list \
5891
--resource-group examplegroup \
5992
--name exampledeployment
6093
```
6194

62-
Get the request content with the following command:
95+
Use a query to get the `request` property's content.
6396

6497
```azurecli
6598
az deployment operation group list \
@@ -68,7 +101,7 @@ az deployment operation group list \
68101
--query [].properties.request
69102
```
70103

71-
Get the response content with the following command:
104+
Use a query to get the `response` property's content.
72105

73106
```azurecli
74107
az deployment operation group list \
@@ -77,11 +110,56 @@ az deployment operation group list \
77110
--query [].properties.response
78111
```
79112

113+
For more information, see the documentation for deployment operation scopes: subscription, management group, and tenant.
114+
115+
- [az deployment operation sub list](/cli/azure/deployment/operation/sub#az-deployment-operation-sub-list)
116+
- [az deployment operation mg list](/cli/azure/deployment/operation/mg#az-deployment-operation-mg-list)
117+
- [az deployment operation tenant list](/cli/azure/deployment/operation/tenant#az-deployment-operation-tenant-list)
118+
119+
120+
---
121+
122+
## Remove debug deployment history
123+
124+
When you're finished debugging, you can remove deployment history to prevent anyone who has access from seeing sensitive information that might have been logged. If you used multiple deployment names during debugging, run the command for each deployment name.
125+
126+
# [PowerShell](#tab/azure-powershell)
127+
128+
To remove deployment history for a resource group deployment, use [Remove-AzResourceGroupDeployment](/powershell/module/az.resources/remove-azresourcegroupdeployment).
129+
130+
```azurepowershell
131+
Remove-AzResourceGroupDeployment -ResourceGroupName examplegroup -Name exampledeployment
132+
```
133+
134+
The command returns `True` when it's successful.
135+
136+
For more information about deployment history, see the documentation for the deployment scopes: subscription, management group, and tenant.
137+
138+
- [Remove-AzDeployment](/powershell/module/az.resources/remove-azdeployment)
139+
- [Remove-AzManagementGroupDeployment](/powershell/module/az.resources/remove-azmanagementgroupdeployment)
140+
- [Remove-AzTenantDeployment](/powershell/module/az.resources/remove-aztenantdeployment)
141+
142+
143+
# [Azure CLI](#tab/azure-cli)
144+
145+
To remove deployment history for a resource group deployment, use [az deployment group delete](/cli/azure/deployment/group#az-deployment-group-delete).
146+
147+
```azurecli
148+
az deployment group delete --resource-group examplegroup --name exampledeployment
149+
```
150+
151+
For more information, see the documentation for deployment scopes: subscription, management group, and tenant.
152+
153+
- [az deployment sub delete](/cli/azure/deployment/sub#az-deployment-sub-delete)
154+
- [az deployment mg delete](/cli/azure/deployment/mg#az-deployment-mg-delete)
155+
- [az deployment tenant delete](/cli/azure/deployment/tenant#az-deployment-tenant-delete)
156+
157+
80158
---
81159

82160
## Nested template
83161

84-
To log debug information for a [nested](../templates/linked-templates.md#nested-template) ARM template, use the [Microsoft.Resources/deployments](/azure/templates/microsoft.resources/deployments) `debugSetting` element.
162+
To log debug information for a [nested](../templates/linked-templates.md#nested-template) ARM template, use the [Microsoft.Resources/deployments](/azure/templates/microsoft.resources/deployments) `debugSetting` property.
85163

86164
```json
87165
{
@@ -101,7 +179,7 @@ To log debug information for a [nested](../templates/linked-templates.md#nested-
101179
}
102180
```
103181

104-
Bicep uses [modules](../bicep/modules.md) rather than `Microsoft.Resources/deployments`. With modules, you can reuse your code to deploy a Bicep file from another Bicep file.
182+
Bicep uses [modules](../bicep/modules.md) rather than nested templates.
105183

106184
## Next steps
107185

0 commit comments

Comments
 (0)