Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions run-samples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,17 @@ if [ -n "${AZURE_CONFIG_DIR:-}" ]; then
mkdir -p "$AZURE_CONFIG_DIR"
fi

if command -v azlocal >/dev/null 2>&1; then
echo "[DEBUG] azlocal command found, attempting login..."
azlocal login || true
echo "[DEBUG] Starting azlocal interception..."
azlocal start-interception
if command -v az >/dev/null 2>&1; then
echo "[DEBUG] az command found, attempting login..."
az login || true
echo "[DEBUG] Starting az interception..."
az start-interception
echo "[DEBUG] Setting default subscription..."
azlocal account set --subscription "00000000-0000-0000-0000-000000000000" || true
echo "[DEBUG] Checking azlocal account status..."
azlocal account show --query "{Environment:environmentName, Subscription:id}" --output json 2>&1 || echo "[DEBUG] azlocal account show failed"
az account set --subscription "00000000-0000-0000-0000-000000000000" || true
echo "[DEBUG] Checking az account status..."
az account show --query "{Environment:environmentName, Subscription:id}" --output json 2>&1 || echo "[DEBUG] az account show failed"
else
echo "[DEBUG] azlocal not found, using standard az login with service principal..."
echo "[DEBUG] az not found, using standard az login with service principal..."
az login --service-principal -u any-app -p any-pass --tenant any-tenant || true
echo "[DEBUG] Checking az account status..."
az account show --query "{Environment:environmentName, Subscription:id}" --output json 2>&1 || echo "[DEBUG] az account show failed"
Expand Down Expand Up @@ -188,13 +188,13 @@ for (( i=START; i<START+COUNT; i++ )); do

# Clean up Azure resources to prevent state pollution between tests
echo "Cleaning up Azure resources in LocalStack..."
if command -v azlocal >/dev/null 2>&1; then
RG_LIST=$(azlocal group list --query "[].name" -o tsv 2>/dev/null || echo "")
if command -v az >/dev/null 2>&1; then
RG_LIST=$(az group list --query "[].name" -o tsv 2>/dev/null || echo "")
if [[ -n "$RG_LIST" ]]; then
echo "$RG_LIST" | while read -r rg; do
if [[ -n "$rg" ]]; then
echo " - Deleting resource group: $rg"
azlocal group delete --name "$rg" --yes --no-wait 2>/dev/null || true
az group delete --name "$rg" --yes --no-wait 2>/dev/null || true
fi
done
sleep 2
Expand Down
7 changes: 0 additions & 7 deletions samples/aci-blob-storage/python/scripts/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ KEY_VAULT_NAME="${PREFIX}acikv"
ACR_NAME="${PREFIX}aciacr"
STORAGE_ACCOUNT_NAME="${PREFIX}acistorage"

# Choose the appropriate CLI based on the environment
if [[ $ENVIRONMENT == "LocalStack" ]]; then
AZ="azlocal"
else
AZ="az"
fi

echo "============================================================"
echo "Cleaning up ACI Vacation Planner Resources"
echo "============================================================"
Expand Down
7 changes: 0 additions & 7 deletions samples/aci-blob-storage/python/scripts/validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ ACI_GROUP_NAME="${PREFIX}-aci-planner"
PASS_COUNT=0
FAIL_COUNT=0

# Choose the appropriate CLI based on the environment
if [[ $ENVIRONMENT == "LocalStack" ]]; then
AZ="azlocal"
else
AZ="az"
fi

check() {
local description="$1"
local command="$2"
Expand Down
9 changes: 0 additions & 9 deletions samples/aci-blob-storage/python/terraform/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@ CURRENT_DIR="$(cd "$(dirname "$0")" && pwd)"
# Change the current directory to the script's directory
cd "$CURRENT_DIR" || exit

# Choose the appropriate CLI based on the environment
if [[ $ENVIRONMENT == "LocalStack" ]]; then
echo "Using azlocal for LocalStack emulator environment."
AZ="azlocal"
else
echo "Using standard terraform and az for AzureCloud environment."
AZ="az"
fi

# =============================================================================
# Build and push the Docker image before Terraform deployment
# (Terraform references the pre-created ACR as a data source)
Expand Down
15 changes: 7 additions & 8 deletions samples/function-app-front-door/python/scripts/cleanup_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Usage: $(basename "$0") [--env-file PATH] [--resource-group NAME] [--use-localst
Options:
--env-file PATH Env file produced by deploy_all.sh (e.g., scripts/.last_deploy_all.env)
-g, --resource-group Resource group name to delete
--use-localstack Use azlocal interception to target LocalStack emulator
-h, --help Show this help
EOF
}
Expand Down Expand Up @@ -59,8 +58,8 @@ fi
INTERCEPTION_STARTED="false"
AZURE_CONFIG_DIR_CREATED="false"
finish() {
if [[ "$INTERCEPTION_STARTED" == "true" ]] && command -v azlocal >/dev/null 2>&1; then
set +e; azlocal stop-interception >/dev/null 2>&1 || true; set -e
if [[ "$INTERCEPTION_STARTED" == "true" ]] && command -v az >/dev/null 2>&1; then
set +e; az stop-interception >/dev/null 2>&1 || true; set -e
fi
if [[ "$AZURE_CONFIG_DIR_CREATED" == "true" && -n "${AZURE_CONFIG_DIR:-}" && -d "$AZURE_CONFIG_DIR" ]]; then
rm -rf "$AZURE_CONFIG_DIR"
Expand All @@ -69,17 +68,17 @@ finish() {
trap finish EXIT

if [[ "$USE_LOCALSTACK" == "true" ]]; then
if command -v mktemp >/dev/null 2>&1; then AZ_TEMP_CONFIG_DIR="$(mktemp -d)"; else AZ_TEMP_CONFIG_DIR="$(pwd)/.azlocal_config_$$"; mkdir -p "$AZ_TEMP_CONFIG_DIR"; fi
if command -v mktemp >/dev/null 2>&1; then AZ_TEMP_CONFIG_DIR="$(mktemp -d)"; else AZ_TEMP_CONFIG_DIR="$(pwd)/.az_config_$$"; mkdir -p "$AZ_TEMP_CONFIG_DIR"; fi
export AZURE_CONFIG_DIR="$AZ_TEMP_CONFIG_DIR"; AZURE_CONFIG_DIR_CREATED="true"
echo "Using isolated AZURE_CONFIG_DIR at: $AZURE_CONFIG_DIR"
if ! command -v azlocal >/dev/null 2>&1; then
echo "Error: --use-localstack specified but 'azlocal' was not found in PATH." >&2
if ! command -v az >/dev/null 2>&1; then
echo "Error: --use-localstack specified but 'az' was not found in PATH." >&2
exit 1
fi
if azlocal start-interception; then
if az start-interception; then
INTERCEPTION_STARTED="true"; echo "LocalStack interception started."
else
echo "Error: azlocal failed to start interception. Ensure LocalStack is running and azlocal is configured correctly." >&2
echo "Error: az failed to start interception. Ensure LocalStack is running and az is configured correctly." >&2
exit 1
fi
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ finish() {
[[ -f "$ZIP_MAIN" ]] && rm -f "$ZIP_MAIN"
[[ -f "$ZIP_A" ]] && rm -f "$ZIP_A"
[[ -f "$ZIP_B" ]] && rm -f "$ZIP_B"
if [[ "$INTERCEPTION_STARTED" == "true" ]] && command -v azlocal >/dev/null 2>&1; then
azlocal stop-interception >/dev/null 2>&1 || true
if [[ "$INTERCEPTION_STARTED" == "true" ]] && command -v az >/dev/null 2>&1; then
az stop-interception >/dev/null 2>&1 || true
fi
if [[ "$AZURE_CONFIG_DIR_CREATED" == "true" && -n "${AZURE_CONFIG_DIR:-}" && -d "$AZURE_CONFIG_DIR" ]]; then
rm -rf "$AZURE_CONFIG_DIR"
Expand All @@ -176,7 +176,7 @@ if [[ "$USE_LOCALSTACK" == "true" ]]; then
echo "Error: --use-localstack specified but 'azlocal' not found in PATH." >&2
exit 1
fi
if azlocal start-interception; then
if az start-interception; then
INTERCEPTION_STARTED="true"; echo "LocalStack interception started."
else
echo "Error: azlocal failed to start interception. Ensure LocalStack is running." >&2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ get_docker_container_port_mapping() {
call_web_app() {
# Get the web app name
echo "Getting web app name..."
web_app_name=$(azlocal webapp list --query '[0].name' --output tsv)
web_app_name=$(az webapp list --query '[0].name' --output tsv)

if [ -n "$web_app_name" ]; then
echo "Web app [$web_app_name] successfully retrieved."
Expand All @@ -79,7 +79,7 @@ call_web_app() {

# Get the resource group name
echo "Getting resource group name for web app [$web_app_name]..."
resource_group_name=$(azlocal webapp list --query '[0].resourceGroup' --output tsv)
resource_group_name=$(az webapp list --query '[0].resourceGroup' --output tsv)

if [ -n "$resource_group_name" ]; then
echo "Resource group [$resource_group_name] successfully retrieved."
Expand All @@ -90,7 +90,7 @@ call_web_app() {

# Get the the default host name of the web app
echo "Getting the default host name of the web app [$web_app_name]..."
app_host_name=$(azlocal webapp show \
app_host_name=$(az webapp show \
--name "$web_app_name" \
--resource-group "$resource_group_name" \
--query 'defaultHostName' \
Expand Down
25 changes: 12 additions & 13 deletions samples/web-app-cosmosdb-nosql-api/python/scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ AZURECOSMOSDB_CONTAINERNAME="activities_${RANDOM_SUFFIX}"
AURECOSMOSDB_PARTITION_KEY="/partitionKey"

# Start azure CLI local mode session
azlocal login
az login

# Change the current directory to the script's directory
#cd "$CURRENT_DIR" || exit

# Validates if the resource group exists in the subscription, if not creates it
echo "Checking if resource group [$RESOURCE_GROUP_NAME] exists..."
azlocal group show --name $RESOURCE_GROUP_NAME &>/dev/null
az group show --name $RESOURCE_GROUP_NAME &>/dev/null

if [[ $? != 0 ]]; then
echo "No resource group [$RESOURCE_GROUP_NAME] exists"
echo "Creating resource group [$RESOURCE_GROUP_NAME]..."

# Create the resource group
azlocal group create \
az group create \
--name $RESOURCE_GROUP_NAME \
--location $LOCATION \
--only-show-errors 1> /dev/null \
Expand All @@ -48,7 +48,7 @@ else
fi

echo "Create CosmosDB NoSQL Account"
export AZURECOSMOSDB_ENDPOINT=$(azlocal cosmosdb create \
export AZURECOSMOSDB_ENDPOINT=$(az cosmosdb create \
--resource-group $RESOURCE_GROUP_NAME \
--name $WEB_APP_NAME \
--locations regionName=$LOCATION \
Expand All @@ -59,13 +59,13 @@ echo "Account created"
echo "AZURECOSMOSDB_ENDPOINT set to $AZURECOSMOSDB_ENDPOINT"

echo "Create CosmosDB NoSQL Database"
azlocal cosmosdb sql database create \
az cosmosdb sql database create \
--resource-group $RESOURCE_GROUP_NAME \
--name $AZURECOSMOSDB_DATABASENAME \
--account-name $WEB_APP_NAME

echo "Create CosmosDB NoSQL Container"
azlocal cosmosdb sql container create \
az cosmosdb sql container create \
--resource-group $RESOURCE_GROUP_NAME \
--account-name $WEB_APP_NAME \
--database-name $AZURECOSMOSDB_DATABASENAME \
Expand All @@ -74,23 +74,23 @@ azlocal cosmosdb sql container create \
--throughput 400

echo "Fetching DB Account primary master key"
export AZURECOSMOSDB_PRIMARY_KEY=$(azlocal cosmosdb keys list \
export AZURECOSMOSDB_PRIMARY_KEY=$(az cosmosdb keys list \
--resource-group $RESOURCE_GROUP_NAME \
--name $WEB_APP_NAME \
--query "primaryMasterKey" \
--output tsv)
echo "Primary master key is $AZURECOSMOSDB_PRIMARY_KEY"

echo "Creating App service"
azlocal appservice plan create --name $WEB_APP_NAME --resource-group $RESOURCE_GROUP_NAME --sku B1 --is-linux
az appservice plan create --name $WEB_APP_NAME --resource-group $RESOURCE_GROUP_NAME --sku B1 --is-linux
echo "App service created"

echo "Creating Web App"
azlocal webapp create --name $WEB_APP_NAME --resource-group $RESOURCE_GROUP_NAME --plan $WEB_APP_NAME --runtime PYTHON:3.13
az webapp create --name $WEB_APP_NAME --resource-group $RESOURCE_GROUP_NAME --plan $WEB_APP_NAME --runtime PYTHON:3.13
echo "Web App created"

echo "Configure appsettings environment variables"
azlocal webapp config appsettings set \
az webapp config appsettings set \
--resource-group $RESOURCE_GROUP_NAME \
--name $WEB_APP_NAME \
--settings AZURECOSMOSDB_ENDPOINT=$AZURECOSMOSDB_ENDPOINT \
Expand All @@ -100,7 +100,7 @@ azlocal webapp config appsettings set \

# Print the application settings of the web app
echo "Retrieving application settings for web app [$WEB_APP_NAME]..."
azlocal webapp config appsettings list \
az webapp config appsettings list \
--resource-group $RESOURCE_GROUP_NAME \
--name $WEB_APP_NAME

Expand All @@ -118,8 +118,7 @@ zip -r "$ZIPFILE" app.py cosmosdb_client.py static templates requirements.txt

# Deploy the web app
echo "Deploying web app [$WEB_APP_NAME] with zip file [$ZIPFILE]..."
echo "Using azlocal webapp deploy command for LocalStack emulator environment."
azlocal webapp deploy \
az webapp deploy \
--resource-group $RESOURCE_GROUP_NAME \
--name $WEB_APP_NAME \
--src-path ${ZIPFILE} \
Expand Down
Loading