|
| 1 | +# Troubleshooting Guide - Overview |
| 2 | + |
| 3 | +Costa Rica |
| 4 | + |
| 5 | +[](https://github.com/) |
| 6 | +[brown9804](https://github.com/brown9804) |
| 7 | + |
| 8 | +Last updated: 2025-11-24 |
| 9 | + |
| 10 | +---------- |
| 11 | + |
| 12 | +> This guide covers common issues you may encounter when deploying and running this Azure AI Shopping demo application. |
| 13 | +
|
| 14 | +<details> |
| 15 | +<summary><b>Table of Content</b> (Click to expand)</summary> |
| 16 | + |
| 17 | +- [Python Not Found](#python-not-found) |
| 18 | +- [Virtual Environment Creation Failed](#virtual-environment-creation-failed) |
| 19 | +- [Package Installation Failed](#package-installation-failed) |
| 20 | +- [Not Logged into Azure CLI](#not-logged-into-azure-cli) |
| 21 | +- [AAD Authentication Failed](#aad-authentication-failed) |
| 22 | +- [Local Authorization Disabled Error](#local-authorization-disabled-error) |
| 23 | +- [Connection Timeout](#connection-timeout) |
| 24 | +- [CSV File Not Found](#csv-file-not-found) |
| 25 | +- [CSV Parsing Error](#csv-parsing-error) |
| 26 | +- [Environment File Missing](#environment-file-missing) |
| 27 | +- [Failed to Authenticate to Cosmos DB](#failed-to-authenticate-to-cosmos-db) |
| 28 | +- [Resource Already Exists](#resource-already-exists) |
| 29 | +- [Insufficient Permissions](#insufficient-permissions) |
| 30 | +- [Provider Configuration Error](#provider-configuration-error) |
| 31 | +- [State Lock Error](#state-lock-error) |
| 32 | +- [Enable Verbose Logging](#enable-verbose-logging) |
| 33 | +- [Check Azure Service Health](#check-azure-service-health) |
| 34 | +- [Clean Up and Retry](#clean-up-and-retry) |
| 35 | +- [Still Having Issues?](#still-having-issues) |
| 36 | + |
| 37 | +</details> |
| 38 | + |
| 39 | +## Python Not Found |
| 40 | + |
| 41 | +``` |
| 42 | +ERROR: Python is not installed or not in PATH |
| 43 | +``` |
| 44 | + |
| 45 | +**Solution**: |
| 46 | + |
| 47 | +- Install Python 3.8+ from <https://www.python.org/downloads/> |
| 48 | +- Ensure Python is added to your system PATH during installation |
| 49 | +- Verify installation: `python --version` |
| 50 | + |
| 51 | +## Virtual Environment Creation Failed |
| 52 | + |
| 53 | +``` |
| 54 | +ERROR: Failed to create virtual environment |
| 55 | +``` |
| 56 | + |
| 57 | +**Solution**: |
| 58 | + |
| 59 | +- Ensure you have write permissions to the `src` directory |
| 60 | +- Try deleting existing `venv` folder: `Remove-Item -Recurse -Force venv` |
| 61 | +- Check if `python -m venv` works manually: `python -m venv test_venv` |
| 62 | +- On Windows, ensure your execution policy allows script execution |
| 63 | + |
| 64 | +## Package Installation Failed |
| 65 | + |
| 66 | +``` |
| 67 | +ERROR: Could not install packages due to an OSError |
| 68 | +``` |
| 69 | + |
| 70 | +**Solution**: |
| 71 | + |
| 72 | +- Update pip: `python -m pip install --upgrade pip` |
| 73 | +- Clear pip cache: `pip cache purge` |
| 74 | +- Try installing with `--no-cache-dir`: `pip install --no-cache-dir -r requirements.txt` |
| 75 | +- For Windows + pandas issues, use pre-built wheels by ensuring `pandas>=2.2.2` in requirements.txt |
| 76 | + |
| 77 | +## Not Logged into Azure CLI |
| 78 | + |
| 79 | +``` |
| 80 | +ERROR: Please run 'az login' to setup account |
| 81 | +``` |
| 82 | + |
| 83 | +**Solution**: |
| 84 | + |
| 85 | +```powershell |
| 86 | +# Login to Azure CLI |
| 87 | +az login |
| 88 | +
|
| 89 | +# Verify you're logged in with the correct account |
| 90 | +az account show |
| 91 | +
|
| 92 | +# If needed, set the correct subscription |
| 93 | +az account set --subscription <subscription-id> |
| 94 | +``` |
| 95 | + |
| 96 | +## AAD Authentication Failed |
| 97 | + |
| 98 | +``` |
| 99 | +DefaultAzureCredential failed to retrieve a token |
| 100 | +``` |
| 101 | + |
| 102 | +**Solution**: |
| 103 | + |
| 104 | +1. Ensure you're logged into Azure CLI: `az login` |
| 105 | +2. Check your account has proper permissions |
| 106 | +3. Verify the resource exists and you have access |
| 107 | +4. Try clearing Azure credentials cache: `az account clear` then `az login` again |
| 108 | + |
| 109 | +## Local Authorization Disabled Error |
| 110 | + |
| 111 | +``` |
| 112 | +ERROR: Local Authorization is disabled. Use an AAD token to authorize all requests. |
| 113 | +``` |
| 114 | + |
| 115 | +> This error occurs when Cosmos DB requires Azure Active Directory (AAD) authentication instead of key-based authentication. |
| 116 | +
|
| 117 | +**Common Causes and Solutions**: |
| 118 | + |
| 119 | +- Not logged into Azure CLI |
| 120 | + |
| 121 | +```powershell |
| 122 | +# Login to Azure CLI |
| 123 | +az login |
| 124 | +
|
| 125 | +# Verify you're logged in with the correct account |
| 126 | +az account show |
| 127 | +
|
| 128 | +# If needed, set the correct subscription |
| 129 | +az account set --subscription <subscription-id> |
| 130 | +``` |
| 131 | + |
| 132 | +> After logging in, try running the script again. |
| 133 | +
|
| 134 | +- Public Network Access Disabled |
| 135 | + |
| 136 | +> If your Cosmos DB has public network access disabled, your local machine or Codespace VM cannot connect. |
| 137 | +
|
| 138 | +**Solution via Azure Portal**: |
| 139 | + |
| 140 | +- Navigate to your Cosmos DB account in the Azure portal |
| 141 | +- Select **Networking** from the Settings menu |
| 142 | +- Ensure **Public network access** is set to **All networks** |
| 143 | +- Click **Save** |
| 144 | +- Wait a few minutes for the change to propagate |
| 145 | +- Try running the script again |
| 146 | + |
| 147 | +**Solution via Azure CLI**: |
| 148 | + |
| 149 | +```powershell |
| 150 | +az cosmosdb update \ |
| 151 | + --name <cosmos-account-name> \ |
| 152 | + --resource-group <resource-group-name> \ |
| 153 | + --enable-public-network true |
| 154 | +``` |
| 155 | + |
| 156 | +- Insufficient Permissions: Your Azure account needs appropriate role assignments on the Cosmos DB account. |
| 157 | + |
| 158 | +**Required roles**: |
| 159 | + |
| 160 | +- `Cosmos DB Built-in Data Contributor` (for read/write access) |
| 161 | +- Or `Contributor` at the resource group level |
| 162 | + |
| 163 | +**Solution via Azure CLI**: |
| 164 | + |
| 165 | +```powershell |
| 166 | +# Get your user object ID |
| 167 | +$userId = (az ad signed-in-user show --query id -o tsv) |
| 168 | +
|
| 169 | +# Assign Cosmos DB Data Contributor role |
| 170 | +az cosmosdb sql role assignment create \ |
| 171 | + --account-name <cosmos-account-name> \ |
| 172 | + --resource-group <resource-group-name> \ |
| 173 | + --role-definition-id 00000000-0000-0000-0000-000000000002 \ |
| 174 | + --principal-id $userId \ |
| 175 | + --scope "/" |
| 176 | +``` |
| 177 | + |
| 178 | +## Connection Timeout |
| 179 | + |
| 180 | +``` |
| 181 | +ERROR: Request timeout |
| 182 | +``` |
| 183 | + |
| 184 | +**Solution**: |
| 185 | + |
| 186 | +- Check your network connection |
| 187 | +- Verify Cosmos DB firewall settings allow your IP address |
| 188 | +- Ensure public network access is enabled (see above) |
| 189 | +- Check if Azure services are experiencing outages: <https://status.azure.com/> |
| 190 | + |
| 191 | +## CSV File Not Found |
| 192 | + |
| 193 | +``` |
| 194 | +WARNING: CSV data file not found at data/updated_product_catalog(in).csv |
| 195 | +``` |
| 196 | + |
| 197 | +**Solution**: |
| 198 | +Download or place the product catalog CSV file in the `src/data/` directory: |
| 199 | + |
| 200 | +```bash |
| 201 | +curl -o src/data/updated_product_catalog(in).csv https://raw.githubusercontent.com/microsoft/TechWorkshop-L300-AI-Apps-and-agents/main/src/data/updated_product_catalog(in).csv |
| 202 | +``` |
| 203 | + |
| 204 | +## CSV Parsing Error |
| 205 | + |
| 206 | +``` |
| 207 | +ERROR: Error tokenizing data. C error: Expected X fields, saw Y |
| 208 | +``` |
| 209 | + |
| 210 | +**Solution**: |
| 211 | + |
| 212 | +- Ensure CSV fields with commas are properly quoted |
| 213 | +- Check for special characters or encoding issues |
| 214 | +- Verify the CSV has the correct number of columns (6): ProductID, ProductName, ProductCategory, ProductDescription, Price, ImageUrl |
| 215 | +- Try opening the CSV in a text editor to check for formatting issues |
| 216 | + |
| 217 | +## Environment File Missing |
| 218 | + |
| 219 | +``` |
| 220 | +ERROR: .env file not found |
| 221 | +``` |
| 222 | + |
| 223 | +**Solution**: |
| 224 | + |
| 225 | +```bash |
| 226 | +# Run Terraform to generate the .env file |
| 227 | +cd terraform-infrastructure |
| 228 | +terraform apply -auto-approve |
| 229 | +``` |
| 230 | + |
| 231 | +## Failed to Authenticate to Cosmos DB |
| 232 | + |
| 233 | +``` |
| 234 | +ERROR: Failed to authenticate to Cosmos DB using DefaultAzureCredential and no valid COSMOS_DB_KEY was provided |
| 235 | +``` |
| 236 | + |
| 237 | +**Solution**: |
| 238 | + |
| 239 | +- Ensure your `.env` file is properly generated with correct keys |
| 240 | +- Run `terraform apply` again if needed |
| 241 | +- Check that `COSMOS_DB_ENDPOINT` and `COSMOS_DB_KEY` are set correctly in `.env` |
| 242 | +- The script will automatically try AAD authentication first, then fall back to key-based auth |
| 243 | + |
| 244 | +## Resource Already Exists |
| 245 | + |
| 246 | +``` |
| 247 | +ERROR: A resource with the ID already exists |
| 248 | +``` |
| 249 | + |
| 250 | +**Solution**: |
| 251 | + |
| 252 | +- Import the existing resource: `terraform import <resource_type>.<name> <azure_resource_id>` |
| 253 | +- Or destroy and recreate: `terraform destroy` then `terraform apply` |
| 254 | +- Check for resources in other resource groups with the same name |
| 255 | + |
| 256 | +## Insufficient Permissions |
| 257 | + |
| 258 | +``` |
| 259 | +ERROR: The client does not have authorization to perform action |
| 260 | +``` |
| 261 | + |
| 262 | +**Solution**: |
| 263 | + |
| 264 | +- Ensure your Azure account has `Contributor` or `Owner` role on the subscription or resource group |
| 265 | +- Check if specific Azure policies are blocking resource creation |
| 266 | +- Contact your Azure administrator to grant necessary permissions |
| 267 | + |
| 268 | +## Provider Configuration Error |
| 269 | + |
| 270 | +``` |
| 271 | +ERROR: Error configuring the backend "azurerm" |
| 272 | +``` |
| 273 | + |
| 274 | +**Solution**: |
| 275 | + |
| 276 | +- Verify your Azure credentials are configured: `az login` |
| 277 | +- Check that the specified subscription exists and you have access |
| 278 | +- Ensure the backend storage account and container exist (if using remote state) |
| 279 | + |
| 280 | +## State Lock Error |
| 281 | + |
| 282 | +``` |
| 283 | +ERROR: Error acquiring the state lock |
| 284 | +``` |
| 285 | + |
| 286 | +**Solution**: |
| 287 | + |
| 288 | +```bash |
| 289 | +# Force unlock (use with caution) |
| 290 | +terraform force-unlock <lock-id> |
| 291 | +``` |
| 292 | + |
| 293 | +> Only force-unlock if you're certain no other Terraform process is running. |
| 294 | +
|
| 295 | +## Enable Verbose Logging |
| 296 | + |
| 297 | +For more detailed error information: |
| 298 | + |
| 299 | +**Azure CLI**: |
| 300 | + |
| 301 | +```powershell |
| 302 | +az <command> --debug |
| 303 | +``` |
| 304 | + |
| 305 | +**Python Scripts**: |
| 306 | +Set environment variable before running: |
| 307 | + |
| 308 | +```powershell |
| 309 | +$env:AZURE_LOG_LEVEL = "DEBUG" |
| 310 | +python pipelines/script.py |
| 311 | +``` |
| 312 | + |
| 313 | +**Terraform**: |
| 314 | + |
| 315 | +```bash |
| 316 | +export TF_LOG=DEBUG |
| 317 | +terraform apply |
| 318 | +``` |
| 319 | + |
| 320 | +## Check Azure Service Health |
| 321 | + |
| 322 | +> If experiencing unexpected issues, check [Azure service status](https://status.azure.com/) |
| 323 | +
|
| 324 | +## Clean Up and Retry |
| 325 | + |
| 326 | +> Sometimes a clean slate helps: |
| 327 | +
|
| 328 | +```bash |
| 329 | +# Clean Python environment |
| 330 | +Remove-Item -Recurse -Force venv |
| 331 | +python -m venv venv |
| 332 | + |
| 333 | +# Clean Terraform state (use with caution) |
| 334 | +terraform destroy |
| 335 | +Remove-Item -Recurse -Force .terraform |
| 336 | +terraform init |
| 337 | +terraform apply |
| 338 | +``` |
| 339 | + |
| 340 | +## Still Having Issues? |
| 341 | + |
| 342 | +> If you continue experiencing problems: |
| 343 | +
|
| 344 | +1. Check the [GitHub repository issues](https://github.com/MicrosoftCloudEssentials-LearningHub/Agentic-DevOps-AI-Shopping/issues) |
| 345 | +2. Review Azure documentation for specific services |
| 346 | +3. Enable detailed logging as described above |
| 347 | +4. Collect error messages, logs, and configuration details |
| 348 | +5. Create a new issue with detailed information about your problem |
| 349 | + |
| 350 | +<!-- START BADGE --> |
| 351 | +<div align="center"> |
| 352 | + <img src="https://img.shields.io/badge/Total%20views-1410-limegreen" alt="Total views"> |
| 353 | + <p>Refresh Date: 2025-11-24</p> |
| 354 | +</div> |
| 355 | +<!-- END BADGE --> |
0 commit comments