You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-resource-manager/troubleshooting/enable-debug-logging.md
+81-40Lines changed: 81 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,27 +3,28 @@ title: Enable debug logging
3
3
description: Describes how to enable debug logging to troubleshoot Azure resources deployed with Bicep files or Azure Resource Manager templates (ARM templates).
4
4
tags: top-support-issue
5
5
ms.topic: troubleshooting
6
-
ms.date: 09/14/2022
6
+
ms.date: 12/30/2022
7
7
ms.custom: devx-track-azurepowershell
8
8
---
9
9
10
10
# Enable debug logging
11
11
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.
12
+
To troubleshoot a deployment error, you can enable debug logging to get more information. Debug logging works for deployments with 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.
13
13
14
14
> [!WARNING]
15
-
> Debug logging can expose secrets like passwords or `listKeys`. Only enable debug logging when you need to troubleshoot a deployment error.
15
+
> Debug logging can expose secrets like passwords or `listKeys` operations. Only enable debug logging when you need to troubleshoot a deployment error. When you're finished debugging, you should [remove the debug deployment history](#remove-debug-deployment-history).
16
16
17
17
## Set up debug logging
18
18
19
-
Use Azure PowerShell to enable debug logging and view the results with Azure PowerShell or Azure CLI.
19
+
Use Azure PowerShell to enable debug logging that populates the `request` and `response` properties with deployment information for troubleshooting. Debug logging can't be enabled using Azure CLI.
20
20
21
-
# [PowerShell](#tab/azure-powershell)
21
+
Debug logging is only enabled for the main ARM template or Bicep file. If you're using nested ARM templates or Bicep modules, see [Debug nested template](#debug-nested-template).
22
22
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`.
23
+
# [PowerShell](#tab/azure-powershell)
24
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`.
25
+
For a resource group deployment, use [New-AzResourceGroupDeployment](/powershell/module/az.resources/new-azresourcegroupdeployment) and set the `DeploymentDebugLogLevel` parameter to `All`, `ResponseContent`, or `RequestContent`.
26
26
27
+
When debug logging is enabled, a warning is displayed that secrets like passwords or `listKeys` operations can be logged and displayed when you use commands like `Get-AzResourceGroupDeploymentOperation` to get information about deployment operations.
27
28
28
29
```azurepowershell
29
30
New-AzResourceGroupDeployment `
@@ -33,7 +34,7 @@ New-AzResourceGroupDeployment `
33
34
-DeploymentDebugLogLevel All
34
35
```
35
36
36
-
The output shows the debug logging level.
37
+
The deployment's output shows the debug logging level.
@@ -49,13 +50,13 @@ The `DeploymentDebugLogLevel` parameter is available for other deployment scopes
49
50
50
51
You can't enable debug logging with Azure CLI but you can get the debug log's data using the `request` and `response` properties.
51
52
52
-
53
53
---
54
54
55
-
56
55
## Get debug information
57
56
58
-
After debug logging is enabled, you can get more information from the deployment operations.
57
+
After debug logging is enabled, you can get more information about the deployment operations. The Azure PowerShell cmdlets for deployment operations don't output the `request` and `response` properties. You need to use Azure CLI to get the information from those properties.
58
+
59
+
If you don't enable debug logging from the deployment command, you can still get deployment operations information. Use Azure PowerShell or Azure CLI to get the status code, status message, and provisioning state.
The main ARM template and nested templates have their own deployment name and deployment history. The main Bicep file and module also use a separate deployment name and deployment history.
134
+
135
+
### ARM template
136
+
137
+
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) with the `debugSetting` property.
138
+
139
+
The following sample shows a nested template with the `debugSetting` to log the deployment's request and response.
The main ARM template and nested templates have their own deployment name and deployment history. If you want the `request` and `response` properties to contain troubleshooting information, be aware of the following deployment scenarios:
174
+
175
+
- The `request` and `response` properties contain `null` values for the main template and nested template when `DeploymentDebugLogLevel` isn't enabled with deployment command.
176
+
- When the deployment command enables `DeploymentDebugLogLevel` the `request` and `response` properties contain information only for the main template. The nested template's properties contain `null` values.
177
+
- When a nested template uses the `debugSetting` and the deployment command doesn't include `DeploymentDebugLogLevel` only the nested template deployment has values for the `request` and `response` properties. The main template's properties contain `null` values.
178
+
- To get the `request` and `response` for the main template and nested template, specify `DeploymentDebugLogLevel` in the deployment command and use `debugSetting` in the nested template.
179
+
180
+
### Bicep file
181
+
182
+
The recommendation for Bicep files is to use [modules](../bicep/modules.md) rather than nested templates with `Microsoft.Resources/deployments`. The status message, status code, and provisioning state will include information for the main Bicep file and module that you can use to troubleshoot the deployment.
183
+
184
+
If you enable `DeploymentDebugLogLevel` from the deployment command, the `request` and `response` properties will contain information only for the main Bicep file's deployment.
185
+
122
186
## Remove debug deployment history
123
187
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.
188
+
When you're finished debugging, you should remove the deployment history to prevent anyone who has access from seeing sensitive information that might have been logged. For each deployment name that you used while debugging, run the command to remove the deployment history.
125
189
126
190
# [PowerShell](#tab/azure-powershell)
127
191
@@ -148,39 +212,16 @@ To remove deployment history for a resource group deployment, use [az deployment
148
212
az deployment group delete --resource-group examplegroup --name exampledeployment
149
213
```
150
214
215
+
The command returns to the command prompt when it's completed.
216
+
151
217
For more information, see the documentation for deployment scopes: subscription, management group, and tenant.
152
218
153
219
-[az deployment sub delete](/cli/azure/deployment/sub#az-deployment-sub-delete)
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.
163
-
164
-
```json
165
-
{
166
-
"type": "Microsoft.Resources/deployments",
167
-
"apiVersion": "2020-10-01",
168
-
"name": "nestedTemplate",
169
-
"properties": {
170
-
"mode": "Incremental",
171
-
"templateLink": {
172
-
"uri": "{template-uri}",
173
-
"contentVersion": "1.0.0.0"
174
-
},
175
-
"debugSetting": {
176
-
"detailLevel": "requestContent, responseContent"
177
-
}
178
-
}
179
-
}
180
-
```
181
-
182
-
Bicep uses [modules](../bicep/modules.md) rather than nested templates.
0 commit comments