Skip to content

Commit 2f6822c

Browse files
authored
Refreshed, reflowed, converted to link refs (#5387)
1 parent 694a0bf commit 2f6822c

File tree

4 files changed

+111
-49
lines changed

4 files changed

+111
-49
lines changed

docs-ref-conceptual/Latest-version/cheat-sheet-onboarding.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ try new commands without incurring costs.
103103
[10]: ./interactive-azure-cli.md
104104
[11]: ./use-azure-cli-successfully-bash.md
105105
[12]: ./use-azure-cli-successfully-query.md
106-
[13]: ./use-azure-cli-successfully-troubleshooting.md#the---debug-parameter
106+
[13]: ./use-azure-cli-successfully-troubleshooting.md#the-debug-parameter
107107
[14]: /azure/cloud-shell/quickstart?toc=%2fcli%2fazure%2ftoc.json&bc=%2fcli%2fazure%2fbreadcrumb%2ftoc.json
108108
[15]: /cli/azure/azure-cli-configuration#configure-settings-using-az-config
109109
[16]: /cli/azure/choose-the-right-azure-command-line-tool#azure-cli-vs-azure-powershell-side-by-side-command-comparison

docs-ref-conceptual/Latest-version/get-started-with-azure-cli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ az feedback
222222
[manage-default-sub]: ./get-started-tutorial-1-prepare-environment.md#find-and-change-your-active-subscription
223223
[resource-random-name]: ./get-started-tutorial-1-prepare-environment.md#create-a-resource-group-containing-a-random-id
224224
[environment-variables]: ./get-started-tutorial-1-prepare-environment.md#set-environment-variables
225-
[debug]: ./use-azure-cli-successfully-troubleshooting.md#the---debug-parameter
225+
[debug]: ./use-azure-cli-successfully-troubleshooting.md#the-debug-parameter
226226
[delete-resources]: ./get-started-tutorial-4-delete-resources.md#delete-multiple-azure-resources-using-a-script
227227
[syntax-diffs]: ./get-started-tutorial-2-environment-syntax.md
228228
[feedback]: https://github.com/azure/azure-cli/issues

docs-ref-conceptual/Latest-version/use-azure-cli-successfully-quoting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ flag reveals the actual arguments received by the Azure CLI in [Python's syntax]
309309

310310

311311

312-
For more information on troubleshooting Azure CLI commands with `--debug`, see [Troubleshooting Azure CLI](./use-azure-cli-successfully-troubleshooting.md#the---debug-parameter).
312+
For more information on troubleshooting Azure CLI commands with `--debug`, see [Troubleshooting Azure CLI](./use-azure-cli-successfully-troubleshooting.md#the-debug-parameter).
313313

314314
## Scripting language rules
315315

docs-ref-conceptual/Latest-version/use-azure-cli-successfully-troubleshooting.md

Lines changed: 108 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
2-
title: Troubleshoot Azure CLI | Microsoft Docs
2+
title: Troubleshooting Azure CLI | Microsoft Docs
33
description: Learn to use the Azure CLI successfully by understanding common Azure CLI errors and how to fix them.
4-
ms.date: 12/10/2024
54
ms.custom: devx-track-azurecli
65
#customer intent: As an Azure CLI customer, I want to be able to search for Azure CLI errors and receive more explanation than what is available from the in-line error message. Just don't tell me what an error is, also tell me how to fix it.
76
---
@@ -15,16 +14,17 @@ Most errors returned by the Azure CLI fall into one of these categories:
1514
|Error category | General error cause |
1615
|-|-|
1716
|Unrecognized argument | A parameter is misspelled or doesn't exist.
18-
|[Required argument missing](#error-arguments-are-expected-or-required) | A required parameter isn't specified or only one of two "parameter pairs" is specified. A parameter might also be misspelled.
17+
|[Required argument missing][13] | A required parameter isn't specified or only one of two "parameter pairs" is specified. A parameter might also be misspelled.
1918
|Mutually exclusive argument | Two or more parameters can't be specified together.
20-
|[Invalid argument value](#error-invalid-value-or-doesnt-exist) | Parameter _value_ isn't valid. This error is often due to quoting, an escape character or spacing.
19+
|[Invalid argument value][14] | Parameter _value_ isn't valid. This error is often due to quoting, an escape character or spacing.
2120
|Bad request | An HTTP status code of 400 returns this error. Check for a missing space, missing parameter dash, or an extra or missing single or double quotation mark. This error also happens when a parameter value doesn't contain an allowed value.
22-
|[Resource not found](#error-resource-not-found) | An Azure resource referenced in a parameter value can't be found.
21+
|[Resource not found][15] | An Azure resource referenced in a parameter value can't be found.
2322
|Authentication | Microsoft Entra authentication failed.
2423

25-
## The `--debug` parameter
24+
## The debug parameter
2625

27-
One of the best ways to see what the Azure CLI is executing for each Azure CLI reference command is to use the `--debug` parameter. Here's examples of `--debug` for both a failed and successful command:
26+
One of the best ways to see what the Azure CLI is executing for each reference command is to use the
27+
`--debug` parameter. Here are examples of `--debug` for both a failed and successful command:
2828

2929
```azurecli
3030
# Error example: Create a resource group, but omit the quotes around the resource group name.
@@ -42,7 +42,7 @@ cli.azure.cli.core.azclierror: unrecognized arguments: msdocs-rg-test
4242
...
4343
```
4444

45-
Compare the error `--debug` output given above to a successful execution:
45+
Compare the error `--debug` output given in the earlier example to a successful execution:
4646

4747
```azurecli
4848
# Correct example: Because the resource group name contains special characters, enclose it in quotes
@@ -80,38 +80,55 @@ cli.azure.cli.core.sdk.policies: {"id":"/subscriptions/00000000-0000-0000-0000-0
8080
cli.__main__: Command ran in 1.829 seconds (init: 0.111, invoke: 1.718)
8181
```
8282

83-
For examples of `--debug` for JSON formatting, see [Quoting differences between scripting languages - JSON strings](./use-azure-cli-successfully-quoting.md#json-strings).
83+
For examples of `--debug` for JSON formatting, see
84+
[Quoting differences between scripting languages - JSON strings][08].
8485

8586
## Common syntax errors
8687

87-
Although the Azure CLI can run in both Bash, PowerShell and Windows Cmd, there are syntax differences between scripting languages. Azure CLI scripts containing single quotes, double quotes, and escape characters usually must be modified when copied between languages. This challenge reveals itself most often in parameter values, especially in values assigned to the `--query` parameter. Here are some common error messages:
88+
Although the Azure CLI can run in Bash, PowerShell, and the Windows Command Prompt (`cmd.exe`),
89+
there are syntax differences between scripting languages. Azure CLI scripts containing single
90+
quotes, double quotes, and escape characters often require modification when copied between
91+
languages. This challenge is most often revealed in parameter values, particularly in those assigned
92+
to the `--query` parameter. Here are some common error messages:
8893

89-
* "**Bad request ...{something} is invalid**" might be caused by a space, single or double quotation mark, or lack of a quote.
94+
- **Bad request ...{something} is invalid**: This error might be caused by a space, single or double
95+
quotation mark, or lack of a quote.
9096

91-
* "**Unexpected token...**" is seen when there's an extra space or quote.
97+
- **Unexpected token...**: This error is seen when there's an extra space or quote.
9298

93-
* "**Invalid jmespath_type value**" error often comes from incorrect quoting in the `--query` parameter.
99+
- **Invalid jmespath_type value**: This error often comes from incorrect quoting in the `--query`
100+
parameter.
94101

95-
* "**Variable reference is not valid**" is received when a string isn't formatted properly often due to concatenation or a missing escape character.
102+
- **Variable reference is not valid**: This error is received when a string isn't formatted
103+
properly, often due to concatenation or a missing escape character.
96104

97-
* "**Unrecognized arguments**" is often caused by an incorrect line continuation character or misspelled parameter name.
105+
- **Unrecognized arguments**: This error is often caused by an incorrect line continuation character
106+
or misspelled parameter name.
98107

99-
* "**Missing expression after unary operator**" is seen when a line continuation character is missing.
108+
- **Missing expression after unary operator**: This error is seen when a line continuation character
109+
is missing.
100110

101-
There are several Azure CLI articles dedicated to explaining syntax errors and providing working examples:
111+
There are several Azure CLI articles dedicated to explaining syntax errors and providing working
112+
examples:
102113

103-
* [Quoting differences between scripting languages](./use-azure-cli-successfully-quoting.md)
104-
* [Syntax differences in Bash, PowerShell, and Cmd](./get-started-tutorial-2-environment-syntax.md) tutorial
105-
* Find many `--query` parameter examples in [How-to query Azure CLI command output using a JMESPath query](./use-azure-cli-successfully-query.md)
106-
* [How-to use the Azure CLI in a Bash scripting language](./use-azure-cli-successfully-bash.md)
107-
* [Considerations for running the Azure CLI in a PowerShell scripting language](./use-azure-cli-successfully-powershell.md)
114+
- [Quoting differences between scripting languages][07]
115+
- [Syntax differences in Bash, PowerShell, and Cmd][03] tutorial
116+
- Find many `--query` parameter examples in
117+
[How-to query Azure CLI command output using a JMESPath query][06]
118+
- [How-to use the Azure CLI in a Bash scripting language][04]
119+
- [Considerations for running the Azure CLI in a PowerShell scripting language][05]
108120

109121
> [!TIP]
110-
> If you can't resolve a command error, try using a different scripting language. **Most Azure CLI documentation is written and tested in Azure Cloud Shell (ACS) with a Bash scripting language.** If you can get an article example to execute in ACS Bash, but it won't execute in Windows PowerShell, review your use of single and double quotes, and escape characters.
122+
> If you can't resolve a command error, try using a different scripting language. Most Azure CLI
123+
> documentation is written and tested in Azure Cloud Shell, which uses the Bash scripting language.
124+
> If you can get an article example to execute in Bash, but it doesn't execute in PowerShell, review
125+
> your use of single and double quotes, and escape characters.
111126
112127
## Error: Invalid value or doesn't exist
113128

114-
These errors often occur when trying to use a variable value that contains an incorrect format. The default output for Azure CLI is JSON, so if you're trying to store an ID for an Azure resource in a variable, you must specify `--output tsv`. Here's an example:
129+
These errors often occur when trying to use variable values that contain an incorrect format. The
130+
default output for Azure CLI is JSON. If you're trying to store an ID for an Azure resource in a
131+
variable, you must specify `--output tsv`. Here's an example:
115132

116133
```azurecli
117134
# Get a subscription that contains a name or phrase
@@ -144,32 +161,43 @@ az account set --subscription $subscriptionID
144161

145162
## Error: Arguments are expected or required
146163

147-
You receive this error when an Azure CLI command is missing a required parameter, or _there's a typographical error that causes the Azure CLI to incorrectly parse the reference command_. When working with a script, you also receive this error when one or more conditions are true:
164+
You receive this error when an Azure CLI command is missing a required parameter, or there's a
165+
typographical error that causes the Azure CLI to incorrectly parse the reference command. When
166+
working with a script, you also receive this error when one or more conditions are true:
148167

149-
* A line continuation character is missing or incorrect.
150-
* A trailing space exists on the right side of a line continuation character when working in the PowerShell scripting language. At this time, [splatting](/powershell/module/microsoft.powershell.core/about/about_splatting) isn't supported with Azure CLI commands.
151-
* A variable name contains a special character, such as a dash (-).
168+
- A line continuation character is missing or incorrect.
169+
- A trailing space exists on the right side of a line continuation character when working in the
170+
PowerShell scripting language. PowerShell [splatting][12] is only supported with arrays and not
171+
hash tables with Azure CLI commands.
172+
- A variable name contains a special character, such as a dash (-).
152173

153174
## Error: Resource not found
154175

155-
When the Azure CLI can't find the resource name or ID passed in a parameter value, it's usually because of one of these reasons:
176+
When the Azure CLI can't find the resource name or ID passed in a parameter value, it's usually
177+
because of one of these reasons:
156178

157-
* The resource name or ID is spelled incorrectly.
158-
* The resource name contains special characters and isn't surrounded by single or double quotes.
159-
* The value being passed to a variable has unseen leading or trailing spaces.
160-
* The resource exists, but is in a different subscription.
179+
- The resource name or ID is spelled incorrectly.
180+
- The resource name contains special characters and isn't surrounded by single or double quotes.
181+
- The value being passed to a variable has unseen leading or trailing spaces.
182+
- The resource exists, but is in a different subscription.
161183

162184
## Error: Failed to parse string as JSON
163185

164-
There are quoting differences between Bash, PowerShell in Linux, and PowerShell in Windows. Furthermore, different versions of PowerShell can produce different results. For complex parameters, like a JSON string, the best practice is to use Azure CLI's `@<file>` convention to bypass a shell's interpretation. For more information, see one of these articles:
186+
There are quoting differences between Bash, PowerShell in Linux, and PowerShell in Windows.
187+
Furthermore, different versions of PowerShell can produce different results. For complex parameters,
188+
such as a JSON string, the best practice is to use Azure CLI's `@<file>` convention to bypass the
189+
shell's interpretation. For more information, see one of these articles:
165190

166-
For JSON syntax examples for Bash, PowerShell and Cmd.exe, see [Quoting differences between scripting languages - JSON strings](./use-azure-cli-successfully-quoting.md#json-strings) tutorial.
191+
For JSON syntax examples for Bash, PowerShell, and `cmd.exe`, see
192+
[Quoting differences between scripting languages - JSON strings][08] tutorial.
167193

168194
## Error: InvalidTemplateDeployment
169195

170-
When you try to create an Azure resource in a location that doesn't offer that resource, you receive an error similar to this message: "Following SKUs have failed for Capacity Restrictions: myDesiredSkuName' is currently not available in location 'mySpecifiedLocation'."
196+
When you try to create an Azure resource in a location that doesn't offer that resource, you receive
197+
an error similar to this message: "Following SKUs have failed for Capacity Restrictions:
198+
myDesiredSkuName' is currently not available in location 'mySpecifiedLocation'".
171199

172-
Here's a full error example for a VM that can't be created in the `westus` location:
200+
Here's a complete error example for a VM that can't be created in the `westus` location:
173201

174202
```azurecli
175203
{"error":{"code":"InvalidTemplateDeployment","message":"The template deployment 'vm_deploy_<32 character ID>'
@@ -184,15 +212,22 @@ The solution is to change a property of your requested Azure resource, or try a
184212

185213
## Error: Subscription not found
186214

187-
Assuming that you have not incorrectly typed a subscription name or ID, this error occurs when a resource provider is not registered in the active subscription. For example, if you want to execute `az storage account create`, the `Microsoft.Storage` provider must be registered. To register a resource provider, see [Azure resource providers and types](/azure/azure-resource-manager/management/resource-providers-and-types).
215+
Assuming that you didn't type in the subscription name or ID incorrectly, this error occurs when a
216+
resource provider isn't registered in the active subscription. For example, if you want to execute
217+
`az storage account create`, the `Microsoft.Storage` provider must be registered. To register a
218+
resource provider, see [Azure resource providers and types][10].
188219

189-
## Error: Bad handshake...certificate verify failed
220+
## Error: Bad handshake certificate verify failed
190221

191-
See [Work behind a proxy](#work-behind-a-proxy) for information on how to resolve this error.
222+
See [Work behind a proxy][16] for information on how to resolve this error.
192223

193224
## Work behind a proxy
194225

195-
If you're using Azure CLI over a proxy server that uses self-signed certificates, the Python [requests library](https://github.com/kennethreitz/requests) used by the Azure CLI might cause the following error: `SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')],)",)`. To address this error, set the environment variable `REQUESTS_CA_BUNDLE` to the path of CA bundle certificate file in PEM format.
226+
If you're using Azure CLI over a proxy server that uses self-signed certificates, the Python
227+
[requests library][18] used by the Azure CLI might cause the following error:
228+
`SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')],)",)`.
229+
To address this error, set the environment variable `REQUESTS_CA_BUNDLE` to the path of CA bundle
230+
certificate file in PEM format.
196231

197232
| OS | Default certificate authority bundle |
198233
|---|---|
@@ -202,7 +237,8 @@ If you're using Azure CLI over a proxy server that uses self-signed certificates
202237
| CentOS Stream/RHEL/SUSE Linux | `/usr/lib64/az/lib/python<version>/site-packages/certifi/cacert.pem` |
203238
| macOS | Intel models: `/usr/local/Cellar/azure-cli/<cliversion>/libexec/lib/python<version>/site-packages/certifi/cacert.pem` <br><br>Silicon models: `/opt/homebrew/Cellar/azure-cli/<cliversion>/libexec/lib/python<version>/site-packages/certifi/cacert.pem`|
204239

205-
Append the proxy server's certificate to the CA bundle certificate file, or copy the contents to another certificate file. Then set `REQUESTS_CA_BUNDLE` to the new file location. Here's an example:
240+
Append the proxy server's certificate to the CA bundle certificate file, or copy the contents to
241+
another certificate file. Then set `REQUESTS_CA_BUNDLE` to the new file location. Here's an example:
206242

207243
```console
208244
<Original cacert.pem>
@@ -212,16 +248,42 @@ Append the proxy server's certificate to the CA bundle certificate file, or copy
212248
-----END CERTIFICATE-----
213249
```
214250

215-
Some proxies require authentication. The format of the `HTTP_PROXY` or `HTTPS_PROXY` environment variables should include the authentication, such as `HTTPS_PROXY="https://username:password@proxy-server:port"`. For details, see [How to configure proxies for the Azure SDK for Python](/azure/developer/python/sdk/azure-sdk-configure-proxy?tabs=bash).
251+
Some proxies require authentication. The format of the `HTTP_PROXY` or `HTTPS_PROXY` environment
252+
variables should include the authentication, such as
253+
`HTTPS_PROXY="https://username:password@proxy-server:port"`. For details, see
254+
[How to configure proxies for the Azure SDK for Python][11].
216255

217256
## Service principals
218257

219-
For information on troubleshooting service principals, see [Cleanup and Troubleshooting](./azure-cli-sp-tutorial-8.md#troubleshoot-service-principals) in the [Work with service principals](./azure-cli-sp-tutorial-1.md) tutorial.
258+
For information on troubleshooting service principals, see [Cleanup and Troubleshooting][02] in the
259+
[Work with service principals][01] tutorial.
220260

221261
## Other issues
222262

223-
If you experience a product issue with Azure CLI not listed in this article, [file an issue on GitHub](https://github.com/Azure/azure-cli/issues/new/choose).
263+
If you experience a product issue with Azure CLI not listed in this article,
264+
[file an issue on GitHub][17].
224265

225266
## See also
226267

227-
* [Tips for using the Azure CLI successfully](./use-azure-cli-successfully-tips.md)
268+
- [Tips for using the Azure CLI successfully][09]
269+
270+
<!-- link references -->
271+
272+
[01]: ./azure-cli-sp-tutorial-1.md
273+
[02]: ./azure-cli-sp-tutorial-8.md#troubleshoot-service-principals
274+
[03]: ./get-started-tutorial-2-environment-syntax.md
275+
[04]: ./use-azure-cli-successfully-bash.md
276+
[05]: ./use-azure-cli-successfully-powershell.md
277+
[06]: ./use-azure-cli-successfully-query.md
278+
[07]: ./use-azure-cli-successfully-quoting.md
279+
[08]: ./use-azure-cli-successfully-quoting.md#json-strings
280+
[09]: ./use-azure-cli-successfully-tips.md
281+
[10]: /azure/azure-resource-manager/management/resource-providers-and-types
282+
[11]: /azure/developer/python/sdk/azure-sdk-configure-proxy?tabs=bash
283+
[12]: /powershell/module/microsoft.powershell.core/about/about_splatting
284+
[13]: #error-arguments-are-expected-or-required
285+
[14]: #error-invalid-value-or-doesnt-exist
286+
[15]: #error-resource-not-found
287+
[16]: #work-behind-a-proxy
288+
[17]: https://github.com/Azure/azure-cli/issues/new/choose
289+
[18]: https://github.com/kennethreitz/requests

0 commit comments

Comments
 (0)