Skip to content

Commit a349ba5

Browse files
authored
Merge branch 'main' into aci-terraform-kv-addition
2 parents 8f93136 + 834326f commit a349ba5

File tree

21 files changed

+199
-298
lines changed

21 files changed

+199
-298
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ This repository contains comprehensive sample projects demonstrating how to deve
3535
| [Web App and Managed Identities](./samples/web-app-managed-identity/python/README.md) | Azure Web App using Managed Identities |
3636
| [Web App and SQL Database ](./samples/web-app-sql-database/python/README.md) | Azure Web App using SQL Database |
3737
| [ACI and Blob Storage](./samples/aci-blob-storage/python/README.md) | Azure Container Instances with ACR, Key Vault, and Blob Storage |
38-
| [Azure Service Bus with Spring Boot](./samples/servicebus/README.md) | Azure Service Bus used by a Spring Boot application |
38+
| [Azure Service Bus with Spring Boot](./samples/servicebus/java/README.md) | Azure Service Bus used by a Spring Boot application |
3939

4040
## Sample Structure
4141

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/aci-blob-storage/python/scripts/cleanup.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@ KEY_VAULT_NAME="${PREFIX}acikv"
1616
ACR_NAME="${PREFIX}aciacr"
1717
STORAGE_ACCOUNT_NAME="${PREFIX}acistorage"
1818

19-
# Choose the appropriate CLI based on the environment
20-
if [[ $ENVIRONMENT == "LocalStack" ]]; then
21-
AZ="azlocal"
22-
else
23-
AZ="az"
24-
fi
25-
2619
echo "============================================================"
2720
echo "Cleaning up ACI Vacation Planner Resources"
2821
echo "============================================================"

samples/aci-blob-storage/python/scripts/validate.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@ ACI_GROUP_NAME="${PREFIX}-aci-planner"
1919
PASS_COUNT=0
2020
FAIL_COUNT=0
2121

22-
# Choose the appropriate CLI based on the environment
23-
if [[ $ENVIRONMENT == "LocalStack" ]]; then
24-
AZ="azlocal"
25-
else
26-
AZ="az"
27-
fi
28-
2922
check() {
3023
local description="$1"
3124
local command="$2"

samples/aci-blob-storage/python/terraform/deploy.sh

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,6 @@ CURRENT_DIR="$(cd "$(dirname "$0")" && pwd)"
1111
# Change the current directory to the script's directory
1212
cd "$CURRENT_DIR" || exit
1313

14-
# Choose the appropriate CLI based on the environment
15-
if [[ $ENVIRONMENT == "LocalStack" ]]; then
16-
echo "Using azlocal for LocalStack emulator environment."
17-
AZ="azlocal"
18-
else
19-
echo "Using standard terraform and az for AzureCloud environment."
20-
AZ="az"
21-
fi
22-
2314
# =============================================================================
2415
# Build and push the Docker image before Terraform deployment
2516
# (Terraform references the pre-created ACR as a data source)

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: 25 additions & 96 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), 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 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,35 +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 func >/dev/null 2>&1; then
225-
echo "Error: Azure Functions Core Tools ('func') not found in PATH." >&2; exit 1
226-
fi
227-
pushd "$FUNCTION_SRC" >/dev/null
228-
func azure functionapp publish "$funcName" --python --build local #--verbose --debug
229-
popd >/dev/null
230-
else
231-
rm -f "$zipPath"; ( cd "$FUNCTION_SRC" && zip -rq "$zipPath" . )
232-
az functionapp deployment source config-zip -g "$RESOURCE_GROUP" -n "$funcName" --src "$zipPath"
233-
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"
234178
}
235179

236180
if [[ "$DO_BASIC" == "true" || "$DO_SPEC" == "true" || "$DO_RULES" == "true" || "$DO_STATE" == "true" ]]; then
@@ -410,11 +354,11 @@ hostBasic=""; hostMulti=""; hostSpec=""; hostRules=""; hostState=""
410354
[[ "$DO_RULES" == "true" ]] && hostRules=$(resolve_ep_host "$epRules")
411355
[[ "$DO_STATE" == "true" ]] && hostState=$(resolve_ep_host "$epState")
412356

413-
# Local addresses for emulator
414-
if [[ "$USE_LOCALSTACK" == "true" ]]; then
415-
funcMainLocal="${funcMain}website.localhost.localstack.cloud:4566"
416-
funcALocal="${funcA}website.localhost.localstack.cloud:4566"
417-
funcBLocal="${funcB}website.localhost.localstack.cloud:4566"
357+
# Detect LocalStack environment for local URLs
358+
IS_LOCALSTACK="false"
359+
ENVIRONMENT=$(az account show --query environmentName --output tsv 2>/dev/null || true)
360+
if [[ "$ENVIRONMENT" == "LocalStack" ]]; then
361+
IS_LOCALSTACK="true"
418362
epBasicLocal="${epBasic}.afd.localhost.localstack.cloud:4566"
419363
epMultiLocal="${epMulti}.afd.localhost.localstack.cloud:4566"
420364
epSpecLocal="${epSpec}.afd.localhost.localstack.cloud:4566"
@@ -446,44 +390,29 @@ echo
446390
echo "Deployment complete."
447391
echo "Resource Group: $RESOURCE_GROUP"
448392
if [[ "$DO_BASIC" == "true" ]]; then
449-
if [[ "$USE_LOCALSTACK" == "true" ]]; then
450-
echo "[Basic] AFD Local Endpoint: https://$epBasicLocal/john"
451-
else
452-
echo "[Basic] AFD Endpoint: https://$hostBasic/john"
453-
fi
393+
echo "[Basic] AFD Endpoint: https://$hostBasic/john"
394+
[[ "$IS_LOCALSTACK" == "true" ]] && echo " Local Endpoint: http://$epBasicLocal/john"
454395
fi
455396
if [[ "$DO_MULTI" == "true" ]]; then
456-
if [[ "$USE_LOCALSTACK" == "true" ]]; then
457-
echo "[Multi] AFD Local Endpoint: https://$epMultiLocal/john"
458-
echo " You can inspect responses to see which origin served them (function echoes WEBSITE_HOSTNAME)."
459-
else
460-
echo "[Multi] AFD Endpoint: https://$hostMulti/john"
461-
fi
397+
echo "[Multi] AFD Endpoint: https://$hostMulti/john"
398+
[[ "$IS_LOCALSTACK" == "true" ]] && echo " Local Endpoint: http://$epMultiLocal/john"
462399
fi
463400
if [[ "$DO_SPEC" == "true" ]]; then
464-
if [[ "$USE_LOCALSTACK" == "true" ]]; then
465-
echo "[Spec] AFD Local Endpoint: https://$epSpecLocal/john (specific route)"
466-
echo " Also try: https://$epSpecLocal/jane (catch-all)"
467-
else
468-
echo "[Spec] AFD Endpoint: https://$hostSpec/john (specific route)"
469-
echo " Also try: https://$hostSpec/jane (catch-all)"
401+
echo "[Spec] AFD Endpoint: https://$hostSpec/john (specific route)"
402+
echo " Also try: https://$hostSpec/jane (catch-all)"
403+
if [[ "$IS_LOCALSTACK" == "true" ]]; then
404+
echo " Local Endpoint: http://$epSpecLocal/john (specific route)"
405+
echo " Also try: http://$epSpecLocal/jane (catch-all)"
470406
fi
471407
fi
472408
if [[ "$DO_RULES" == "true" ]]; then
473-
if [[ "$USE_LOCALSTACK" == "true" ]]; then
474-
echo "[Rules] AFD Local Endpoint: https://$epRulesLocal/john"
475-
echo " Expect response header: X-CDN: MSFT (if rules are supported)."
476-
else
477-
echo "[Rules] AFD Endpoint: https://$hostRules/john"
478-
echo " Expect response header: X-CDN: MSFT (once propagation completes)."
479-
fi
409+
echo "[Rules] AFD Endpoint: https://$hostRules/john"
410+
echo " Expect response header: X-CDN: MSFT (once propagation completes)."
411+
[[ "$IS_LOCALSTACK" == "true" ]] && echo " Local Endpoint: http://$epRulesLocal/john"
480412
fi
481413
if [[ "$DO_STATE" == "true" ]]; then
482-
if [[ "$USE_LOCALSTACK" == "true" ]]; then
483-
echo "[State] AFD Local Endpoint: https://$epStateLocal/john"
484-
else
485-
echo "[State] AFD Endpoint: https://$hostState/john"
486-
fi
414+
echo "[State] AFD Endpoint: https://$hostState/john"
415+
[[ "$IS_LOCALSTACK" == "true" ]] && echo " Local Endpoint: http://$epStateLocal/john"
487416
echo " To test enabled-state toggle:"
488417
echo " az afd endpoint update -g $RESOURCE_GROUP --profile-name $profileName --endpoint-name $epState --enabled-state Disabled"
489418
echo " # Then re-enable:"
48.3 KB
Loading
-172 Bytes
Binary file not shown.

samples/web-app-cosmosdb-nosql-api/python/scripts/...

Whitespace-only changes.

0 commit comments

Comments
 (0)