diff --git a/migration/setup-azure-auth.sh b/migration/setup-azure-auth.sh new file mode 100644 index 000000000..f685fbb2e --- /dev/null +++ b/migration/setup-azure-auth.sh @@ -0,0 +1,74 @@ +#!/bin/bash +# Azure CLI Authentication Helper for Docker Container +# This script helps set up Azure CLI authentication for the migration container + +set -e + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +echo -e "${BLUE}๐Ÿ” Azure CLI Authentication Setup for Docker Container${NC}" +echo "========================================================" + +# Check if Docker is running +if ! docker info > /dev/null 2>&1; then + echo -e "${RED}โŒ Docker is not running. Please start Docker and try again.${NC}" + exit 1 +fi + +# Check if Azure CLI is installed +if ! command -v az &> /dev/null; then + echo -e "${RED}โŒ Azure CLI is not installed on the host system.${NC}" + echo -e "${YELLOW}๐Ÿ’ก Install Azure CLI: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli${NC}" + exit 1 +else + echo -e "${GREEN}โœ… Azure CLI is installed on host${NC}" +fi + +# Check if already authenticated +if az account show > /dev/null 2>&1; then + echo -e "${GREEN}โœ… Already authenticated to Azure CLI${NC}" + echo "" + echo -e "${BLUE}๐Ÿ“‹ Current account info:${NC}" + az account show --output table +else + echo -e "${YELLOW}โš ๏ธ Not authenticated to Azure CLI${NC}" + echo -e "${BLUE}๐Ÿ”‘ Starting Azure CLI login process...${NC}" + echo "" + az login + + if [ $? -eq 0 ]; then + echo -e "${GREEN}โœ… Successfully authenticated to Azure CLI${NC}" + echo "" + echo -e "${BLUE}๐Ÿ“‹ Current account info:${NC}" + az account show --output table + else + echo -e "${RED}โŒ Azure CLI login failed${NC}" + exit 1 + fi +fi + +echo "" +echo -e "${BLUE}๐Ÿ”จ Building Docker image with Azure CLI support...${NC}" +docker build -t v1-to-v2-migration . + +echo "" +echo -e "${BLUE}๐Ÿงช Testing Azure CLI authentication in container...${NC}" +docker run --rm -it \ + --network host \ + -v ~/.azure:/home/migration/.azure \ + v1-to-v2-migration \ + /bin/bash -c "az account show --output table || echo 'Authentication test failed'" + +echo "" +echo -e "${GREEN}โœ… Setup complete! You can now run migration commands.${NC}" +echo "" +echo -e "${YELLOW}๐Ÿ“‹ Example commands:${NC}" +echo -e "${NC} ./run-migration.sh --help${NC}" +echo -e "${NC} ./run-migration.sh --project-endpoint \"https://your-endpoint\" --use-v2-api your-assistant-id${NC}" +echo -e "${NC} ./run-migration.sh --project-connection-string \"your-connection-string\" --use-v2-api your-assistant-id${NC}" +echo "" \ No newline at end of file diff --git a/migration/v1_to_v2_migration.py b/migration/v1_to_v2_migration.py index cc28b760a..d1e7bdac6 100644 --- a/migration/v1_to_v2_migration.py +++ b/migration/v1_to_v2_migration.py @@ -1,7 +1,6 @@ import os, sys, time, json, argparse, subprocess, requests from typing import List, Dict, Any, Optional from azure.cosmos import CosmosClient, exceptions -from read_cosmos_data import fetch_data from azure.ai.agents.models import AzureFunctionStorageQueue, AzureFunctionTool # Import AIProjectClient for project endpoint support