|
| 1 | +# V1 to V2 Agent Migration - Docker Container |
| 2 | + |
| 3 | +This directory contains the containerized version of the v1 to v2 agent migration script. |
| 4 | + |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +### Prerequisites |
| 8 | +- Docker installed and running |
| 9 | +- Azure CLI installed and authenticated (`az login`) |
| 10 | +- Access to source data (Cosmos DB, API, or Project) |
| 11 | + |
| 12 | +### Build and Run |
| 13 | + |
| 14 | +#### Option 1: Using the helper scripts (Recommended) |
| 15 | + |
| 16 | +**Linux/macOS:** |
| 17 | +```bash |
| 18 | +# Make the script executable |
| 19 | +chmod +x run-migration.sh |
| 20 | + |
| 21 | +# Run migration with arguments |
| 22 | +./run-migration.sh --help |
| 23 | +./run-migration.sh --use-api --use-v2-api |
| 24 | +./run-migration.sh asst_abc123 --project-connection-string "eastus.api.azureml.ms;...;...;..." |
| 25 | +``` |
| 26 | + |
| 27 | +**Windows:** |
| 28 | +```cmd |
| 29 | +# Run migration with arguments |
| 30 | +run-migration.bat --help |
| 31 | +run-migration.bat --use-api --use-v2-api |
| 32 | +run-migration.bat asst_abc123 --project-connection-string "eastus.api.azureml.ms;...;...;..." |
| 33 | +``` |
| 34 | + |
| 35 | +#### Option 2: Using Docker directly |
| 36 | + |
| 37 | +```bash |
| 38 | +# Build the image |
| 39 | +docker build -t v1-to-v2-migration . |
| 40 | + |
| 41 | +# Run with arguments |
| 42 | +docker run --rm -it \ |
| 43 | + --network host \ |
| 44 | + -v ~/.azure:/home/migration/.azure:ro \ |
| 45 | + -v "$(pwd)/output:/app/output" \ |
| 46 | + -e COSMOS_CONNECTION_STRING \ |
| 47 | + v1-to-v2-migration --help |
| 48 | +``` |
| 49 | + |
| 50 | +#### Option 3: Using Docker Compose |
| 51 | + |
| 52 | +```bash |
| 53 | +# Create .env file from example |
| 54 | +cp .env.example .env |
| 55 | +# Edit .env with your values |
| 56 | + |
| 57 | +# Run with Docker Compose |
| 58 | +docker-compose run --rm v1-to-v2-migration --help |
| 59 | +docker-compose run --rm v1-to-v2-migration --use-api --use-v2-api |
| 60 | +``` |
| 61 | + |
| 62 | +## Configuration |
| 63 | + |
| 64 | +### Environment Variables |
| 65 | + |
| 66 | +The container supports all the same environment variables as the standalone script: |
| 67 | + |
| 68 | +- `COSMOS_CONNECTION_STRING`: Cosmos DB connection string |
| 69 | +- `AGENTS_HOST`: API host (default: eastus.api.azureml.ms) |
| 70 | +- `AGENTS_SUBSCRIPTION`: Azure subscription ID |
| 71 | +- `AGENTS_RESOURCE_GROUP`: Resource group for v1 API |
| 72 | +- `AGENTS_RESOURCE_GROUP_V2`: Resource group for v2 API |
| 73 | +- `AGENTS_WORKSPACE`: Workspace for v1 API |
| 74 | +- `AGENTS_WORKSPACE_V2`: Workspace for v2 API |
| 75 | +- `AGENTS_API_VERSION`: API version (default: 2025-05-15-preview) |
| 76 | +- `AZ_TOKEN`: Optional Azure token (will use Azure CLI if not provided) |
| 77 | + |
| 78 | +### Volume Mounts |
| 79 | + |
| 80 | +- `~/.azure:/home/migration/.azure:ro`: Azure CLI configuration (read-only) |
| 81 | +- `./output:/app/output`: Output directory for logs and results |
| 82 | + |
| 83 | +## Usage Examples |
| 84 | + |
| 85 | +### Test Tool Injection |
| 86 | +```bash |
| 87 | +# Test all tool types |
| 88 | +./run-migration.sh --add-test-function --add-test-mcp --add-test-computer --add-test-imagegen --add-test-azurefunction --use-api |
| 89 | + |
| 90 | +# Test specific tool combinations |
| 91 | +./run-migration.sh --add-test-mcp --add-test-computer --project-connection-string "eastus.api.azureml.ms;...;...;..." |
| 92 | +``` |
| 93 | + |
| 94 | +### Migration Workflows |
| 95 | +```bash |
| 96 | +# Migrate all assistants from API to v2 API |
| 97 | +./run-migration.sh --use-api --use-v2-api |
| 98 | + |
| 99 | +# Migrate specific assistant from Cosmos DB to Cosmos DB |
| 100 | +./run-migration.sh asst_abc123 |
| 101 | + |
| 102 | +# Migrate from project connection to v2 API |
| 103 | +./run-migration.sh --project-connection-string "eastus.api.azureml.ms;...;...;..." --use-v2-api |
| 104 | +``` |
| 105 | + |
| 106 | +## Features |
| 107 | + |
| 108 | +✅ **Complete Migration Pipeline**: All 4 input methods, 2 output methods |
| 109 | +✅ **Tool Testing**: 5 different test tool types for validation |
| 110 | +✅ **Azure CLI Integration**: Automatic token management |
| 111 | +✅ **Security**: Non-root user, read-only mounts |
| 112 | +✅ **Cross-Platform**: Works on Linux, macOS, and Windows |
| 113 | +✅ **Flexible Configuration**: Environment variables, volume mounts |
| 114 | +✅ **Network Access**: Host networking for localhost v2 API access |
| 115 | + |
| 116 | +## Troubleshooting |
| 117 | + |
| 118 | +### Docker Issues |
| 119 | +- Ensure Docker is running: `docker info` |
| 120 | +- Check image build: `docker images | grep v1-to-v2-migration` |
| 121 | + |
| 122 | +### Authentication Issues |
| 123 | +- Verify Azure CLI: `az account show` |
| 124 | +- Check token: `az account get-access-token --scope https://ai.azure.com/.default` |
| 125 | + |
| 126 | +### Network Issues |
| 127 | +- For localhost v2 API, ensure `--network host` is used |
| 128 | +- Check firewall settings for container network access |
| 129 | + |
| 130 | +### Permission Issues |
| 131 | +- Ensure Azure CLI config is readable: `ls -la ~/.azure` |
| 132 | +- Check output directory permissions: `ls -la ./output` |
| 133 | + |
| 134 | +## Development |
| 135 | + |
| 136 | +To modify the container: |
| 137 | + |
| 138 | +1. Edit the migration script: `v1_to_v2_migration.py` |
| 139 | +2. Update dependencies: `requirements.txt` |
| 140 | +3. Rebuild the image: `docker build -t v1-to-v2-migration .` |
| 141 | +4. Test changes: `./run-migration.sh --help` |
0 commit comments