|
| 1 | +# Dev Container for APIM Samples |
| 2 | + |
| 3 | +This directory contains the GitHub Dev Container configuration for the APIM Samples repository, providing a complete development environment with all necessary prerequisites. |
| 4 | + |
| 5 | +## 🚀 Quick Start |
| 6 | + |
| 7 | +### Using GitHub Codespaces |
| 8 | + |
| 9 | +1. Navigate to the repository on GitHub |
| 10 | +2. Click the green "Code" button |
| 11 | +3. Select "Codespaces" tab |
| 12 | +4. Click "Create codespace on main" |
| 13 | +5. Wait for the environment to build and initialize |
| 14 | + |
| 15 | +### Using VS Code Dev Containers |
| 16 | + |
| 17 | +1. Install the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) |
| 18 | +2. Open the repository in VS Code |
| 19 | +3. When prompted, click "Reopen in Container" or use Command Palette: "Dev Containers: Reopen in Container" |
| 20 | +4. Wait for the container to build and initialize |
| 21 | + |
| 22 | +## 📦 What's Included |
| 23 | + |
| 24 | +### Core Tools |
| 25 | +- **Python 3.12** - Primary development runtime |
| 26 | +- **Azure CLI** - Latest version with useful extensions pre-installed |
| 27 | +- **Git** - Version control with enhanced configuration |
| 28 | + |
| 29 | +### VS Code Extensions |
| 30 | +- **Python** - Full Python development support |
| 31 | +- **Jupyter** - Complete Jupyter notebook support with renderers and tools |
| 32 | +- **Azure Bicep** - Infrastructure as Code support |
| 33 | +- **Azure CLI Tools** - Enhanced Azure development experience |
| 34 | +- **GitHub Copilot** - AI-powered coding assistance (if licensed) |
| 35 | +- **YAML & JSON** - Configuration file support |
| 36 | + |
| 37 | +### Python Packages |
| 38 | +All packages from `requirements.txt` are pre-installed: |
| 39 | +- `requests` - HTTP library |
| 40 | +- `pandas` - Data manipulation |
| 41 | +- `matplotlib` - Data visualization |
| 42 | +- `pyjwt` - JWT token handling |
| 43 | +- `pytest` & `pytest-cov` - Testing framework |
| 44 | +- `azure.storage.blob` & `azure.identity` - Azure SDK components |
| 45 | + |
| 46 | +### Environment Configuration |
| 47 | +- **PYTHONPATH** - Automatically configured to include shared Python modules |
| 48 | +- **Jupyter Kernel** - Custom kernel named "APIM Samples Python" |
| 49 | +- **Azure CLI** - Configured for container-friendly authentication |
| 50 | +- **Port Forwarding** - Common development ports (3000, 5000, 8000, 8080) pre-configured |
| 51 | + |
| 52 | +## 🔧 Post-Setup Steps |
| 53 | + |
| 54 | +After the container starts, you'll need to: |
| 55 | + |
| 56 | +1. **Sign in to Azure**: |
| 57 | + ```bash |
| 58 | + az login |
| 59 | + ``` |
| 60 | + |
| 61 | +2. **Verify your Azure setup**: |
| 62 | + Execute `shared/jupyter/verify-az-account.ipynb` |
| 63 | + |
| 64 | +3. **Start exploring**: |
| 65 | + - Navigate to any infrastructure folder (`infrastructure/`) |
| 66 | + - Run the `create.ipynb` notebook to set up infrastructure |
| 67 | + - Explore samples in the `samples/` directory |
| 68 | + |
| 69 | +## 🏗️ Architecture |
| 70 | + |
| 71 | +The dev container is built on: |
| 72 | +- **Base Image**: `mcr.microsoft.com/devcontainers/python:1-3.12-bullseye` |
| 73 | +- **Features**: Azure CLI, Common utilities with Zsh/Oh My Zsh |
| 74 | +- **Workspace**: Mounted at `/workspaces/Apim-Samples` |
| 75 | +- **User**: `vscode` with proper permissions |
| 76 | + |
| 77 | +## 🔄 Azure CLI Authentication |
| 78 | + |
| 79 | +The container mounts your local `~/.azure` directory to preserve authentication state between container rebuilds. This means: |
| 80 | +- Your Azure login persists across sessions |
| 81 | +- Your Azure CLI configuration is maintained |
| 82 | +- No need to repeatedly authenticate |
| 83 | + |
| 84 | +## 🐛 Troubleshooting |
| 85 | + |
| 86 | +### Python Path Issues |
| 87 | +If you encounter import errors: |
| 88 | +```bash |
| 89 | +python setup/setup_python_path.py --generate-env |
| 90 | +``` |
| 91 | + |
| 92 | +### Jupyter Kernel Not Found |
| 93 | +Restart VS Code or refresh the Jupyter kernel list: |
| 94 | +- Command Palette → "Jupyter: Refresh Kernels" |
| 95 | + |
| 96 | +### Azure CLI Issues |
| 97 | +Check Azure CLI status: |
| 98 | +```bash |
| 99 | +az account show |
| 100 | +az account list |
| 101 | +``` |
| 102 | + |
| 103 | +### Container Rebuild |
| 104 | +If you need to rebuild the container: |
| 105 | +- Command Palette → "Dev Containers: Rebuild Container" |
| 106 | + |
| 107 | +## 🔒 Security Considerations |
| 108 | + |
| 109 | +- Azure credentials are mounted from your local machine |
| 110 | +- The container runs as a non-root user (`vscode`) |
| 111 | +- All dependencies are installed from official sources |
| 112 | +- Network access is controlled through VS Code's port forwarding |
| 113 | + |
| 114 | +## 🤝 Contributing |
| 115 | + |
| 116 | +When modifying the dev container configuration: |
| 117 | +1. Test changes locally first |
| 118 | +2. Update this README if adding new tools or changing behavior |
| 119 | +3. Consider backward compatibility for existing users |
| 120 | +4. Document any new environment variables or configuration options |
0 commit comments