1+ #! /bin/bash
2+ # Azure CLI Authentication Helper for Docker Container
3+ # This script helps set up Azure CLI authentication for the migration container
4+
5+ set -e
6+
7+ # Colors for output
8+ RED=' \033[0;31m'
9+ GREEN=' \033[0;32m'
10+ YELLOW=' \033[1;33m'
11+ BLUE=' \033[0;34m'
12+ NC=' \033[0m' # No Color
13+
14+ echo -e " ${BLUE} 🔐 Azure CLI Authentication Setup for Docker Container${NC} "
15+ echo " ========================================================"
16+
17+ # Check if Docker is running
18+ if ! docker info > /dev/null 2>&1 ; then
19+ echo -e " ${RED} ❌ Docker is not running. Please start Docker and try again.${NC} "
20+ exit 1
21+ fi
22+
23+ # Check if Azure CLI is installed
24+ if ! command -v az & > /dev/null; then
25+ echo -e " ${RED} ❌ Azure CLI is not installed on the host system.${NC} "
26+ echo -e " ${YELLOW} 💡 Install Azure CLI: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli${NC} "
27+ exit 1
28+ else
29+ echo -e " ${GREEN} ✅ Azure CLI is installed on host${NC} "
30+ fi
31+
32+ # Check if already authenticated
33+ if az account show > /dev/null 2>&1 ; then
34+ echo -e " ${GREEN} ✅ Already authenticated to Azure CLI${NC} "
35+ echo " "
36+ echo -e " ${BLUE} 📋 Current account info:${NC} "
37+ az account show --output table
38+ else
39+ echo -e " ${YELLOW} ⚠️ Not authenticated to Azure CLI${NC} "
40+ echo -e " ${BLUE} 🔑 Starting Azure CLI login process...${NC} "
41+ echo " "
42+ az login
43+
44+ if [ $? -eq 0 ]; then
45+ echo -e " ${GREEN} ✅ Successfully authenticated to Azure CLI${NC} "
46+ echo " "
47+ echo -e " ${BLUE} 📋 Current account info:${NC} "
48+ az account show --output table
49+ else
50+ echo -e " ${RED} ❌ Azure CLI login failed${NC} "
51+ exit 1
52+ fi
53+ fi
54+
55+ echo " "
56+ echo -e " ${BLUE} 🔨 Building Docker image with Azure CLI support...${NC} "
57+ docker build -t v1-to-v2-migration .
58+
59+ echo " "
60+ echo -e " ${BLUE} 🧪 Testing Azure CLI authentication in container...${NC} "
61+ docker run --rm -it \
62+ --network host \
63+ -v ~ /.azure:/home/migration/.azure \
64+ v1-to-v2-migration \
65+ /bin/bash -c " az account show --output table || echo 'Authentication test failed'"
66+
67+ echo " "
68+ echo -e " ${GREEN} ✅ Setup complete! You can now run migration commands.${NC} "
69+ echo " "
70+ echo -e " ${YELLOW} 📋 Example commands:${NC} "
71+ echo -e " ${NC} ./run-migration.sh --help${NC} "
72+ echo -e " ${NC} ./run-migration.sh --project-endpoint \" https://your-endpoint\" --use-v2-api your-assistant-id${NC} "
73+ echo -e " ${NC} ./run-migration.sh --project-connection-string \" your-connection-string\" --use-v2-api your-assistant-id${NC} "
74+ echo " "
0 commit comments