Skip to content

Commit 004dc4d

Browse files
committed
added logging
1 parent b8e0ee0 commit 004dc4d

10 files changed

Lines changed: 55 additions & 190 deletions

File tree

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

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

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
27-
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'"
14+
# Determine environment
15+
if command -v az >/dev/null 2>&1; then
16+
CLOUD_NAME=$(az cloud show --query name --output tsv 2>&1 || echo "")
3417

35-
if [[ -z "$ENVIRONMENT" || "$ENVIRONMENT" == *"ERROR"* || "$ENVIRONMENT" == *"error"* ]]; then
36-
echo "[DEBUG] Both azlocal and az failed, defaulting to AzureCloud"
18+
if [[ "$CLOUD_NAME" == "LocalStack" ]]; then
19+
ENVIRONMENT="LocalStack"
20+
elif [[ "$CLOUD_NAME" == "AzureCloud" ]]; then
21+
ENVIRONMENT="AzureCloud"
22+
else
3723
ENVIRONMENT="AzureCloud"
3824
fi
25+
else
26+
ENVIRONMENT="AzureCloud"
3927
fi
4028

41-
echo "[DEBUG] Final detected environment: '$ENVIRONMENT'"
42-
4329
# Run terraform init and apply
4430
if [[ $ENVIRONMENT == "LocalStack" ]]; then
4531
echo "Using tflocal and azlocal for LocalStack emulator environment."
@@ -51,7 +37,7 @@ else
5137
AZ="az"
5238
fi
5339

54-
echo "[DEBUG] Selected tools: TERRAFORM=$TERRAFORM, AZ=$AZ"
40+
echo "[DEBUG] Cloud name: '$CLOUD_NAME', Environment: '$ENVIRONMENT', Tools: TERRAFORM=$TERRAFORM, AZ=$AZ"
5541

5642
echo "Initializing Terraform..."
5743
$TERRAFORM init -upgrade

samples/function-app-managed-identity/python/terraform/providers.tf

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,4 @@ provider "azurerm" {
1818

1919
# LocalStack Azure emulator uses a fixed subscription id
2020
subscription_id = "00000000-0000-0000-0000-000000000000"
21-
22-
# The following configs are required for local testing
23-
# Skip provider registration and authentication for LocalStack
24-
skip_provider_registration = true
25-
26-
# Use environment variables or static values for LocalStack
27-
tenant_id = "00000000-0000-0000-0000-000000000000"
28-
client_id = "00000000-0000-0000-0000-000000000000"
29-
client_secret = "fake-secret"
30-
31-
# Disable authentication checks
32-
use_cli = false
33-
use_msi = false
3421
}

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

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

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
26-
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'"
13+
# Determine environment
14+
if command -v az >/dev/null 2>&1; then
15+
CLOUD_NAME=$(az cloud show --query name --output tsv 2>&1 || echo "")
3316

34-
if [[ -z "$ENVIRONMENT" || "$ENVIRONMENT" == *"ERROR"* || "$ENVIRONMENT" == *"error"* ]]; then
35-
echo "[DEBUG] Both azlocal and az failed, defaulting to AzureCloud"
17+
if [[ "$CLOUD_NAME" == "LocalStack" ]]; then
18+
ENVIRONMENT="LocalStack"
19+
elif [[ "$CLOUD_NAME" == "AzureCloud" ]]; then
20+
ENVIRONMENT="AzureCloud"
21+
else
3622
ENVIRONMENT="AzureCloud"
3723
fi
24+
else
25+
ENVIRONMENT="AzureCloud"
3826
fi
3927

40-
echo "[DEBUG] Final detected environment: '$ENVIRONMENT'"
41-
4228
# Run terraform init and apply
4329
if [[ $ENVIRONMENT == "LocalStack" ]]; then
4430
echo "Using tflocal and azlocal for LocalStack emulator environment."
@@ -50,7 +36,7 @@ else
5036
AZ="az"
5137
fi
5238

53-
echo "[DEBUG] Selected tools: TERRAFORM=$TERRAFORM, AZ=$AZ"
39+
echo "[DEBUG] Cloud name: '$CLOUD_NAME', Environment: '$ENVIRONMENT', Tools: TERRAFORM=$TERRAFORM, AZ=$AZ"
5440

5541
echo "Initializing Terraform..."
5642
$TERRAFORM init -upgrade

samples/function-app-storage-http/dotnet/terraform/providers.tf

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,4 @@ provider "azurerm" {
1818

1919
# LocalStack Azure emulator uses a fixed subscription id
2020
subscription_id = "00000000-0000-0000-0000-000000000000"
21-
22-
# The following configs are required for local testing
23-
# Skip provider registration and authentication for LocalStack
24-
skip_provider_registration = true
25-
26-
# Use environment variables or static values for LocalStack
27-
tenant_id = "00000000-0000-0000-0000-000000000000"
28-
client_id = "00000000-0000-0000-0000-000000000000"
29-
client_secret = "fake-secret"
30-
31-
# Disable authentication checks
32-
use_cli = false
33-
use_msi = false
3421
}

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

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

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
26-
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'"
13+
# Determine environment
14+
if command -v az >/dev/null 2>&1; then
15+
CLOUD_NAME=$(az cloud show --query name --output tsv 2>&1 || echo "")
3316

34-
if [[ -z "$ENVIRONMENT" || "$ENVIRONMENT" == *"ERROR"* || "$ENVIRONMENT" == *"error"* ]]; then
35-
echo "[DEBUG] Both azlocal and az failed, defaulting to AzureCloud"
17+
if [[ "$CLOUD_NAME" == "LocalStack" ]]; then
18+
ENVIRONMENT="LocalStack"
19+
elif [[ "$CLOUD_NAME" == "AzureCloud" ]]; then
20+
ENVIRONMENT="AzureCloud"
21+
else
3622
ENVIRONMENT="AzureCloud"
3723
fi
24+
else
25+
ENVIRONMENT="AzureCloud"
3826
fi
3927

40-
echo "[DEBUG] Final detected environment: '$ENVIRONMENT'"
41-
4228
# Run terraform init and apply
4329
if [[ $ENVIRONMENT == "LocalStack" ]]; then
4430
echo "Using tflocal and azlocal for LocalStack emulator environment."
@@ -50,7 +36,7 @@ else
5036
AZ="az"
5137
fi
5238

53-
echo "[DEBUG] Selected tools: TERRAFORM=$TERRAFORM, AZ=$AZ"
39+
echo "[DEBUG] Cloud name: '$CLOUD_NAME', Environment: '$ENVIRONMENT', Tools: TERRAFORM=$TERRAFORM, AZ=$AZ"
5440

5541
echo "Initializing Terraform..."
5642
$TERRAFORM init -upgrade

samples/web-app-cosmosdb-mongodb-api/python/terraform/providers.tf

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,4 @@ provider "azurerm" {
1818

1919
# LocalStack Azure emulator uses a fixed subscription id
2020
subscription_id = "00000000-0000-0000-0000-000000000000"
21-
22-
# The following configs are required for local testing
23-
# Skip provider registration and authentication for LocalStack
24-
skip_provider_registration = true
25-
26-
# Use environment variables or static values for LocalStack
27-
tenant_id = "00000000-0000-0000-0000-000000000000"
28-
client_id = "00000000-0000-0000-0000-000000000000"
29-
client_secret = "fake-secret"
30-
31-
# Disable authentication checks
32-
use_cli = false
33-
use_msi = false
3421
}

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

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

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
27-
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'"
14+
# Determine environment
15+
if command -v az >/dev/null 2>&1; then
16+
CLOUD_NAME=$(az cloud show --query name --output tsv 2>&1 || echo "")
3417

35-
if [[ -z "$ENVIRONMENT" || "$ENVIRONMENT" == *"ERROR"* || "$ENVIRONMENT" == *"error"* ]]; then
36-
echo "[DEBUG] Both azlocal and az failed, defaulting to AzureCloud"
18+
if [[ "$CLOUD_NAME" == "LocalStack" ]]; then
19+
ENVIRONMENT="LocalStack"
20+
elif [[ "$CLOUD_NAME" == "AzureCloud" ]]; then
21+
ENVIRONMENT="AzureCloud"
22+
else
3723
ENVIRONMENT="AzureCloud"
3824
fi
25+
else
26+
ENVIRONMENT="AzureCloud"
3927
fi
4028

41-
echo "[DEBUG] Final detected environment: '$ENVIRONMENT'"
42-
4329
# Run terraform init and apply
4430
if [[ $ENVIRONMENT == "LocalStack" ]]; then
4531
echo "Using tflocal and azlocal for LocalStack emulator environment."
@@ -51,7 +37,7 @@ else
5137
AZ="az"
5238
fi
5339

54-
echo "[DEBUG] Selected tools: TERRAFORM=$TERRAFORM, AZ=$AZ"
40+
echo "[DEBUG] Cloud name: '$CLOUD_NAME', Environment: '$ENVIRONMENT', Tools: TERRAFORM=$TERRAFORM, AZ=$AZ"
5541

5642
echo "Initializing Terraform..."
5743
$TERRAFORM init -upgrade

samples/web-app-managed-identity/python/terraform/providers.tf

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,4 @@ provider "azurerm" {
1818

1919
# LocalStack Azure emulator uses a fixed subscription id
2020
subscription_id = "00000000-0000-0000-0000-000000000000"
21-
22-
# The following configs are required for local testing
23-
# Skip provider registration and authentication for LocalStack
24-
skip_provider_registration = true
25-
26-
# Use environment variables or static values for LocalStack
27-
tenant_id = "00000000-0000-0000-0000-000000000000"
28-
client_id = "00000000-0000-0000-0000-000000000000"
29-
client_secret = "fake-secret"
30-
31-
# Disable authentication checks
32-
use_cli = false
33-
use_msi = false
3421
}

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

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

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
31-
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'"
18+
# Determine environment
19+
if command -v az >/dev/null 2>&1; then
20+
CLOUD_NAME=$(az cloud show --query name --output tsv 2>&1 || echo "")
3821

39-
if [[ -z "$ENVIRONMENT" || "$ENVIRONMENT" == *"ERROR"* || "$ENVIRONMENT" == *"error"* ]]; then
40-
echo "[DEBUG] Both azlocal and az failed, defaulting to AzureCloud"
22+
if [[ "$CLOUD_NAME" == "LocalStack" ]]; then
23+
ENVIRONMENT="LocalStack"
24+
elif [[ "$CLOUD_NAME" == "AzureCloud" ]]; then
25+
ENVIRONMENT="AzureCloud"
26+
else
4127
ENVIRONMENT="AzureCloud"
4228
fi
29+
else
30+
ENVIRONMENT="AzureCloud"
4331
fi
4432

45-
echo "[DEBUG] Final detected environment: '$ENVIRONMENT'"
46-
4733
# Run terraform init and apply
4834
if [[ $ENVIRONMENT == "LocalStack" ]]; then
4935
echo "Using tflocal and azlocal for LocalStack emulator environment."
@@ -55,7 +41,7 @@ else
5541
AZ="az"
5642
fi
5743

58-
echo "[DEBUG] Selected tools: TERRAFORM=$TERRAFORM, AZ=$AZ"
44+
echo "[DEBUG] Cloud name: '$CLOUD_NAME', Environment: '$ENVIRONMENT', Tools: TERRAFORM=$TERRAFORM, AZ=$AZ"
5945

6046
echo "Initializing Terraform..."
6147
$TERRAFORM init -upgrade

samples/web-app-sql-database/python/terraform/providers.tf

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,4 @@ provider "azurerm" {
1818

1919
# LocalStack Azure emulator uses a fixed subscription id
2020
subscription_id = "00000000-0000-0000-0000-000000000000"
21-
22-
# The following configs are required for local testing
23-
# Skip provider registration and authentication for LocalStack
24-
skip_provider_registration = true
25-
26-
# Use environment variables or static values for LocalStack
27-
tenant_id = "00000000-0000-0000-0000-000000000000"
28-
client_id = "00000000-0000-0000-0000-000000000000"
29-
client_secret = "fake-secret"
30-
31-
# Disable authentication checks
32-
use_cli = false
33-
use_msi = false
3421
}

0 commit comments

Comments
 (0)