Skip to content

Commit 6856912

Browse files
committed
remove start-interception from front door sample app
1 parent d2662f4 commit 6856912

3 files changed

Lines changed: 17 additions & 143 deletions

File tree

run-samples.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fi
3030
# 1. Define Samples (placed before tool checks so --list works without dependencies)
3131
SAMPLES=(
3232
"samples/servicebus/java|bash scripts/deploy.sh"
33-
"samples/function-app-front-door/python|bash scripts/deploy_all.sh --name-prefix testafd --use-localstack|"
33+
"samples/function-app-front-door/python|bash scripts/deploy_all.sh --name-prefix testafd|"
3434
"samples/function-app-managed-identity/python|bash scripts/user-managed-identity.sh|bash scripts/validate.sh && bash scripts/test.sh"
3535
"samples/function-app-service-bus/dotnet|bash scripts/deploy.sh|bash scripts/validate.sh && bash scripts/call-http-trigger.sh"
3636
"samples/function-app-storage-http/dotnet|bash scripts/deploy.sh|bash scripts/validate.sh && bash scripts/call-http-triggers.sh"

samples/function-app-front-door/python/scripts/cleanup_all.sh

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,23 @@ set -euo pipefail
88
#
99
# Usage examples:
1010
# # Using the env file written by deploy_all.sh
11-
# bash ./scripts/cleanup_all.sh --env-file ./scripts/.last_deploy_all.env --use-localstack
11+
# bash ./scripts/cleanup_all.sh --env-file ./scripts/.last_deploy_all.env
1212
#
13-
# # Passing the RG directly (works for Azure or LocalStack)
13+
# # Passing the RG directly
1414
# bash ./scripts/cleanup_all.sh --resource-group rg-funcafdall-12345
1515
#
1616
# Requirements: az CLI
17-
# Optional: azlocal (LocalStack Azure CLI helper) when cleaning emulator resources
1817

1918
RESOURCE_GROUP=""
2019
ENV_FILE=""
21-
USE_LOCALSTACK="false"
2220

2321
print_usage() {
2422
cat <<EOF
25-
Usage: $(basename "$0") [--env-file PATH] [--resource-group NAME] [--use-localstack]
23+
Usage: $(basename "$0") [--env-file PATH] [--resource-group NAME]
2624
2725
Options:
2826
--env-file PATH Env file produced by deploy_all.sh (e.g., scripts/.last_deploy_all.env)
2927
-g, --resource-group Resource group name to delete
30-
--use-localstack Use azlocal interception to target LocalStack emulator
3128
-h, --help Show this help
3229
EOF
3330
}
@@ -37,7 +34,6 @@ while [[ $# -gt 0 ]]; do
3734
case "$1" in
3835
--env-file) ENV_FILE=${2:-}; shift 2;;
3936
-g|--resource-group) RESOURCE_GROUP=${2:-}; shift 2;;
40-
--use-localstack) USE_LOCALSTACK="true"; shift;;
4137
-h|--help) print_usage; exit 0;;
4238
*) echo "Unknown option: $1" >&2; print_usage; exit 1;;
4339
esac
@@ -56,33 +52,5 @@ if [[ -z "$RESOURCE_GROUP" ]]; then
5652
exit 1
5753
fi
5854

59-
INTERCEPTION_STARTED="false"
60-
AZURE_CONFIG_DIR_CREATED="false"
61-
finish() {
62-
if [[ "$INTERCEPTION_STARTED" == "true" ]] && command -v azlocal >/dev/null 2>&1; then
63-
set +e; azlocal stop-interception >/dev/null 2>&1 || true; set -e
64-
fi
65-
if [[ "$AZURE_CONFIG_DIR_CREATED" == "true" && -n "${AZURE_CONFIG_DIR:-}" && -d "$AZURE_CONFIG_DIR" ]]; then
66-
rm -rf "$AZURE_CONFIG_DIR"
67-
fi
68-
}
69-
trap finish EXIT
70-
71-
if [[ "$USE_LOCALSTACK" == "true" ]]; then
72-
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
73-
export AZURE_CONFIG_DIR="$AZ_TEMP_CONFIG_DIR"; AZURE_CONFIG_DIR_CREATED="true"
74-
echo "Using isolated AZURE_CONFIG_DIR at: $AZURE_CONFIG_DIR"
75-
if ! command -v azlocal >/dev/null 2>&1; then
76-
echo "Error: --use-localstack specified but 'azlocal' was not found in PATH." >&2
77-
exit 1
78-
fi
79-
if azlocal start-interception; then
80-
INTERCEPTION_STARTED="true"; echo "LocalStack interception started."
81-
else
82-
echo "Error: azlocal failed to start interception. Ensure LocalStack is running and azlocal is configured correctly." >&2
83-
exit 1
84-
fi
85-
fi
86-
8755
az group delete -n "$RESOURCE_GROUP" --yes --no-wait
8856
echo "Delete requested for resource group '$RESOURCE_GROUP'."

samples/function-app-front-door/python/scripts/deploy_all.sh

Lines changed: 13 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,24 @@ set -euo pipefail
1010
# 4) Rules Engine demo via Rule Set + Rule (ep-rules)
1111
# 5) Endpoint enabled/disabled state toggle (ep-state)
1212
#
13-
# It supports deploying to real Azure or to LocalStack’s Azure emulator via azlocal interception.
1413
# By default, all scenarios are deployed. You can selectively skip scenarios via flags.
1514
#
1615
# Requirements
1716
# - az CLI
1817
# - bash, zip
19-
# - Optional for LocalStack mode: azlocal (CLI interceptor), funclocal + Azure Functions Core Tools ('func')
18+
# - Optional: Azure Functions Core Tools (func)
2019
#
2120
# Examples
2221
# # Real Azure (eastus by default)
2322
# bash ./scripts/deploy_all.sh --name-prefix demo
2423
#
25-
# # LocalStack emulator
26-
# bash ./scripts/deploy_all.sh --name-prefix demo --use-localstack
27-
#
2824

2925
# -------------------------------
3026
# Defaults (overridable via flags)
3127
# -------------------------------
3228
NAME_PREFIX="funcafdall"
3329
LOCATION="eastus"
3430
RESOURCE_GROUP=""
35-
USE_LOCALSTACK="false"
3631
PYTHON_VERSION="3.11"
3732

3833
# Scenario toggles
@@ -51,7 +46,6 @@ Options:
5146
-l, --location STR Azure region (default: eastus)
5247
-g, --resource-group STR Resource group name (auto-generated if omitted)
5348
--python-version STR Python runtime for Function App(s) (default: 3.11)
54-
--use-localstack Use azlocal/funclocal for LocalStack emulator
5549
5650
# Scenario toggles (all enabled by default)
5751
--no-basic Skip basic single-origin scenario
@@ -70,7 +64,6 @@ while [[ $# -gt 0 ]]; do
7064
-l|--location) LOCATION=${2:-}; shift 2;;
7165
-g|--resource-group) RESOURCE_GROUP=${2:-}; shift 2;;
7266
--python-version) PYTHON_VERSION=${2:-}; shift 2;;
73-
--use-localstack) USE_LOCALSTACK="true"; shift;;
7467
--no-basic) DO_BASIC="false"; shift;;
7568
--no-multi) DO_MULTI="false"; shift;;
7669
--no-spec) DO_SPEC="false"; shift;;
@@ -145,45 +138,17 @@ ruleSetName="rs${prefix}${suffix}"
145138
ruleName="ruleAddHeader"
146139

147140
# -------------------------------
148-
# LocalStack interception lifecycle (optional)
141+
# Cleanup on exit
149142
# -------------------------------
150-
INTERCEPTION_STARTED="false"
151-
AZURE_CONFIG_DIR_CREATED="false"
152143
finish() {
153144
set +e
154145
[[ -f "$ZIP_MAIN" ]] && rm -f "$ZIP_MAIN"
155146
[[ -f "$ZIP_A" ]] && rm -f "$ZIP_A"
156147
[[ -f "$ZIP_B" ]] && rm -f "$ZIP_B"
157-
if [[ "$INTERCEPTION_STARTED" == "true" ]] && command -v azlocal >/dev/null 2>&1; then
158-
azlocal stop-interception >/dev/null 2>&1 || true
159-
fi
160-
if [[ "$AZURE_CONFIG_DIR_CREATED" == "true" && -n "${AZURE_CONFIG_DIR:-}" && -d "$AZURE_CONFIG_DIR" ]]; then
161-
rm -rf "$AZURE_CONFIG_DIR"
162-
fi
163148
set -e
164149
}
165150
trap finish EXIT
166151

167-
if [[ "$USE_LOCALSTACK" == "true" ]]; then
168-
if command -v mktemp >/dev/null 2>&1; then
169-
AZ_TEMP_CONFIG_DIR="$(mktemp -d)"
170-
else
171-
AZ_TEMP_CONFIG_DIR="$ROOT_DIR/.azlocal_config_$$"; mkdir -p "$AZ_TEMP_CONFIG_DIR"
172-
fi
173-
export AZURE_CONFIG_DIR="$AZ_TEMP_CONFIG_DIR"; AZURE_CONFIG_DIR_CREATED="true"
174-
echo "Using isolated AZURE_CONFIG_DIR: $AZURE_CONFIG_DIR"
175-
if ! command -v azlocal >/dev/null 2>&1; then
176-
echo "Error: --use-localstack specified but 'azlocal' not found in PATH." >&2
177-
exit 1
178-
fi
179-
if azlocal start-interception; then
180-
INTERCEPTION_STARTED="true"; echo "LocalStack interception started."
181-
else
182-
echo "Error: azlocal failed to start interception. Ensure LocalStack is running." >&2
183-
exit 1
184-
fi
185-
fi
186-
187152
echo "Resource Group: $RESOURCE_GROUP"
188153

189154
# -------------------------------
@@ -202,38 +167,14 @@ create_function_app() {
202167
--runtime python --runtime-version "$PYTHON_VERSION" \
203168
--functions-version 4 --os-type Linux \
204169
--storage-account "$storageName" --disable-app-insights -o none
205-
if [[ "$USE_LOCALSTACK" != "true" ]]; then
206-
az functionapp config appsettings set -g "$RESOURCE_GROUP" -n "$funcName" \
207-
--settings WEBSITE_RUN_FROM_PACKAGE=1 FUNCTIONS_WORKER_RUNTIME=python SCM_DO_BUILD_DURING_DEPLOYMENT=false -o none
208-
else
209-
az functionapp config appsettings set -g "$RESOURCE_GROUP" -n "$funcName" \
210-
--settings FUNCTIONS_WORKER_RUNTIME=python WEBSITE_RUN_FROM_PACKAGE=0 -o none
211-
local STORAGE_KEY
212-
STORAGE_KEY=$(az storage account keys list -g "$RESOURCE_GROUP" -n "$storageName" --query "[0].value" -o tsv)
213-
if [[ -z "$STORAGE_KEY" ]]; then echo "Failed to get storage key for $storageName" >&2; exit 1; fi
214-
local STORAGE_CONNECTION_STRING
215-
STORAGE_CONNECTION_STRING="DefaultEndpointsProtocol=http;AccountName=$storageName;AccountKey=$STORAGE_KEY;BlobEndpoint=http://$storageName.blob.localhost.localstack.cloud:4566;QueueEndpoint=http://$storageName.queue.localhost.localstack.cloud:4566;TableEndpoint=http://$storageName.table.localhost.localstack.cloud:4566;FileEndpoint=http://$storageName.file.localhost.localstack.cloud:4566"
216-
az functionapp config appsettings set -g "$RESOURCE_GROUP" -n "$funcName" \
217-
--settings AzureWebJobsStorage="$STORAGE_CONNECTION_STRING" WEBSITE_CONTENTAZUREFILECONNECTIONSTRING="$STORAGE_CONNECTION_STRING" SCM_RUN_FROM_PACKAGE= -o none
218-
fi
170+
az functionapp config appsettings set -g "$RESOURCE_GROUP" -n "$funcName" \
171+
--settings WEBSITE_RUN_FROM_PACKAGE=1 FUNCTIONS_WORKER_RUNTIME=python SCM_DO_BUILD_DURING_DEPLOYMENT=false -o none
219172
}
220173

221174
publish_function_code() {
222175
local funcName="$1"; local zipPath="$2"
223-
if [[ "$USE_LOCALSTACK" == "true" ]]; then
224-
if ! command -v funclocal >/dev/null 2>&1; then
225-
echo "Error: funclocal is required in --use-localstack mode." >&2; exit 1
226-
fi
227-
if ! command -v func >/dev/null 2>&1; then
228-
echo "Error: Azure Functions Core Tools ('func') not found in PATH." >&2; exit 1
229-
fi
230-
pushd "$FUNCTION_SRC" >/dev/null
231-
funclocal azure functionapp publish "$funcName" --python --build local #--verbose --debug
232-
popd >/dev/null
233-
else
234-
rm -f "$zipPath"; ( cd "$FUNCTION_SRC" && zip -rq "$zipPath" . )
235-
az functionapp deployment source config-zip -g "$RESOURCE_GROUP" -n "$funcName" --src "$zipPath"
236-
fi
176+
rm -f "$zipPath"; ( cd "$FUNCTION_SRC" && zip -rq "$zipPath" . )
177+
az functionapp deployment source config-zip -g "$RESOURCE_GROUP" -n "$funcName" --src "$zipPath"
237178
}
238179

239180
if [[ "$DO_BASIC" == "true" || "$DO_SPEC" == "true" || "$DO_RULES" == "true" || "$DO_STATE" == "true" ]]; then
@@ -413,18 +354,6 @@ hostBasic=""; hostMulti=""; hostSpec=""; hostRules=""; hostState=""
413354
[[ "$DO_RULES" == "true" ]] && hostRules=$(resolve_ep_host "$epRules")
414355
[[ "$DO_STATE" == "true" ]] && hostState=$(resolve_ep_host "$epState")
415356

416-
# Local addresses for emulator
417-
if [[ "$USE_LOCALSTACK" == "true" ]]; then
418-
funcMainLocal="${funcMain}website.localhost.localstack.cloud:4566"
419-
funcALocal="${funcA}website.localhost.localstack.cloud:4566"
420-
funcBLocal="${funcB}website.localhost.localstack.cloud:4566"
421-
epBasicLocal="${epBasic}.afd.localhost.localstack.cloud:4566"
422-
epMultiLocal="${epMulti}.afd.localhost.localstack.cloud:4566"
423-
epSpecLocal="${epSpec}.afd.localhost.localstack.cloud:4566"
424-
epRulesLocal="${epRules}.afd.localhost.localstack.cloud:4566"
425-
epStateLocal="${epState}.afd.localhost.localstack.cloud:4566"
426-
fi
427-
428357
# -------------------------------
429358
# Persist environment for cleanup
430359
# -------------------------------
@@ -449,44 +378,21 @@ echo
449378
echo "Deployment complete."
450379
echo "Resource Group: $RESOURCE_GROUP"
451380
if [[ "$DO_BASIC" == "true" ]]; then
452-
if [[ "$USE_LOCALSTACK" == "true" ]]; then
453-
echo "[Basic] AFD Local Endpoint: https://$epBasicLocal/john"
454-
else
455-
echo "[Basic] AFD Endpoint: https://$hostBasic/john"
456-
fi
381+
echo "[Basic] AFD Endpoint: https://$hostBasic/john"
457382
fi
458383
if [[ "$DO_MULTI" == "true" ]]; then
459-
if [[ "$USE_LOCALSTACK" == "true" ]]; then
460-
echo "[Multi] AFD Local Endpoint: https://$epMultiLocal/john"
461-
echo " You can inspect responses to see which origin served them (function echoes WEBSITE_HOSTNAME)."
462-
else
463-
echo "[Multi] AFD Endpoint: https://$hostMulti/john"
464-
fi
384+
echo "[Multi] AFD Endpoint: https://$hostMulti/john"
465385
fi
466386
if [[ "$DO_SPEC" == "true" ]]; then
467-
if [[ "$USE_LOCALSTACK" == "true" ]]; then
468-
echo "[Spec] AFD Local Endpoint: https://$epSpecLocal/john (specific route)"
469-
echo " Also try: https://$epSpecLocal/jane (catch-all)"
470-
else
471-
echo "[Spec] AFD Endpoint: https://$hostSpec/john (specific route)"
472-
echo " Also try: https://$hostSpec/jane (catch-all)"
473-
fi
387+
echo "[Spec] AFD Endpoint: https://$hostSpec/john (specific route)"
388+
echo " Also try: https://$hostSpec/jane (catch-all)"
474389
fi
475390
if [[ "$DO_RULES" == "true" ]]; then
476-
if [[ "$USE_LOCALSTACK" == "true" ]]; then
477-
echo "[Rules] AFD Local Endpoint: https://$epRulesLocal/john"
478-
echo " Expect response header: X-CDN: MSFT (if rules are supported)."
479-
else
480-
echo "[Rules] AFD Endpoint: https://$hostRules/john"
481-
echo " Expect response header: X-CDN: MSFT (once propagation completes)."
482-
fi
391+
echo "[Rules] AFD Endpoint: https://$hostRules/john"
392+
echo " Expect response header: X-CDN: MSFT (once propagation completes)."
483393
fi
484394
if [[ "$DO_STATE" == "true" ]]; then
485-
if [[ "$USE_LOCALSTACK" == "true" ]]; then
486-
echo "[State] AFD Local Endpoint: https://$epStateLocal/john"
487-
else
488-
echo "[State] AFD Endpoint: https://$hostState/john"
489-
fi
395+
echo "[State] AFD Endpoint: https://$hostState/john"
490396
echo " To test enabled-state toggle:"
491397
echo " az afd endpoint update -g $RESOURCE_GROUP --profile-name $profileName --endpoint-name $epState --enabled-state Disabled"
492398
echo " # Then re-enable:"

0 commit comments

Comments
 (0)