Skip to content

Commit 08009bb

Browse files
Read the app's port from its container in the web and function app call scripts (#127)
* Read the app's port from its container in the call scripts, and take PREFIX and SUFFIX from the environment The call scripts looked up the host port mapped to container port 80 and called the container IP on port 80 (or on a hard-coded 8000). The emulator serves an app on the port its WEBSITES_PORT app setting names, 8000 in several samples, so the host-port and container-IP calls of web-app-cosmosdb-mongodb-api/python failed, and every other script was one setting change away from the same failure. The scripts now read the port the app's container publishes, and the READMEs no longer tell readers to look for port 80. The deploy, call and validate scripts take PREFIX and SUFFIX from the environment, defaulting to local and test as before, so several deployments of the same sample can run side by side on one emulator and a redeployment does not run into the soft-deleted Key Vault of the previous one. The function-app-storage-http Bicep deployment now passes them to its template and names its resource group with the prefix. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JPjRV37o1e5vjqHHqtMLQm * Take the app name as an input in the call scripts instead of calling the first app listed The call scripts looked up the first web app or function app the Azure CLI listed, so with several deployments on one emulator (which taking PREFIX and SUFFIX from the environment allows) they could read the port from and call another deployment's app. A call script now takes the app name as its first argument, or from WEB_APP_NAME or FUNCTION_APP_NAME, and reads the resource group from that app. Without a name it calls the only app in the subscription, and stops with a message asking for the name when there are several. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JPjRV37o1e5vjqHHqtMLQm * Remove the stopped emulator container before starting a new one in the samples workflow localstack stop does not wait for Docker to remove the container, so the start that followed failed with 'container named "localstack-main" already exists', and the retry of a failed sample never ran. The readiness loop and the retry step now remove the container and wait until it is gone before they start the emulator again. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JPjRV37o1e5vjqHHqtMLQm * Serve HTTPS on port 8443 in the SQL Database web app after every deployment method call-web-app.sh checks the certificate the web app serves on port 8443, and it failed in two cases. The Bicep deployments set no CERT_NAME, created no certificate and gave the web app no certificate permission on the Key Vault, so the app never served HTTPS. main.bicep now sets CERT_NAME and grants certificates/get, and deploy.sh creates the certificate in the Key Vault after the deployment and before the code is deployed (Bicep cannot create a Key Vault certificate). The Python app started its HTTPS listener only when run as `python app.py`, never under gunicorn, which is how App Service runs it. gunicorn.conf.py now starts that listener once in the gunicorn master when KEYVAULT_URI and CERT_NAME are set. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JPjRV37o1e5vjqHHqtMLQm * Document the certificate the SQL Database Bicep deployment creates Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JPjRV37o1e5vjqHHqtMLQm --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 432437e commit 08009bb

114 files changed

Lines changed: 1158 additions & 331 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/run-samples.yml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ jobs:
216216
echo "::warning::Emulator was not ready within 400s (attempt ${attempt}/${attempts})."
217217
docker logs localstack-main --tail 100 2>&1 || true
218218
python -m localstack_cli.cli.main stop || true
219+
# stop does not wait for Docker to remove the container, and a start that still finds it fails with
220+
# 'container named "localstack-main" already exists'.
221+
docker rm -f localstack-main >/dev/null 2>&1 || true
222+
for _ in $(seq 1 30); do docker container inspect localstack-main >/dev/null 2>&1 || break; sleep 1; done
219223
done
220224
echo "::error::Emulator failed to become ready after ${attempts} attempts."
221225
exit 1
@@ -307,6 +311,10 @@ jobs:
307311
source .venv/bin/activate
308312
echo "::warning::${MATRIX_NAME} failed once; retrying on a fresh emulator."
309313
python -m localstack_cli.cli.main stop || true
314+
# stop does not wait for Docker to remove the container, and a start that still finds it fails with
315+
# 'container named "localstack-main" already exists'.
316+
docker rm -f localstack-main >/dev/null 2>&1 || true
317+
for _ in $(seq 1 30); do docker container inspect localstack-main >/dev/null 2>&1 || break; sleep 1; done
310318
python -m localstack_cli.cli.main start -d
311319
python -m localstack_cli.cli.main wait -t 600
312320
make test SHARD="${SHARD}" SPLITS="${SPLITS}"

‎samples/function-app-front-door/python/scripts/call-front-door.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/bash
22

33
# Variables
4-
PREFIX='local'
5-
SUFFIX='test'
4+
PREFIX="${PREFIX:-local}"
5+
SUFFIX="${SUFFIX:-test}"
66
RESOURCE_GROUP_NAME="${PREFIX}-rg"
77
PROFILE_NAME="${PREFIX}-catalog-afd-${SUFFIX}"
88
ENDPOINT_NAME="${PREFIX}-catalog-${SUFFIX}"

‎samples/function-app-front-door/python/scripts/cleanup.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# accounts and the shared App Service plan are all inside it.
99
# =============================================================================
1010

11-
PREFIX='local'
11+
PREFIX="${PREFIX:-local}"
1212
RESOURCE_GROUP_NAME="${PREFIX}-rg"
1313
CURRENT_DIR="$(cd "$(dirname "$0")" && pwd)"
1414

‎samples/function-app-front-door/python/scripts/deploy.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/bash
22

33
# Variables
4-
PREFIX='local'
5-
SUFFIX='test'
4+
PREFIX="${PREFIX:-local}"
5+
SUFFIX="${SUFFIX:-test}"
66
LOCATION='westeurope'
77
RESOURCE_GROUP_NAME="${PREFIX}-rg"
88
APP_SERVICE_PLAN_NAME="${PREFIX}-catalog-app-service-plan-${SUFFIX}"

‎samples/function-app-front-door/python/scripts/validate.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/bash
22

33
# Variables
4-
PREFIX='local'
5-
SUFFIX='test'
4+
PREFIX="${PREFIX:-local}"
5+
SUFFIX="${SUFFIX:-test}"
66
RESOURCE_GROUP_NAME="${PREFIX}-rg"
77
PRIMARY_FUNCTION_APP_NAME="${PREFIX}-catalog-primary-${SUFFIX}"
88
SECONDARY_FUNCTION_APP_NAME="${PREFIX}-catalog-secondary-${SUFFIX}"

‎samples/function-app-managed-identity/python/bicep/deploy.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/bash
22

33
# Variables
4-
PREFIX='local'
5-
SUFFIX='test'
4+
PREFIX="${PREFIX:-local}"
5+
SUFFIX="${SUFFIX:-test}"
66
TEMPLATE="main.bicep"
77
PARAMETERS="main.bicepparam"
88
RESOURCE_GROUP_NAME="$PREFIX-rg"

‎samples/function-app-managed-identity/python/scripts/system-managed-identity.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/bash
22

33
# Variables
4-
PREFIX='local'
5-
SUFFIX='test'
4+
PREFIX="${PREFIX:-local}"
5+
SUFFIX="${SUFFIX:-test}"
66
LOCATION='westeurope'
77
STORAGE_ACCOUNT_NAME="${PREFIX}storage${SUFFIX}"
88
FUNCTION_APP_NAME="${PREFIX}-functionapp-${SUFFIX}"

‎samples/function-app-managed-identity/python/scripts/test.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/bash
22

33
# Variables
4-
PREFIX='local'
5-
SUFFIX='test'
4+
PREFIX="${PREFIX:-local}"
5+
SUFFIX="${SUFFIX:-test}"
66
FILE_PATH="input.txt"
77
INPUT_CONTAINER_NAME="input"
88
OUTPUT_CONTAINER_NAME="output"

‎samples/function-app-managed-identity/python/scripts/user-managed-identity.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/bash
22

33
# Variables
4-
PREFIX='local'
5-
SUFFIX='test'
4+
PREFIX="${PREFIX:-local}"
5+
SUFFIX="${SUFFIX:-test}"
66
LOCATION='northeurope'
77
STORAGE_ACCOUNT_NAME="${PREFIX}storage${SUFFIX}"
88
MANAGED_IDENTITY_NAME="${PREFIX}-identity-${SUFFIX}"

‎samples/function-app-managed-identity/python/scripts/validate.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/bash
22

33
# Variables
4-
PREFIX='local'
5-
SUFFIX='test'
4+
PREFIX="${PREFIX:-local}"
5+
SUFFIX="${SUFFIX:-test}"
66
RESOURCE_GROUP_NAME="${PREFIX}-rg"
77
STORAGE_ACCOUNT_NAME="${PREFIX}storage${SUFFIX}"
88
INPUT_STORAGE_CONTAINER_NAME='input'

0 commit comments

Comments
 (0)