Skip to content

Commit 97005e8

Browse files
Clean up markdown
1 parent dfa62da commit 97005e8

2 files changed

Lines changed: 80 additions & 21 deletions

File tree

TROUBLESHOOTING.md

Lines changed: 68 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ This guide helps you resolve common issues when working with the Azure API Manag
1717
If you encounter import errors (e.g., `ModuleNotFoundError: No module named 'requests'` or cannot import shared modules), try these steps:
1818

1919
1. **Fix Python path configuration**:
20+
2021
```bash
2122
python setup/local_setup.py --generate-env
2223
```
2324

2425
2. **Verify setup**:
26+
2527
```bash
2628
python setup/verify_local_setup.py
2729
```
@@ -35,27 +37,32 @@ If you encounter import errors (e.g., `ModuleNotFoundError: No module named 'req
3537
### "The content for this response was already consumed"
3638

3739
**Error Message:**
38-
```
40+
41+
```text
3942
ERROR: The content for this response was already consumed
4043
```
4144

4245
**Root Cause:** This misleading error message often indicates a Bicep template validation error, typically caused by parameter mismatches between the notebook and the Bicep template.
4346

4447
**Solution:**
48+
4549
1. Run the Azure CLI command with `--debug` to see the actual error:
50+
4651
```bash
4752
az deployment group validate --resource-group <rg-name> --template-file "main.bicep" --parameters "params.json" --debug
4853
```
4954

5055
2. Look for the real error in the debug output, often something like:
51-
```
56+
57+
```text
5258
The following parameters were supplied, but do not correspond to any parameters defined in the template: 'parameterName'
5359
```
5460

5561
3. Check that all parameters in your notebook's `bicep_parameters` dictionary match the parameters defined in the `main.bicep` file.
5662

5763
**Example Fix:**
5864
If the error mentions `apimSku` parameter not found:
65+
5966
```python
6067
# ❌ Incorrect - includes undefined/unexpected apimSku parameter
6168
bicep_parameters = {
@@ -72,29 +79,35 @@ bicep_parameters = {
7279
### "Resource already exists" Conflicts
7380

7481
**Error Message:**
75-
```
82+
83+
```text
7684
The resource already exists and conflicts with...
7785
```
7886

7987
**Solution:**
88+
8089
1. Use unique deployment names with timestamps:
90+
8191
```bash
8292
az deployment group create --name "sample-$(date +%Y%m%d-%H%M%S)" ...
8393
```
8494

8595
2. Or delete existing conflicting resources:
96+
8697
```bash
8798
az resource delete --ids /subscriptions/.../resourceGroups/.../providers/...
8899
```
89100

90101
### Module Path Resolution Errors
91102

92103
**Error Message:**
93-
```
104+
105+
```text
94106
Unable to download the module...
95107
```
96108

97109
**Solution:**
110+
98111
1. Ensure you're running deployments from the correct directory (sample directory, not project root)
99112
2. Verify relative paths to shared modules are correct
100113
3. The utility function `create_bicep_deployment_group_for_sample()` handles this automatically
@@ -104,11 +117,13 @@ Unable to download the module...
104117
### Azure CLI Not Authenticated
105118

106119
**Error Message:**
107-
```
120+
121+
```text
108122
Please run 'az login' to setup account
109123
```
110124

111125
**Solution:**
126+
112127
```bash
113128
az login
114129
az account set --subscription "your-subscription-name-or-id"
@@ -124,16 +139,19 @@ az account set --subscription "your-subscription-name-or-id"
124139
### Insufficient Permissions
125140

126141
**Error Message:**
127-
```
142+
143+
```text
128144
The client does not have authorization to perform action...
129145
```
130146

131147
**Solution:**
148+
132149
1. Ensure you have the necessary role assignments:
133150
- **Contributor** or **Owner** on the resource group/subscription
134151
- **API Management Service Contributor** for APIM-specific operations
135152

136153
2. Check your current permissions:
154+
137155
```bash
138156
az role assignment list --assignee $(az account show --query user.name -o tsv)
139157
```
@@ -145,7 +163,8 @@ The client does not have authorization to perform action...
145163
These can be a bit nebulous. When making changes to imported modules, they are not automatically picked up.
146164

147165
**Error Message:**
148-
```
166+
167+
```text
149168
AttributeError: module 'utils' has no attribute 'function_name'
150169
```
151170

@@ -174,25 +193,29 @@ importlib.reload(utils)
174193
### Python Path Issues
175194

176195
**Error Message:**
177-
```
196+
197+
```text
178198
ModuleNotFoundError: No module named 'utils'
179199
```
180200

181201
**Solution:**
182202
Use the provided setup script:
203+
183204
```bash
184205
python setup/local_setup.py --generate-env
185206
```
186207

187208
### Working Directory Issues
188209

189210
**Error Message:**
190-
```
211+
212+
```text
191213
FileNotFoundError: [Errno 2] No such file or directory: 'main.bicep'
192214
```
193215

194216
**Solution:**
195217
Use the utility function that handles working directory management:
218+
196219
```python
197220
# ✅ Use this instead of manual directory management
198221
output = utils.create_bicep_deployment_group_for_sample('sample-name', rg_name, rg_location, bicep_parameters)
@@ -203,24 +226,29 @@ output = utils.create_bicep_deployment_group_for_sample('sample-name', rg_name,
203226
### Rate Limiting
204227

205228
**Error Message:**
206-
```
229+
230+
```text
207231
Rate limit exceeded
208232
```
209233

210234
**Solution:**
235+
211236
1. Wait a few minutes before retrying
212237
2. Reduce the frequency of API calls
213238
3. Use `--verbose` to see retry information
214239

215240
### API Version Compatibility
216241

217242
**Error Message:**
218-
```
243+
244+
```text
219245
The api-version '...' is invalid
220246
```
221247

222248
**Solution:**
249+
223250
1. Update Azure CLI to the latest version:
251+
224252
```bash
225253
az upgrade
226254
```
@@ -232,7 +260,8 @@ The api-version '...' is invalid
232260
This is a bit cryptic. It's helpful to execute the `az` command from the error separately in the terminal and supply the `--debug` flag. You might then see errors such as this one:
233261

234262
**Error Message:**
235-
```
263+
264+
```text
236265
cli.azure.cli.core.azclierror: [WinError 193] %1 is not a valid Win32 application
237266
az_command_data_logger: [WinError 193] %1 is not a valid Win32 application
238267
```
@@ -257,20 +286,23 @@ In one case, `%USERPROFILE%\.azure\bin` contained a `bicep.exe` file but with a
257286
When you delete Azure API Management services or Key Vaults, they are soft-deleted and remain recoverable for a period of time (typically 48 days for APIM, 90 days for Key Vault). These soft-deleted resources continue to reserve their names and can cause deployment conflicts.
258287

259288
**Common Issues:**
289+
260290
- Deployment fails with "Name already exists" even though resource appears deleted
261291
- Cannot reuse the same name for a new APIM service or Key Vault
262292
- Key Vault creation fails during infrastructure deployment
263293
- Subscription quotas are affected by soft-deleted resources
264294

265295
**Error During Infrastructure Deployment:**
266-
```
296+
297+
```text
267298
Creating Key Vault: kv-sbfc4encghfag
268299
❌ Failed to create Key Vault: kv-sbfc4encghfag
269300
This may be caused by a soft-deleted Key Vault with the same name.
270301
Check for soft-deleted resources: python shared/python/show_soft_deleted_resources.py
271302
```
272303

273304
**Check for Soft-Deleted Resources:**
305+
274306
```bash
275307
# Using Python script (recommended)
276308
python shared/python/show_soft_deleted_resources.py
@@ -297,6 +329,7 @@ az keyvault purge --name <name> --location <location> --no-wait
297329
```
298330

299331
**Best Practices:**
332+
300333
1. Check for soft-deleted resources before deploying with the same name
301334
2. Use unique names for resources to avoid conflicts
302335
3. Purge soft-deleted resources if you need to reuse the name immediately
@@ -307,20 +340,23 @@ az keyvault purge --name <name> --location <location> --no-wait
307340
Key Vaults can have **purge protection** enabled, which prevents them from being manually purged before their scheduled purge date. This is a security feature that cannot be disabled once enabled.
308341

309342
**Error When Purging Protected Key Vaults:**
310-
```
343+
344+
```text
311345
(MethodNotAllowed) Operation 'DeletedVaultPurge' is not allowed.
312346
Code: MethodNotAllowed
313347
Message: Operation 'DeletedVaultPurge' is not allowed.
314348
```
315349

316350
**Identifying Purge Protection:**
317351
The `show_soft_deleted_resources.py` script automatically detects and displays purge protection status:
352+
318353
```bash
319354
python shared/python/show_soft_deleted_resources.py
320355
```
321356

322357
Sample output:
323-
```
358+
359+
```text
324360
1/2:
325361
Vault Name : kv-glgoiqn66pbnu
326362
Location : eastus2
@@ -334,12 +370,14 @@ Sample output:
334370
```
335371

336372
**Handling Purge-Protected Key Vaults:**
373+
337374
-**Recoverable:** You can still recover the vault before the scheduled purge date
338375
-**Cannot purge manually:** The vault cannot be purged until its scheduled purge date
339376
- 💡 **Use different names:** Deploy new Key Vaults with different names
340377
- 🔒 **Security feature:** This is by design to prevent accidental data loss
341378

342379
**Recovery Option:**
380+
343381
```bash
344382
# Recover a soft-deleted Key Vault (even with purge protection)
345383
az keyvault recover --name <vault-name>
@@ -348,46 +386,56 @@ az keyvault recover --name <vault-name>
348386
### Resource Group Does Not Exist
349387

350388
**Error Message:**
351-
```
389+
390+
```text
352391
Resource group 'name' could not be found
353392
```
354393

355394
**Solution:**
395+
356396
1. Create the infrastructure first by running the appropriate infrastructure deployment from the `/infrastructure/` folder
357397
2. Verify the resource group name matches the expected pattern:
398+
358399
```python
359400
rg_name = get_infra_rg_name(deployment, index)
360401
```
361402

362403
### APIM Service Not Found
363404

364405
**Error Message:**
365-
```
406+
407+
```text
366408
API Management service 'name' not found
367409
```
368410

369411
**Solution:**
412+
370413
1. Ensure the infrastructure deployment completed successfully
371414
2. Check that the APIM service exists:
415+
372416
```bash
373417
az apim list --resource-group <rg-name>
374418
```
375419

376420
3. Verify the naming pattern matches:
421+
377422
```bash
378423
az resource list --resource-group <rg-name> --resource-type Microsoft.ApiManagement/service
379424
```
380425

381426
### Permission Propagation Delays
382427

383428
**Error Message:**
384-
```
429+
430+
```text
385431
403 Forbidden / Access denied errors when accessing storage
386432
```
387433

388434
**Solution:**
435+
389436
1. Azure role assignments can take 5-10 minutes to propagate
390437
2. Use the built-in permission verification utility:
438+
391439
```python
392440
permissions_ready = utils.wait_for_apim_blob_permissions(
393441
apim_name=apim_name,
@@ -404,11 +452,13 @@ API Management service 'name' not found
404452
For more detailed error information:
405453

406454
1. **Azure CLI:**
455+
407456
```bash
408457
az deployment group create ... --verbose --debug
409458
```
410459

411460
2. **Python/Notebook:**
461+
412462
```python
413463
import logging
414464
logging.basicConfig(level=logging.DEBUG)

0 commit comments

Comments
 (0)