Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ python -m ipykernel install --user --name=python-venv --display-name='Python (.v
source /workspaces/Apim-Samples/.venv/bin/activate &&
pip install -r requirements.txt &&
pip install pytest pytest-cov coverage &&
python setup/setup_python_path.py --generate-env &&
python setup/local_setup.py --generate-env &&
az config set core.login_experience_v2=off &&
az extension add --name containerapp --only-show-errors &&
az extension add --name front-door --only-show-errors
Expand Down Expand Up @@ -342,7 +342,7 @@ python -m ipykernel install --user --name=python-venv --display-name="Python (.v
**Symptom**: Import errors or path issues
**Solution**: Regenerate the `.env` file:
```bash
python setup/setup_python_path.py --generate-env
python setup/local_setup.py --generate-env
```

### Debug Commands
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/python312/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"updateContentCommand": [
"bash",
"-c",
"echo '📦 Installing/updating Python packages from requirements.txt...' && source /workspaces/Apim-Samples/.venv/bin/activate && pip install -r requirements.txt && pip install pytest pytest-cov coverage && echo '✅ Python packages installed/updated' && python setup/setup_python_path.py --generate-env && echo '✅ Environment configuration updated' && echo '⚙️ Configuring Azure CLI...' && az config set core.login_experience_v2=off 2>/dev/null || true && az extension add --name containerapp --only-show-errors 2>/dev/null || true && az extension add --name front-door --only-show-errors 2>/dev/null || true && echo '✅ Azure CLI configured for Codespaces'"
"echo '📦 Installing/updating Python packages from requirements.txt...' && source /workspaces/Apim-Samples/.venv/bin/activate && pip install -r requirements.txt && pip install pytest pytest-cov coverage && echo '✅ Python packages installed/updated' && python setup/local_setup.py --generate-env && echo '✅ Environment configuration updated' && echo '⚙️ Configuring Azure CLI...' && az config set core.login_experience_v2=off 2>/dev/null || true && az extension add --name containerapp --only-show-errors 2>/dev/null || true && az extension add --name front-door --only-show-errors 2>/dev/null || true && echo '✅ Azure CLI configured for Codespaces'"
],
"postStartCommand": [
"bash",
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/python313/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"updateContentCommand": [
"bash",
"-c",
"echo '📦 Installing/updating Python packages from requirements.txt...' && source /workspaces/Apim-Samples/.venv/bin/activate && pip install -r requirements.txt && pip install pytest pytest-cov coverage && echo '✅ Python packages installed/updated' && python setup/setup_python_path.py --generate-env && echo '✅ Environment configuration updated' && echo '⚙️ Configuring Azure CLI...' && az config set core.login_experience_v2=off 2>/dev/null || true && az extension add --name containerapp --only-show-errors 2>/dev/null || true && az extension add --name front-door --only-show-errors 2>/dev/null || true && echo '✅ Azure CLI configured for Codespaces'"
"echo '📦 Installing/updating Python packages from requirements.txt...' && source /workspaces/Apim-Samples/.venv/bin/activate && pip install -r requirements.txt && pip install pytest pytest-cov coverage && echo '✅ Python packages installed/updated' && python setup/local_setup.py --generate-env && echo '✅ Environment configuration updated' && echo '⚙️ Configuring Azure CLI...' && az config set core.login_experience_v2=off 2>/dev/null || true && az extension add --name containerapp --only-show-errors 2>/dev/null || true && az extension add --name front-door --only-show-errors 2>/dev/null || true && echo '✅ Azure CLI configured for Codespaces'"
],
"postStartCommand": [
"bash",
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/python314/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"updateContentCommand": [
"bash",
"-c",
"echo '📦 Installing/updating Python packages from requirements.txt...' && source /workspaces/Apim-Samples/.venv/bin/activate && pip install -r requirements.txt && pip install pytest pytest-cov coverage && echo '✅ Python packages installed/updated' && python setup/setup_python_path.py --generate-env && echo '✅ Environment configuration updated' && echo '⚙️ Configuring Azure CLI...' && az config set core.login_experience_v2=off 2>/dev/null || true && az extension add --name containerapp --only-show-errors 2>/dev/null || true && az extension add --name front-door --only-show-errors 2>/dev/null || true && echo '✅ Azure CLI configured for Codespaces'"
"echo '📦 Installing/updating Python packages from requirements.txt...' && source /workspaces/Apim-Samples/.venv/bin/activate && pip install -r requirements.txt && pip install pytest pytest-cov coverage && echo '✅ Python packages installed/updated' && python setup/local_setup.py --generate-env && echo '✅ Environment configuration updated' && echo '⚙️ Configuring Azure CLI...' && az config set core.login_experience_v2=off 2>/dev/null || true && az extension add --name containerapp --only-show-errors 2>/dev/null || true && az extension add --name front-door --only-show-errors 2>/dev/null || true && echo '✅ Azure CLI configured for Codespaces'"
],
"postStartCommand": [
"bash",
Expand Down
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@

# Keep essential files for the build
!requirements.txt
!setup/setup_python_path.py
!setup/local_setup.py
!shared/python/**
40 changes: 8 additions & 32 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,19 @@
{
"jupyter.defaultKernel": "apim-samples",
"jupyter.kernels.changeKernelIdForNotebookEnabled": false,
"jupyter.preferredKernelIdForNotebook": {
"*.ipynb": "apim-samples"
},
"jupyter.kernels.trusted": [
"./.venv/Scripts/python.exe"
],
"jupyter.kernels.excludePythonEnvironments": [
"apim-samples"
],
"search.exclude": {
"**/.venv": true,
"**/.venv/**": true
},
"files.watcherExclude": {
"**/.venv/**": true
},
"files.exclude": {
"**/.venv": true
},
"python.analysis.exclude": [
"**/.*",
"**/.venv",
"**/venv",
"**/env",
"**/node_modules",
"**/__pycache__",
".git",
"**/build",
"env/**",
"**/.venv/**"
"env/**"
],
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.eol": "\n",
"editor.renderWhitespace": "trailing",
"python.defaultInterpreterPath": "./.venv/Scripts/python.exe",
"python.pythonPath": "./.venv/Scripts/python.exe",
"python.envFile": "${workspaceFolder}/.env",
"[python]": {
"editor.codeActionsOnSave": {
Expand All @@ -43,8 +22,7 @@
},
"editor.formatOnSave": true
},
"notebook.defaultLanguage": "python",
"notebook.kernelPickerType": "mru",

"terminal.integrated.defaultProfile.windows": "PowerShell",
"plantuml.render": "Local",
"plantuml.exportFormat": "svg",
Expand All @@ -53,7 +31,5 @@
"plantuml.exportOutDir": "assets/diagrams/out",
"python.terminal.activateEnvironment": true,
"python.terminal.activateEnvInCurrentTerminal": true,
"python.testing.pytestEnabled": true,
"python.linting.enabled": true,
"python.linting.pylintEnabled": true
}
"python.testing.pytestEnabled": true
}
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "shell",
"command": "${config:python.pythonPath}",
"args": [
"setup/setup_python_path.py",
"setup/local_setup.py",
"--generate-env"
],
"group": "build",
Expand Down
86 changes: 75 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,76 @@ This menu-driven interface provides quick access to:
Example output from option 2 (Verify local setup):
```
🔍 APIM Samples Local Environment Verification
==================================================

📋 Virtual Environment
----------------------
✅ Virtual environment is active
✅ All required packages installed
✅ Shared modules can be imported
✅ .env file configured
⚠️ Jupyter kernel not found
✅ VS Code settings configured

📋 Required Packages
--------------------
✅ requests is installed
✅ ipykernel is installed
✅ jupyter is installed
✅ python-dotenv is installed

📋 Shared Modules
-----------------
✅ All shared modules can be imported

📋 Environment File
-------------------
✅ .env file is configured correctly

📋 Azure CLI
------------
✅ Azure CLI is installed (azure-cli 2.81.0)

📋 Azure Bicep CLI
------------------
✅ Azure Bicep CLI is installed (az bicep version: Bicep CLI version 0.39.26 (1e90b06e40))

📋 Azure Providers
------------------
Registered providers:
- Microsoft.ApiManagement
- Microsoft.App
- Microsoft.Authorization
- Microsoft.CognitiveServices
- Microsoft.ContainerRegistry
- Microsoft.KeyVault
- Microsoft.Maps
- Microsoft.ManagedIdentity
- Microsoft.Network
- Microsoft.OperationalInsights
- Microsoft.Resources
- Microsoft.Storage
✅ All required Azure providers are registered

📋 Jupyter Kernel
-----------------
✅ APIM Samples Jupyter kernel is registered

📋 VS Code Settings
-------------------
✅ VS Code settings are configured correctly

📋 Summary
----------
✅ Virtual Environment : PASS
✅ Required Packages : PASS
✅ Shared Modules : PASS
✅ Environment File : PASS
✅ Azure CLI : PASS
✅ Azure Bicep CLI : PASS
✅ Azure Providers : PASS
✅ Jupyter Kernel : PASS
✅ VS Code Settings : PASS

📊 Overall: 9/9 checks passed

🎉 All checks passed! Your local environment is ready for APIM Samples.
💡 You can now open any notebook and it should work seamlessly.
```

---
Expand Down Expand Up @@ -132,11 +196,11 @@ If you're setting up locally without the dev container:
1. **Create Python Environment**: In VS Code, use Ctrl+Shift+P → "Python: Create Environment" → "Venv" → Select Python version → Check requirements.txt
2. **Complete Environment Setup**: Run the automated setup script:
```bash
python setup/setup_python_path.py --complete-setup
python setup/local_setup.py --complete-setup
```
For help and available options, run without arguments:
```bash
python setup/setup_python_path.py
python setup/local_setup.py
```
3. **Restart VS Code** to apply all settings
4. **Sign in to Azure**: `az login --tenant <your-tenant-id>` and `az account set --subscription <your-subscription>`
Expand Down Expand Up @@ -164,9 +228,9 @@ If you prefer manual setup or the automated script doesn't work:
1. Verify the virtual environment is set up. You should see a new _.venv_ directory with a _pyveng.cfg_ file and the Python version you selected earlier.
1. Set up the project environment:
```bash
python setup/setup_python_path.py --generate-env
python setup/setup_python_path.py --setup-kernel
python setup/setup_python_path.py --setup-vscode
python setup/local_setup.py --generate-env
python setup/local_setup.py --setup-kernel
python setup/local_setup.py --setup-vscode
```
1. **Restart VS Code** to ensure all environment settings are loaded properly.

Expand All @@ -178,7 +242,7 @@ If you encounter import errors (e.g., `ModuleNotFoundError: No module named 'req

1. **Fix Python path configuration**:
```bash
python setup/setup_python_path.py --generate-env
python setup/local_setup.py --generate-env
```

2. **Verify setup**:
Expand Down
2 changes: 1 addition & 1 deletion TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ ModuleNotFoundError: No module named 'utils'
**Solution:**
Use the provided setup script:
```bash
python setup/setup_python_path.py --generate-env
python setup/local_setup.py --generate-env
```

### Working Directory Issues
Expand Down
18 changes: 9 additions & 9 deletions setup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Configures cross-platform PYTHONPATH for APIM Samples and provides streamlined l
For complete local environment setup that matches the dev container experience:

```shell
python setup/setup_python_path.py --complete-setup
python setup/local_setup.py --complete-setup
```

This will:
Expand All @@ -23,22 +23,22 @@ If you prefer to run setup steps individually:

```shell
# Generate .env file only
python setup/setup_python_path.py --generate-env
python setup/local_setup.py --generate-env

# Register Jupyter kernel only
python setup/setup_python_path.py --setup-kernel
python setup/local_setup.py --setup-kernel

# Configure VS Code settings only
python setup/setup_python_path.py --setup-vscode
python setup/local_setup.py --setup-vscode

# Force kernel consistency (fix kernel switching issues)
python setup/setup_python_path.py --force-kernel
python setup/local_setup.py --force-kernel

# Basic PYTHONPATH setup for current session
python setup/setup_python_path.py --run-only
python setup/local_setup.py --run-only

# Show help and available options
python setup/setup_python_path.py
python setup/local_setup.py
```

## Verification
Expand All @@ -62,13 +62,13 @@ This checks:

To ensure notebooks always use the correct kernel ("APIM Samples Python 3.12" instead of ".venv" or "python3"):

1. **Run the complete setup**: `python setup/setup_python_path.py --complete-setup`
1. **Run the complete setup**: `python setup/local_setup.py --complete-setup`
2. **Restart VS Code** completely
3. **Verify with**: `python setup/verify_setup.py`

If you still see incorrect kernel names, run:
```shell
python setup/setup_python_path.py --force-kernel
python setup/local_setup.py --force-kernel
```

## Troubleshooting
Expand Down
Loading
Loading