Skip to content

Commit b8e0ee0

Browse files
committed
added logging
1 parent 7e9ed3e commit b8e0ee0

6 files changed

Lines changed: 147 additions & 25 deletions

File tree

run-samples.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,17 @@ if [ -n "${AZURE_CONFIG_DIR:-}" ]; then
5757
fi
5858

5959
if command -v azlocal >/dev/null 2>&1; then
60+
echo "[DEBUG] azlocal command found, attempting login..."
6061
azlocal login || true
62+
echo "[DEBUG] Starting azlocal interception..."
6163
azlocal start_interception
64+
echo "[DEBUG] Checking azlocal account status..."
65+
azlocal account show --query "{Environment:environmentName, Subscription:id}" --output json 2>&1 || echo "[DEBUG] azlocal account show failed"
6266
else
67+
echo "[DEBUG] azlocal not found, using standard az login with service principal..."
6368
az login --service-principal -u any-app -p any-pass --tenant any-tenant || true
69+
echo "[DEBUG] Checking az account status..."
70+
az account show --query "{Environment:environmentName, Subscription:id}" --output json 2>&1 || echo "[DEBUG] az account show failed"
6471
fi
6572

6673

samples/function-app-managed-identity/python/terraform/deploy.sh

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,35 @@ ZIPFILE="function_app.zip"
1111
# Change the current directory to the script's directory
1212
cd "$CURRENT_DIR" || exit
1313

14-
# Determine environment - check if azlocal is configured first
15-
ENVIRONMENT=$(azlocal account show --query environmentName --output tsv 2>/dev/null || echo "")
14+
# Determine environment with detailed logging
15+
echo "[DEBUG] Starting environment detection..."
16+
echo "[DEBUG] Checking for azlocal command..."
17+
if command -v azlocal >/dev/null 2>&1; then
18+
echo "[DEBUG] azlocal command exists, attempting to query environment..."
19+
ENVIRONMENT=$(azlocal account show --query environmentName --output tsv 2>&1)
20+
AZLOCAL_EXIT_CODE=$?
21+
echo "[DEBUG] azlocal exit code: $AZLOCAL_EXIT_CODE"
22+
echo "[DEBUG] azlocal output: '$ENVIRONMENT'"
23+
else
24+
echo "[DEBUG] azlocal command not found"
25+
ENVIRONMENT=""
26+
fi
1627

17-
if [[ -z "$ENVIRONMENT" ]]; then
18-
# Try with regular az if azlocal failed
19-
ENVIRONMENT=$(az account show --query environmentName --output tsv 2>/dev/null || echo "AzureCloud")
28+
if [[ -z "$ENVIRONMENT" || "$ENVIRONMENT" == *"ERROR"* || "$ENVIRONMENT" == *"error"* ]]; then
29+
echo "[DEBUG] azlocal failed or returned empty, trying standard az..."
30+
ENVIRONMENT=$(az account show --query environmentName --output tsv 2>&1)
31+
AZ_EXIT_CODE=$?
32+
echo "[DEBUG] az exit code: $AZ_EXIT_CODE"
33+
echo "[DEBUG] az output: '$ENVIRONMENT'"
34+
35+
if [[ -z "$ENVIRONMENT" || "$ENVIRONMENT" == *"ERROR"* || "$ENVIRONMENT" == *"error"* ]]; then
36+
echo "[DEBUG] Both azlocal and az failed, defaulting to AzureCloud"
37+
ENVIRONMENT="AzureCloud"
38+
fi
2039
fi
2140

41+
echo "[DEBUG] Final detected environment: '$ENVIRONMENT'"
42+
2243
# Run terraform init and apply
2344
if [[ $ENVIRONMENT == "LocalStack" ]]; then
2445
echo "Using tflocal and azlocal for LocalStack emulator environment."
@@ -30,6 +51,8 @@ else
3051
AZ="az"
3152
fi
3253

54+
echo "[DEBUG] Selected tools: TERRAFORM=$TERRAFORM, AZ=$AZ"
55+
3356
echo "Initializing Terraform..."
3457
$TERRAFORM init -upgrade
3558

samples/function-app-storage-http/dotnet/terraform/deploy.sh

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,35 @@ ZIPFILE="function_app.zip"
1010
# Change the current directory to the script's directory
1111
cd "$CURRENT_DIR" || exit
1212

13-
# Determine environment - check if azlocal is configured first
14-
ENVIRONMENT=$(azlocal account show --query environmentName --output tsv 2>/dev/null || echo "")
13+
# Determine environment with detailed logging
14+
echo "[DEBUG] Starting environment detection..."
15+
echo "[DEBUG] Checking for azlocal command..."
16+
if command -v azlocal >/dev/null 2>&1; then
17+
echo "[DEBUG] azlocal command exists, attempting to query environment..."
18+
ENVIRONMENT=$(azlocal account show --query environmentName --output tsv 2>&1)
19+
AZLOCAL_EXIT_CODE=$?
20+
echo "[DEBUG] azlocal exit code: $AZLOCAL_EXIT_CODE"
21+
echo "[DEBUG] azlocal output: '$ENVIRONMENT'"
22+
else
23+
echo "[DEBUG] azlocal command not found"
24+
ENVIRONMENT=""
25+
fi
1526

16-
if [[ -z "$ENVIRONMENT" ]]; then
17-
# Try with regular az if azlocal failed
18-
ENVIRONMENT=$(az account show --query environmentName --output tsv 2>/dev/null || echo "AzureCloud")
27+
if [[ -z "$ENVIRONMENT" || "$ENVIRONMENT" == *"ERROR"* || "$ENVIRONMENT" == *"error"* ]]; then
28+
echo "[DEBUG] azlocal failed or returned empty, trying standard az..."
29+
ENVIRONMENT=$(az account show --query environmentName --output tsv 2>&1)
30+
AZ_EXIT_CODE=$?
31+
echo "[DEBUG] az exit code: $AZ_EXIT_CODE"
32+
echo "[DEBUG] az output: '$ENVIRONMENT'"
33+
34+
if [[ -z "$ENVIRONMENT" || "$ENVIRONMENT" == *"ERROR"* || "$ENVIRONMENT" == *"error"* ]]; then
35+
echo "[DEBUG] Both azlocal and az failed, defaulting to AzureCloud"
36+
ENVIRONMENT="AzureCloud"
37+
fi
1938
fi
2039

40+
echo "[DEBUG] Final detected environment: '$ENVIRONMENT'"
41+
2142
# Run terraform init and apply
2243
if [[ $ENVIRONMENT == "LocalStack" ]]; then
2344
echo "Using tflocal and azlocal for LocalStack emulator environment."
@@ -29,6 +50,8 @@ else
2950
AZ="az"
3051
fi
3152

53+
echo "[DEBUG] Selected tools: TERRAFORM=$TERRAFORM, AZ=$AZ"
54+
3255
echo "Initializing Terraform..."
3356
$TERRAFORM init -upgrade
3457

samples/web-app-cosmosdb-mongodb-api/python/terraform/deploy.sh

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,35 @@ ZIPFILE="planner_website.zip"
1010
# Change the current directory to the script's directory
1111
cd "$CURRENT_DIR" || exit
1212

13-
# Determine environment - check if azlocal is configured first
14-
ENVIRONMENT=$(azlocal account show --query environmentName --output tsv 2>/dev/null || echo "")
13+
# Determine environment with detailed logging
14+
echo "[DEBUG] Starting environment detection..."
15+
echo "[DEBUG] Checking for azlocal command..."
16+
if command -v azlocal >/dev/null 2>&1; then
17+
echo "[DEBUG] azlocal command exists, attempting to query environment..."
18+
ENVIRONMENT=$(azlocal account show --query environmentName --output tsv 2>&1)
19+
AZLOCAL_EXIT_CODE=$?
20+
echo "[DEBUG] azlocal exit code: $AZLOCAL_EXIT_CODE"
21+
echo "[DEBUG] azlocal output: '$ENVIRONMENT'"
22+
else
23+
echo "[DEBUG] azlocal command not found"
24+
ENVIRONMENT=""
25+
fi
1526

16-
if [[ -z "$ENVIRONMENT" ]]; then
17-
# Try with regular az if azlocal failed
18-
ENVIRONMENT=$(az account show --query environmentName --output tsv 2>/dev/null || echo "AzureCloud")
27+
if [[ -z "$ENVIRONMENT" || "$ENVIRONMENT" == *"ERROR"* || "$ENVIRONMENT" == *"error"* ]]; then
28+
echo "[DEBUG] azlocal failed or returned empty, trying standard az..."
29+
ENVIRONMENT=$(az account show --query environmentName --output tsv 2>&1)
30+
AZ_EXIT_CODE=$?
31+
echo "[DEBUG] az exit code: $AZ_EXIT_CODE"
32+
echo "[DEBUG] az output: '$ENVIRONMENT'"
33+
34+
if [[ -z "$ENVIRONMENT" || "$ENVIRONMENT" == *"ERROR"* || "$ENVIRONMENT" == *"error"* ]]; then
35+
echo "[DEBUG] Both azlocal and az failed, defaulting to AzureCloud"
36+
ENVIRONMENT="AzureCloud"
37+
fi
1938
fi
2039

40+
echo "[DEBUG] Final detected environment: '$ENVIRONMENT'"
41+
2142
# Run terraform init and apply
2243
if [[ $ENVIRONMENT == "LocalStack" ]]; then
2344
echo "Using tflocal and azlocal for LocalStack emulator environment."
@@ -29,6 +50,8 @@ else
2950
AZ="az"
3051
fi
3152

53+
echo "[DEBUG] Selected tools: TERRAFORM=$TERRAFORM, AZ=$AZ"
54+
3255
echo "Initializing Terraform..."
3356
$TERRAFORM init -upgrade
3457

samples/web-app-managed-identity/python/terraform/deploy.sh

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,35 @@ ZIPFILE="planner_website.zip"
1111
# Change the current directory to the script's directory
1212
cd "$CURRENT_DIR" || exit
1313

14-
# Determine environment - check if azlocal is configured first
15-
ENVIRONMENT=$(azlocal account show --query environmentName --output tsv 2>/dev/null || echo "")
14+
# Determine environment with detailed logging
15+
echo "[DEBUG] Starting environment detection..."
16+
echo "[DEBUG] Checking for azlocal command..."
17+
if command -v azlocal >/dev/null 2>&1; then
18+
echo "[DEBUG] azlocal command exists, attempting to query environment..."
19+
ENVIRONMENT=$(azlocal account show --query environmentName --output tsv 2>&1)
20+
AZLOCAL_EXIT_CODE=$?
21+
echo "[DEBUG] azlocal exit code: $AZLOCAL_EXIT_CODE"
22+
echo "[DEBUG] azlocal output: '$ENVIRONMENT'"
23+
else
24+
echo "[DEBUG] azlocal command not found"
25+
ENVIRONMENT=""
26+
fi
1627

17-
if [[ -z "$ENVIRONMENT" ]]; then
18-
# Try with regular az if azlocal failed
19-
ENVIRONMENT=$(az account show --query environmentName --output tsv 2>/dev/null || echo "AzureCloud")
28+
if [[ -z "$ENVIRONMENT" || "$ENVIRONMENT" == *"ERROR"* || "$ENVIRONMENT" == *"error"* ]]; then
29+
echo "[DEBUG] azlocal failed or returned empty, trying standard az..."
30+
ENVIRONMENT=$(az account show --query environmentName --output tsv 2>&1)
31+
AZ_EXIT_CODE=$?
32+
echo "[DEBUG] az exit code: $AZ_EXIT_CODE"
33+
echo "[DEBUG] az output: '$ENVIRONMENT'"
34+
35+
if [[ -z "$ENVIRONMENT" || "$ENVIRONMENT" == *"ERROR"* || "$ENVIRONMENT" == *"error"* ]]; then
36+
echo "[DEBUG] Both azlocal and az failed, defaulting to AzureCloud"
37+
ENVIRONMENT="AzureCloud"
38+
fi
2039
fi
2140

41+
echo "[DEBUG] Final detected environment: '$ENVIRONMENT'"
42+
2243
# Run terraform init and apply
2344
if [[ $ENVIRONMENT == "LocalStack" ]]; then
2445
echo "Using tflocal and azlocal for LocalStack emulator environment."
@@ -30,6 +51,8 @@ else
3051
AZ="az"
3152
fi
3253

54+
echo "[DEBUG] Selected tools: TERRAFORM=$TERRAFORM, AZ=$AZ"
55+
3356
echo "Initializing Terraform..."
3457
$TERRAFORM init -upgrade
3558

samples/web-app-sql-database/python/terraform/deploy.sh

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,35 @@ DEPLOY_APP=1
1515
# Change the current directory to the script's directory
1616
cd "$CURRENT_DIR" || exit
1717

18-
# Determine environment - check if azlocal is configured first
19-
ENVIRONMENT=$(azlocal account show --query environmentName --output tsv 2>/dev/null || echo "")
18+
# Determine environment with detailed logging
19+
echo "[DEBUG] Starting environment detection..."
20+
echo "[DEBUG] Checking for azlocal command..."
21+
if command -v azlocal >/dev/null 2>&1; then
22+
echo "[DEBUG] azlocal command exists, attempting to query environment..."
23+
ENVIRONMENT=$(azlocal account show --query environmentName --output tsv 2>&1)
24+
AZLOCAL_EXIT_CODE=$?
25+
echo "[DEBUG] azlocal exit code: $AZLOCAL_EXIT_CODE"
26+
echo "[DEBUG] azlocal output: '$ENVIRONMENT'"
27+
else
28+
echo "[DEBUG] azlocal command not found"
29+
ENVIRONMENT=""
30+
fi
2031

21-
if [[ -z "$ENVIRONMENT" ]]; then
22-
# Try with regular az if azlocal failed
23-
ENVIRONMENT=$(az account show --query environmentName --output tsv 2>/dev/null || echo "AzureCloud")
32+
if [[ -z "$ENVIRONMENT" || "$ENVIRONMENT" == *"ERROR"* || "$ENVIRONMENT" == *"error"* ]]; then
33+
echo "[DEBUG] azlocal failed or returned empty, trying standard az..."
34+
ENVIRONMENT=$(az account show --query environmentName --output tsv 2>&1)
35+
AZ_EXIT_CODE=$?
36+
echo "[DEBUG] az exit code: $AZ_EXIT_CODE"
37+
echo "[DEBUG] az output: '$ENVIRONMENT'"
38+
39+
if [[ -z "$ENVIRONMENT" || "$ENVIRONMENT" == *"ERROR"* || "$ENVIRONMENT" == *"error"* ]]; then
40+
echo "[DEBUG] Both azlocal and az failed, defaulting to AzureCloud"
41+
ENVIRONMENT="AzureCloud"
42+
fi
2443
fi
2544

45+
echo "[DEBUG] Final detected environment: '$ENVIRONMENT'"
46+
2647
# Run terraform init and apply
2748
if [[ $ENVIRONMENT == "LocalStack" ]]; then
2849
echo "Using tflocal and azlocal for LocalStack emulator environment."
@@ -34,6 +55,8 @@ else
3455
AZ="az"
3556
fi
3657

58+
echo "[DEBUG] Selected tools: TERRAFORM=$TERRAFORM, AZ=$AZ"
59+
3760
echo "Initializing Terraform..."
3861
$TERRAFORM init -upgrade
3962

0 commit comments

Comments
 (0)