From a2d669c519a69382062ff2dc93a627fb9b8a9f10 Mon Sep 17 00:00:00 2001 From: Paolo Salvatori Date: Wed, 8 Apr 2026 15:06:16 +0200 Subject: [PATCH 1/9] Added azlocal start-interception to all README files --- docs/LOCALSTACK.md | 9 ++++++++- samples/aci-blob-storage/python/README.md | 7 +++---- .../function-app-front-door/python/README.md | 18 ++++++++++++++++-- .../python/README.md | 9 ++++++++- .../python/bicep/README.md | 9 ++++++++- .../python/scripts/README.md | 9 ++++++++- .../python/terraform/README.md | 9 ++++++++- .../function-app-service-bus/dotnet/README.md | 11 +++++++++-- .../dotnet/bicep/README.md | 9 ++++++++- .../dotnet/scripts/README.md | 9 ++++++++- .../dotnet/terraform/README.md | 9 ++++++++- .../dotnet/terraform/README.md | 9 ++++++++- samples/servicebus/java/README.md | 9 ++++++++- samples/servicebus/java/bicep/README.md | 9 ++++++++- samples/servicebus/java/scripts/README.md | 9 ++++++++- samples/servicebus/java/terraform/README.md | 9 ++++++++- .../python/README.md | 11 +++++++++-- .../python/bicep/README.md | 9 ++++++++- .../python/scripts/README.md | 9 ++++++++- .../python/terraform/README.md | 9 ++++++++- .../python/README.md | 11 +++++++++-- .../python/scripts/README.md | 9 ++++++++- .../web-app-managed-identity/python/README.md | 9 ++++++++- .../python/bicep/README.md | 9 ++++++++- .../python/scripts/README.md | 9 ++++++++- .../python/terraform/README.md | 9 ++++++++- samples/web-app-sql-database/python/README.md | 9 ++++++++- .../python/bicep/README.md | 9 ++++++++- .../python/scripts/README.md | 9 ++++++++- .../python/terraform/README.md | 9 ++++++++- 30 files changed, 246 insertions(+), 37 deletions(-) diff --git a/docs/LOCALSTACK.md b/docs/LOCALSTACK.md index fddabf2..7f1af9a 100644 --- a/docs/LOCALSTACK.md +++ b/docs/LOCALSTACK.md @@ -28,8 +28,15 @@ You can start the Azure emulator using one of the following methods: Make sure the `localstack` CLI is installed (`pip install localstack` or `brew install localstack/tap/localstack`). ```bash +# Set the authentication token export LOCALSTACK_AUTH_TOKEN= -IMAGE_NAME=localstack/localstack-azure-alpha localstack start + +# Start the LocalStack Azure emulator +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d +localstack wait -t 60 + +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception ``` This: diff --git a/samples/aci-blob-storage/python/README.md b/samples/aci-blob-storage/python/README.md index b1761a7..a44917f 100644 --- a/samples/aci-blob-storage/python/README.md +++ b/samples/aci-blob-storage/python/README.md @@ -27,13 +27,12 @@ The following diagram illustrates the architecture of the solution: ## Quick Start ```bash -# Start LocalStack Azure +# Start the LocalStack Azure emulator IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d localstack wait -t 60 -# Login -azlocal login -azlocal start_interception +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception # Deploy all services cd python diff --git a/samples/function-app-front-door/python/README.md b/samples/function-app-front-door/python/README.md index 52d48a5..113e1f0 100644 --- a/samples/function-app-front-door/python/README.md +++ b/samples/function-app-front-door/python/README.md @@ -62,12 +62,26 @@ The following diagrams visualize each scenario provisioned by `deploy_all.sh`. T ## Quick Start -1. **Deploy against real Azure** (eastus by default): +1. + +## Quick Start + +1. **Start the LocalStack Azure emulator** + ```bash + # Start the LocalStack Azure emulator + IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d + localstack wait -t 60 + + # Route all Azure CLI calls to the LocalStack Azure emulator + azlocal start-interception + ``` + +2. **Deploy against real Azure** (eastus by default): ```bash bash ./scripts/deploy_all.sh --name-prefix mydemo ``` -2. **Deploy against LocalStack emulator**: +3. **Deploy against LocalStack emulator**: ```bash bash ./scripts/deploy_all.sh --name-prefix mydemo --use-localstack ``` diff --git a/samples/function-app-managed-identity/python/README.md b/samples/function-app-managed-identity/python/README.md index b9a9a9f..fca6733 100644 --- a/samples/function-app-managed-identity/python/README.md +++ b/samples/function-app-managed-identity/python/README.md @@ -62,8 +62,15 @@ docker pull localstack/localstack-azure-alpha Start the LocalStack Azure emulator by running: ```bash +# Set the authentication token export LOCALSTACK_AUTH_TOKEN= -IMAGE_NAME=localstack/localstack-azure-alpha localstack start + +# Start the LocalStack Azure emulator +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d +localstack wait -t 60 + +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception ``` Deploy the application to LocalStack for Azure using one of these methods: diff --git a/samples/function-app-managed-identity/python/bicep/README.md b/samples/function-app-managed-identity/python/bicep/README.md index f99f5a5..f15afc7 100644 --- a/samples/function-app-managed-identity/python/bicep/README.md +++ b/samples/function-app-managed-identity/python/bicep/README.md @@ -83,8 +83,15 @@ docker pull localstack/localstack-azure-alpha Start the LocalStack Azure emulator using the localstack CLI, execute the following command: ```bash +# Set the authentication token export LOCALSTACK_AUTH_TOKEN= -IMAGE_NAME=localstack/localstack-azure-alpha localstack start + +# Start the LocalStack Azure emulator +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d +localstack wait -t 60 + +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception ``` Navigate to the `bicep` folder: diff --git a/samples/function-app-managed-identity/python/scripts/README.md b/samples/function-app-managed-identity/python/scripts/README.md index 1dede4b..132f58e 100644 --- a/samples/function-app-managed-identity/python/scripts/README.md +++ b/samples/function-app-managed-identity/python/scripts/README.md @@ -60,8 +60,15 @@ docker pull localstack/localstack-azure-alpha Start the LocalStack Azure emulator using the localstack CLI, execute the following command: ```bash +# Set the authentication token export LOCALSTACK_AUTH_TOKEN= -IMAGE_NAME=localstack/localstack-azure-alpha localstack start + +# Start the LocalStack Azure emulator +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d +localstack wait -t 60 + +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception ``` Navigate to the `scripts` folder: diff --git a/samples/function-app-managed-identity/python/terraform/README.md b/samples/function-app-managed-identity/python/terraform/README.md index 3bb87c8..8bd1e34 100644 --- a/samples/function-app-managed-identity/python/terraform/README.md +++ b/samples/function-app-managed-identity/python/terraform/README.md @@ -88,8 +88,15 @@ docker pull localstack/localstack-azure-alpha Start the LocalStack Azure emulator using the localstack CLI, execute the following command: ```bash +# Set the authentication token export LOCALSTACK_AUTH_TOKEN= -IMAGE_NAME=localstack/localstack-azure-alpha localstack start + +# Start the LocalStack Azure emulator +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d +localstack wait -t 60 + +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception ``` Navigate to the `terraform` folder: diff --git a/samples/function-app-service-bus/dotnet/README.md b/samples/function-app-service-bus/dotnet/README.md index c61f53b..a38f70b 100644 --- a/samples/function-app-service-bus/dotnet/README.md +++ b/samples/function-app-service-bus/dotnet/README.md @@ -64,9 +64,16 @@ docker pull localstack/localstack-azure-alpha Start the LocalStack Azure emulator by running: ```bash +# Set the authentication token export LOCALSTACK_AUTH_TOKEN= -IMAGE_NAME=localstack/localstack-azure-alpha localstack start - ``` + +# Start the LocalStack Azure emulator +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d +localstack wait -t 60 + +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception +``` Deploy the application to LocalStack for Azure using one of these methods: diff --git a/samples/function-app-service-bus/dotnet/bicep/README.md b/samples/function-app-service-bus/dotnet/bicep/README.md index 3bf1e7c..bca1b9d 100644 --- a/samples/function-app-service-bus/dotnet/bicep/README.md +++ b/samples/function-app-service-bus/dotnet/bicep/README.md @@ -101,8 +101,15 @@ docker pull localstack/localstack-azure-alpha Start the LocalStack Azure emulator using the localstack CLI, execute the following command: ```bash +# Set the authentication token export LOCALSTACK_AUTH_TOKEN= -IMAGE_NAME=localstack/localstack-azure-alpha localstack start + +# Start the LocalStack Azure emulator +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d +localstack wait -t 60 + +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception ``` Navigate to the `bicep` folder: diff --git a/samples/function-app-service-bus/dotnet/scripts/README.md b/samples/function-app-service-bus/dotnet/scripts/README.md index 7791f76..d935c05 100644 --- a/samples/function-app-service-bus/dotnet/scripts/README.md +++ b/samples/function-app-service-bus/dotnet/scripts/README.md @@ -70,8 +70,15 @@ docker pull localstack/localstack-azure-alpha Start the LocalStack Azure emulator using the localstack CLI, execute the following command: ```bash +# Set the authentication token export LOCALSTACK_AUTH_TOKEN= -IMAGE_NAME=localstack/localstack-azure-alpha localstack start + +# Start the LocalStack Azure emulator +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d +localstack wait -t 60 + +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception ``` Navigate to the `scripts` folder: diff --git a/samples/function-app-service-bus/dotnet/terraform/README.md b/samples/function-app-service-bus/dotnet/terraform/README.md index fc03ab9..0feaede 100644 --- a/samples/function-app-service-bus/dotnet/terraform/README.md +++ b/samples/function-app-service-bus/dotnet/terraform/README.md @@ -106,8 +106,15 @@ docker pull localstack/localstack-azure-alpha Start the LocalStack Azure emulator using the localstack CLI, execute the following command: ```bash +# Set the authentication token export LOCALSTACK_AUTH_TOKEN= -IMAGE_NAME=localstack/localstack-azure-alpha localstack start + +# Start the LocalStack Azure emulator +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d +localstack wait -t 60 + +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception ``` Navigate to the `terraform` folder: diff --git a/samples/function-app-storage-http/dotnet/terraform/README.md b/samples/function-app-storage-http/dotnet/terraform/README.md index 90c3b15..a060dbe 100644 --- a/samples/function-app-storage-http/dotnet/terraform/README.md +++ b/samples/function-app-storage-http/dotnet/terraform/README.md @@ -83,8 +83,15 @@ docker pull localstack/localstack-azure-alpha Start the LocalStack Azure emulator using the localstack CLI, execute the following command: ```bash +# Set the authentication token export LOCALSTACK_AUTH_TOKEN= -IMAGE_NAME=localstack/localstack-azure-alpha localstack start + +# Start the LocalStack Azure emulator +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d +localstack wait -t 60 + +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception ``` Navigate to the `terraform` folder: diff --git a/samples/servicebus/java/README.md b/samples/servicebus/java/README.md index cf6d4f8..ccf882c 100644 --- a/samples/servicebus/java/README.md +++ b/samples/servicebus/java/README.md @@ -37,8 +37,15 @@ docker pull localstack/localstack-azure-alpha Start the LocalStack Azure emulator by running: ```bash +# Set the authentication token export LOCALSTACK_AUTH_TOKEN= -IMAGE_NAME=localstack/localstack-azure-alpha localstack start + +# Start the LocalStack Azure emulator +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d +localstack wait -t 60 + +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception ``` Deploy the application to LocalStack for Azure using one of these methods: diff --git a/samples/servicebus/java/bicep/README.md b/samples/servicebus/java/bicep/README.md index 07ce110..f2ac6c3 100644 --- a/samples/servicebus/java/bicep/README.md +++ b/samples/servicebus/java/bicep/README.md @@ -75,8 +75,15 @@ docker pull localstack/localstack-azure-alpha Start the LocalStack Azure emulator using the localstack CLI, execute the following command: ```bash +# Set the authentication token export LOCALSTACK_AUTH_TOKEN= -IMAGE_NAME=localstack/localstack-azure-alpha localstack start + +# Start the LocalStack Azure emulator +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d +localstack wait -t 60 + +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception ``` Navigate to the `bicep` folder: diff --git a/samples/servicebus/java/scripts/README.md b/samples/servicebus/java/scripts/README.md index edcb2c1..217c65e 100644 --- a/samples/servicebus/java/scripts/README.md +++ b/samples/servicebus/java/scripts/README.md @@ -58,8 +58,15 @@ docker pull localstack/localstack-azure-alpha Start the LocalStack Azure emulator using the localstack CLI, execute the following command: ```bash +# Set the authentication token export LOCALSTACK_AUTH_TOKEN= -IMAGE_NAME=localstack/localstack-azure-alpha localstack start + +# Start the LocalStack Azure emulator +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d +localstack wait -t 60 + +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception ``` Navigate to the `scripts` folder: diff --git a/samples/servicebus/java/terraform/README.md b/samples/servicebus/java/terraform/README.md index 05e0c91..eae6660 100644 --- a/samples/servicebus/java/terraform/README.md +++ b/samples/servicebus/java/terraform/README.md @@ -81,8 +81,15 @@ docker pull localstack/localstack-azure-alpha Start the LocalStack Azure emulator using the localstack CLI, execute the following command: ```bash +# Set the authentication token export LOCALSTACK_AUTH_TOKEN= -IMAGE_NAME=localstack/localstack-azure-alpha localstack start + +# Start the LocalStack Azure emulator +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d +localstack wait -t 60 + +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception ``` Navigate to the `terraform` folder: diff --git a/samples/web-app-cosmosdb-mongodb-api/python/README.md b/samples/web-app-cosmosdb-mongodb-api/python/README.md index c2fadfc..2831794 100644 --- a/samples/web-app-cosmosdb-mongodb-api/python/README.md +++ b/samples/web-app-cosmosdb-mongodb-api/python/README.md @@ -47,9 +47,16 @@ docker pull localstack/localstack-azure-alpha Start the LocalStack Azure emulator by running: ```bash +# Set the authentication token export LOCALSTACK_AUTH_TOKEN= -IMAGE_NAME=localstack/localstack-azure-alpha localstack start - ``` + +# Start the LocalStack Azure emulator +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d +localstack wait -t 60 + +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception +``` Deploy the application to LocalStack for Azure using one of these methods: diff --git a/samples/web-app-cosmosdb-mongodb-api/python/bicep/README.md b/samples/web-app-cosmosdb-mongodb-api/python/bicep/README.md index bf66992..1d05a9a 100644 --- a/samples/web-app-cosmosdb-mongodb-api/python/bicep/README.md +++ b/samples/web-app-cosmosdb-mongodb-api/python/bicep/README.md @@ -88,8 +88,15 @@ docker pull localstack/localstack-azure-alpha Start the LocalStack Azure emulator using the localstack CLI, execute the following command: ```bash +# Set the authentication token export LOCALSTACK_AUTH_TOKEN= -IMAGE_NAME=localstack/localstack-azure-alpha localstack start + +# Start the LocalStack Azure emulator +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d +localstack wait -t 60 + +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception ``` Navigate to the `bicep` folder: diff --git a/samples/web-app-cosmosdb-mongodb-api/python/scripts/README.md b/samples/web-app-cosmosdb-mongodb-api/python/scripts/README.md index c0c79b0..1f6eaeb 100644 --- a/samples/web-app-cosmosdb-mongodb-api/python/scripts/README.md +++ b/samples/web-app-cosmosdb-mongodb-api/python/scripts/README.md @@ -73,8 +73,15 @@ docker pull localstack/localstack-azure-alpha Start the LocalStack Azure emulator using the localstack CLI, execute the following command: ```bash +# Set the authentication token export LOCALSTACK_AUTH_TOKEN= -IMAGE_NAME=localstack/localstack-azure-alpha localstack start + +# Start the LocalStack Azure emulator +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d +localstack wait -t 60 + +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception ``` Navigate to the `scripts` folder: diff --git a/samples/web-app-cosmosdb-mongodb-api/python/terraform/README.md b/samples/web-app-cosmosdb-mongodb-api/python/terraform/README.md index ba79265..564d95b 100644 --- a/samples/web-app-cosmosdb-mongodb-api/python/terraform/README.md +++ b/samples/web-app-cosmosdb-mongodb-api/python/terraform/README.md @@ -93,8 +93,15 @@ docker pull localstack/localstack-azure-alpha Start the LocalStack Azure emulator using the localstack CLI, execute the following command: ```bash +# Set the authentication token export LOCALSTACK_AUTH_TOKEN= -IMAGE_NAME=localstack/localstack-azure-alpha localstack start + +# Start the LocalStack Azure emulator +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d +localstack wait -t 60 + +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception ``` Navigate to the `terraform` folder: diff --git a/samples/web-app-cosmosdb-nosql-api/python/README.md b/samples/web-app-cosmosdb-nosql-api/python/README.md index ab667c0..bd25834 100644 --- a/samples/web-app-cosmosdb-nosql-api/python/README.md +++ b/samples/web-app-cosmosdb-nosql-api/python/README.md @@ -30,9 +30,16 @@ docker pull localstack/localstack-azure-alpha Start the LocalStack Azure emulator by running: ```bash +# Set the authentication token export LOCALSTACK_AUTH_TOKEN= -IMAGE_NAME=localstack/localstack-azure-alpha localstack start - ``` + +# Start the LocalStack Azure emulator +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d +localstack wait -t 60 + +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception +``` Deploy the application to LocalStack for Azure using: diff --git a/samples/web-app-cosmosdb-nosql-api/python/scripts/README.md b/samples/web-app-cosmosdb-nosql-api/python/scripts/README.md index 9abde0e..dadeb7a 100644 --- a/samples/web-app-cosmosdb-nosql-api/python/scripts/README.md +++ b/samples/web-app-cosmosdb-nosql-api/python/scripts/README.md @@ -35,8 +35,15 @@ docker pull localstack/localstack-azure-alpha Start the LocalStack Azure emulator using the localstack CLI, execute the following command: ```bash +# Set the authentication token export LOCALSTACK_AUTH_TOKEN= -IMAGE_NAME=localstack/localstack-azure-alpha localstack start + +# Start the LocalStack Azure emulator +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d +localstack wait -t 60 + +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception ``` Navigate to the `scripts` folder: diff --git a/samples/web-app-managed-identity/python/README.md b/samples/web-app-managed-identity/python/README.md index 9f835b1..3b0d85b 100644 --- a/samples/web-app-managed-identity/python/README.md +++ b/samples/web-app-managed-identity/python/README.md @@ -58,8 +58,15 @@ docker pull localstack/localstack-azure-alpha Start the LocalStack Azure emulator by running: ```bash +# Set the authentication token export LOCALSTACK_AUTH_TOKEN= -IMAGE_NAME=localstack/localstack-azure-alpha localstack start + +# Start the LocalStack Azure emulator +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d +localstack wait -t 60 + +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception ``` Deploy the application to LocalStack for Azure using one of these methods: diff --git a/samples/web-app-managed-identity/python/bicep/README.md b/samples/web-app-managed-identity/python/bicep/README.md index dac9d89..08c82ca 100644 --- a/samples/web-app-managed-identity/python/bicep/README.md +++ b/samples/web-app-managed-identity/python/bicep/README.md @@ -63,8 +63,15 @@ docker pull localstack/localstack-azure-alpha Start the LocalStack Azure emulator using the localstack CLI, execute the following command: ```bash +# Set the authentication token export LOCALSTACK_AUTH_TOKEN= -IMAGE_NAME=localstack/localstack-azure-alpha localstack start + +# Start the LocalStack Azure emulator +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d +localstack wait -t 60 + +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception ``` Navigate to the `bicep` folder: diff --git a/samples/web-app-managed-identity/python/scripts/README.md b/samples/web-app-managed-identity/python/scripts/README.md index bf43670..53041f3 100644 --- a/samples/web-app-managed-identity/python/scripts/README.md +++ b/samples/web-app-managed-identity/python/scripts/README.md @@ -79,8 +79,15 @@ docker pull localstack/localstack-azure-alpha Start the LocalStack Azure emulator using the localstack CLI, execute the following command: ```bash +# Set the authentication token export LOCALSTACK_AUTH_TOKEN= -IMAGE_NAME=localstack/localstack-azure-alpha localstack start + +# Start the LocalStack Azure emulator +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d +localstack wait -t 60 + +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception ``` Navigate to the `scripts` folder: diff --git a/samples/web-app-managed-identity/python/terraform/README.md b/samples/web-app-managed-identity/python/terraform/README.md index 269a2d6..4378d35 100644 --- a/samples/web-app-managed-identity/python/terraform/README.md +++ b/samples/web-app-managed-identity/python/terraform/README.md @@ -77,8 +77,15 @@ docker pull localstack/localstack-azure-alpha Start the LocalStack Azure emulator using the localstack CLI, execute the following command: ```bash +# Set the authentication token export LOCALSTACK_AUTH_TOKEN= -IMAGE_NAME=localstack/localstack-azure-alpha localstack start + +# Start the LocalStack Azure emulator +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d +localstack wait -t 60 + +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception ``` Navigate to the `terraform` folder: diff --git a/samples/web-app-sql-database/python/README.md b/samples/web-app-sql-database/python/README.md index a784eca..950a8cb 100644 --- a/samples/web-app-sql-database/python/README.md +++ b/samples/web-app-sql-database/python/README.md @@ -61,8 +61,15 @@ docker pull localstack/localstack-azure-alpha Start the LocalStack Azure emulator by running: ```bash +# Set the authentication token export LOCALSTACK_AUTH_TOKEN= -IMAGE_NAME=localstack/localstack-azure-alpha localstack start + +# Start the LocalStack Azure emulator +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d +localstack wait -t 60 + +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception ``` Deploy the application to LocalStack for Azure using one of these methods: diff --git a/samples/web-app-sql-database/python/bicep/README.md b/samples/web-app-sql-database/python/bicep/README.md index 67e72c9..4acf2ed 100644 --- a/samples/web-app-sql-database/python/bicep/README.md +++ b/samples/web-app-sql-database/python/bicep/README.md @@ -49,8 +49,15 @@ docker pull localstack/localstack-azure-alpha Start the LocalStack Azure emulator using the localstack CLI, execute the following command: ```bash +# Set the authentication token export LOCALSTACK_AUTH_TOKEN= -IMAGE_NAME=localstack/localstack-azure-alpha localstack start + +# Start the LocalStack Azure emulator +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d +localstack wait -t 60 + +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception ``` Navigate to the `bicep` folder: diff --git a/samples/web-app-sql-database/python/scripts/README.md b/samples/web-app-sql-database/python/scripts/README.md index 2d0ab8d..1dda2c3 100644 --- a/samples/web-app-sql-database/python/scripts/README.md +++ b/samples/web-app-sql-database/python/scripts/README.md @@ -49,8 +49,15 @@ docker pull localstack/localstack-azure-alpha Start the LocalStack Azure emulator using the localstack CLI, execute the following command: ```bash +# Set the authentication token export LOCALSTACK_AUTH_TOKEN= -IMAGE_NAME=localstack/localstack-azure-alpha localstack start + +# Start the LocalStack Azure emulator +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d +localstack wait -t 60 + +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception ``` Navigate to the `scripts` folder: diff --git a/samples/web-app-sql-database/python/terraform/README.md b/samples/web-app-sql-database/python/terraform/README.md index 382ff11..47ff666 100644 --- a/samples/web-app-sql-database/python/terraform/README.md +++ b/samples/web-app-sql-database/python/terraform/README.md @@ -73,8 +73,15 @@ docker pull localstack/localstack-azure-alpha Start the LocalStack Azure emulator using the localstack CLI, execute the following command: ```bash +# Set the authentication token export LOCALSTACK_AUTH_TOKEN= -IMAGE_NAME=localstack/localstack-azure-alpha localstack start + +# Start the LocalStack Azure emulator +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d +localstack wait -t 60 + +# Route all Azure CLI calls to the LocalStack Azure emulator +azlocal start-interception ``` Navigate to the `terraform` folder: From bc78a0bcf85239a2908d3259f31d0a47f582ebfd Mon Sep 17 00:00:00 2001 From: Paolo Salvatori Date: Fri, 10 Apr 2026 12:03:53 +0200 Subject: [PATCH 2/9] Fix Web App + SQL Sample --- .../python/bicep/deploy.sh | 6 +-- .../python/bicep/main.bicep | 2 + .../python/scripts/validate.sh | 51 ++++++++++++------- .../python/src/requirements.txt | 14 ++--- .../python/terraform/terraform.tfvars | 2 +- .../python/terraform/variables.tf | 1 + 6 files changed, 47 insertions(+), 29 deletions(-) diff --git a/samples/web-app-sql-database/python/bicep/deploy.sh b/samples/web-app-sql-database/python/bicep/deploy.sh index 4f78275..996806c 100755 --- a/samples/web-app-sql-database/python/bicep/deploy.sh +++ b/samples/web-app-sql-database/python/bicep/deploy.sh @@ -1,11 +1,11 @@ #!/bin/bash # Variables -PREFIX='local' +PREFIX='cayado' SUFFIX='test' TEMPLATE="main.bicep" PARAMETERS="main.bicepparam" -RESOURCE_GROUP_NAME="$PREFIX-webapp-sql-rg" +RESOURCE_GROUP_NAME="$PREFIX-rg" LOCATION="westeurope" VALIDATE_TEMPLATE=1 USE_WHAT_IF=0 @@ -295,7 +295,7 @@ fi # Create the zip package of the web app echo "Creating zip package of the web app..." -zip -r "$ZIPFILE" app.py activities.py database.py static templates requirements.txt +zip -r "$ZIPFILE" app.py activities.py certificates.py database.py static templates requirements.txt # Deploy the web app echo "Deploying web app [$WEB_APP_NAME] with zip file [$ZIPFILE]..." diff --git a/samples/web-app-sql-database/python/bicep/main.bicep b/samples/web-app-sql-database/python/bicep/main.bicep index 73580ad..bc70d41 100644 --- a/samples/web-app-sql-database/python/bicep/main.bicep +++ b/samples/web-app-sql-database/python/bicep/main.bicep @@ -323,6 +323,7 @@ var sqlServerName = '${prefix}-sqlserver-${suffix}' var webAppName = '${prefix}-webapp-${suffix}' var appServicePlanName = '${prefix}-app-service-plan-${suffix}' var keyVaultName = '${prefix}-kv-${suffix}' +var certificateName = '${prefix}-cert-${suffix}' var sqlConnectionStringSecretName = 'sql-connection-string' var identity = { type: 'SystemAssigned' @@ -478,6 +479,7 @@ resource configAppSettings 'Microsoft.Web/sites/config@2024-11-01' = { KEY_VAULT_NAME: keyVaultName SECRET_NAME: sqlConnectionStringSecretName LOGIN_NAME: username + KEYVAULT_URI: keyVault.properties.vaultUri } } diff --git a/samples/web-app-sql-database/python/scripts/validate.sh b/samples/web-app-sql-database/python/scripts/validate.sh index fde0134..19d5997 100755 --- a/samples/web-app-sql-database/python/scripts/validate.sh +++ b/samples/web-app-sql-database/python/scripts/validate.sh @@ -1,44 +1,59 @@ #!/bin/bash # Variables +PREFIX='local' +SUFFIX='test' +RESOURCE_GROUP_NAME="${PREFIX}-rg" +SQL_SERVER_NAME="${PREFIX}-sqlserver-${SUFFIX}" +SQL_DATABASE_NAME='PlannerDB' +WEB_APP_NAME="${PREFIX}-webapp-${SUFFIX}" +KEY_VAULT_NAME="${PREFIX}-kv-${SUFFIX}" +SECRET_NAME="${PREFIX}-secret-${SUFFIX}" + # Check resource group +echo -e "[$RESOURCE_GROUP_NAME] resource group:\n" az group show \ ---name local-rg \ ---output table - -# List resources -az resource list \ ---resource-group local-rg \ +--name "$RESOURCE_GROUP_NAME" \ --output table # Check Azure Web App +echo -e "\n[$WEB_APP_NAME] web app:\n" az webapp show \ ---name local-webapp-test \ ---resource-group local-rg \ +--name "$WEB_APP_NAME" \ +--resource-group "$RESOURCE_GROUP_NAME" \ +--query "{name:name, state:state, defaultHostName:defaultHostName}" \ --output table # Check Azure SQL Server +echo -e "\n[$SQL_SERVER_NAME] SQL server:\n" az sql server show \ ---name local-sqlserver-test \ ---resource-group local-rg \ +--name "$SQL_SERVER_NAME" \ +--resource-group "$RESOURCE_GROUP_NAME" \ --output table # Check Azure SQL Database +echo -e "\n[$SQL_DATABASE_NAME] SQL database:\n" az sql db show \ ---name PlannerDB \ ---server local-sqlserver-test \ ---resource-group local-rg \ +--name "$SQL_DATABASE_NAME" \ +--server "$SQL_SERVER_NAME" \ +--resource-group "$RESOURCE_GROUP_NAME" \ --output table # Check Azure Key Vault +echo -e "\n[$KEY_VAULT_NAME] Key Vault:\n" az keyvault show \ ---name local-kv-test \ ---resource-group local-rg \ +--name "$KEY_VAULT_NAME" \ +--resource-group "$RESOURCE_GROUP_NAME" \ --output table # Check Key Vault secret +echo -e "\n[$SECRET_NAME] Key Vault secret:\n" az keyvault secret show \ ---vault-name local-kv-test \ ---name local-secret-test \ +--vault-name "$KEY_VAULT_NAME" \ +--name "$SECRET_NAME" \ --query "{name:name, enabled:attributes.enabled, created:attributes.created}" \ ---output table \ No newline at end of file +--output table + +# Print the list of resources in the resource group +echo -e "\nListing resources in resource group [$RESOURCE_GROUP_NAME]...\n" +az resource list --resource-group "$RESOURCE_GROUP_NAME" --output table diff --git a/samples/web-app-sql-database/python/src/requirements.txt b/samples/web-app-sql-database/python/src/requirements.txt index b2685fc..5fd779d 100644 --- a/samples/web-app-sql-database/python/src/requirements.txt +++ b/samples/web-app-sql-database/python/src/requirements.txt @@ -1,8 +1,8 @@ -Flask==3.1.0 -azure-identity==1.25.1 +Flask==3.1.3 +azure-identity==1.25.3 pyodbc==5.3.0 -gunicorn==23.0.0 -python-dotenv==1.1.1 -azure-keyvault-secrets -azure-keyvault-certificates -cryptography \ No newline at end of file +gunicorn==25.3.0 +python-dotenv==1.2.2 +azure-keyvault-secrets==4.10.0 +azure-keyvault-certificates==4.10.0 +cryptography==46.0.7 \ No newline at end of file diff --git a/samples/web-app-sql-database/python/terraform/terraform.tfvars b/samples/web-app-sql-database/python/terraform/terraform.tfvars index 62c676a..8e831cf 100644 --- a/samples/web-app-sql-database/python/terraform/terraform.tfvars +++ b/samples/web-app-sql-database/python/terraform/terraform.tfvars @@ -1,2 +1,2 @@ location = "westeurope" -python_version = "3.12" \ No newline at end of file +python_version = "3.13" \ No newline at end of file diff --git a/samples/web-app-sql-database/python/terraform/variables.tf b/samples/web-app-sql-database/python/terraform/variables.tf index d54f76f..596be04 100644 --- a/samples/web-app-sql-database/python/terraform/variables.tf +++ b/samples/web-app-sql-database/python/terraform/variables.tf @@ -281,6 +281,7 @@ variable "python_version" { validation { condition = contains([ + "3.13", "3.12", "3.11", "3.10", From 015885369af6018464d5a0c8b0c28476587e4423 Mon Sep 17 00:00:00 2001 From: Paolo Salvatori Date: Mon, 13 Apr 2026 08:20:34 +0200 Subject: [PATCH 3/9] Change secret name to be compliant with validate.sh --- samples/web-app-sql-database/python/bicep/deploy.sh | 2 +- samples/web-app-sql-database/python/bicep/main.bicep | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/samples/web-app-sql-database/python/bicep/deploy.sh b/samples/web-app-sql-database/python/bicep/deploy.sh index 996806c..7d1f395 100755 --- a/samples/web-app-sql-database/python/bicep/deploy.sh +++ b/samples/web-app-sql-database/python/bicep/deploy.sh @@ -1,7 +1,7 @@ #!/bin/bash # Variables -PREFIX='cayado' +PREFIX='local' SUFFIX='test' TEMPLATE="main.bicep" PARAMETERS="main.bicepparam" diff --git a/samples/web-app-sql-database/python/bicep/main.bicep b/samples/web-app-sql-database/python/bicep/main.bicep index bc70d41..cdd900c 100644 --- a/samples/web-app-sql-database/python/bicep/main.bicep +++ b/samples/web-app-sql-database/python/bicep/main.bicep @@ -323,8 +323,7 @@ var sqlServerName = '${prefix}-sqlserver-${suffix}' var webAppName = '${prefix}-webapp-${suffix}' var appServicePlanName = '${prefix}-app-service-plan-${suffix}' var keyVaultName = '${prefix}-kv-${suffix}' -var certificateName = '${prefix}-cert-${suffix}' -var sqlConnectionStringSecretName = 'sql-connection-string' +var sqlConnectionStringSecretName = '${prefix}-secret-${suffix}' var identity = { type: 'SystemAssigned' } From d1e8cd2b68c8d7e39c5287991360565b453fe632 Mon Sep 17 00:00:00 2001 From: "Dris.S" Date: Mon, 13 Apr 2026 11:25:37 +0100 Subject: [PATCH 4/9] updated runner --- .github/workflows/run-samples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-samples.yml b/.github/workflows/run-samples.yml index afbd66b..cb0e12b 100644 --- a/.github/workflows/run-samples.yml +++ b/.github/workflows/run-samples.yml @@ -70,7 +70,7 @@ jobs: strategy: fail-fast: false matrix: ${{ fromJSON(needs.setup.outputs.matrix) }} - runs-on: github-ubuntu2204-amd64-4 + runs-on: ubuntu-22.04 env: IMAGE_NAME: localstack/localstack-azure-alpha From 14d82701af69e40be4f2f3341d2dea7f3603471f Mon Sep 17 00:00:00 2001 From: "Dris.S" Date: Mon, 13 Apr 2026 11:32:17 +0100 Subject: [PATCH 5/9] skip if already exists --- .github/workflows/run-samples.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-samples.yml b/.github/workflows/run-samples.yml index cb0e12b..20b6199 100644 --- a/.github/workflows/run-samples.yml +++ b/.github/workflows/run-samples.yml @@ -163,8 +163,10 @@ jobs: # Required for the 'web-app-sql-database' sample which uses 'sqlcmd' to # initialize and verify the database schema in the local emulator. run: | - curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc - curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list + if [ ! -f /etc/apt/sources.list.d/mssql-release.list ]; then + curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc + curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list + fi sudo apt-get update sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 echo "/opt/mssql-tools18/bin" >> $GITHUB_PATH From ea0896aa5db39b45e0ec14cfc13658dde8bbe7a0 Mon Sep 17 00:00:00 2001 From: "Dris.S" Date: Mon, 13 Apr 2026 11:37:44 +0100 Subject: [PATCH 6/9] remove the pre-existing microsoft-prod.list --- .github/workflows/run-samples.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/run-samples.yml b/.github/workflows/run-samples.yml index 20b6199..1504ae2 100644 --- a/.github/workflows/run-samples.yml +++ b/.github/workflows/run-samples.yml @@ -163,10 +163,9 @@ jobs: # Required for the 'web-app-sql-database' sample which uses 'sqlcmd' to # initialize and verify the database schema in the local emulator. run: | - if [ ! -f /etc/apt/sources.list.d/mssql-release.list ]; then - curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc - curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list - fi + sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list + curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc + curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list sudo apt-get update sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 echo "/opt/mssql-tools18/bin" >> $GITHUB_PATH From ae67f32f51bba4f4585928e8aeecaeb3e1c024f7 Mon Sep 17 00:00:00 2001 From: "Dris.S" Date: Mon, 13 Apr 2026 12:17:42 +0100 Subject: [PATCH 7/9] upgraded azurerm provider --- samples/web-app-sql-database/python/terraform/providers.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/web-app-sql-database/python/terraform/providers.tf b/samples/web-app-sql-database/python/terraform/providers.tf index 566cfc6..55bebe0 100644 --- a/samples/web-app-sql-database/python/terraform/providers.tf +++ b/samples/web-app-sql-database/python/terraform/providers.tf @@ -4,7 +4,7 @@ terraform { required_providers { azurerm = { source = "hashicorp/azurerm" - version = "=4.14.0" + version = "=4.25.0" } } } From a1fa0d7ac143bef4af145675beaac20394a1e5e5 Mon Sep 17 00:00:00 2001 From: Paolo Salvatori Date: Tue, 14 Apr 2026 16:49:34 +0200 Subject: [PATCH 8/9] Modify Samples to Call Function App and Web App Samples via Default Hostname --- .../python/README.md | 2 +- .../function-app-service-bus/dotnet/README.md | 2 +- .../dotnet/scripts/call-http-trigger.sh | 15 +- .../dotnet/scripts/deploy.sh | 57 +++-- .../dotnet/README.md | 186 +--------------- .../dotnet/scripts/call-http-triggers.sh | 21 +- .../python/README.md | 206 +----------------- .../python/scripts/call-web-app.sh | 16 +- .../python/README.md | 206 +----------------- .../python/scripts/call-web-app.sh | 16 +- .../web-app-managed-identity/python/README.md | 206 +----------------- .../python/scripts/call-web-app.sh | 16 +- samples/web-app-sql-database/python/README.md | 206 +----------------- .../python/scripts/deploy.sh | 2 +- .../python/scripts/get-web-app-url.sh | 14 ++ 15 files changed, 83 insertions(+), 1088 deletions(-) diff --git a/samples/function-app-managed-identity/python/README.md b/samples/function-app-managed-identity/python/README.md index fca6733..a81d21f 100644 --- a/samples/function-app-managed-identity/python/README.md +++ b/samples/function-app-managed-identity/python/README.md @@ -86,7 +86,7 @@ All deployment methods have been fully tested with both user-assigned and system ## Test -Once the resources and serverless application have been deployed, you can use the `test.sh` script below to copy a sample file to the `input` container and monitor whether the Azure Functions App processes the input blob file and generates a result file in the `output` container. +Once the resources and serverless application have been deployed, you can use the [test.sh](./scripts/test.sh) script below to copy a sample file to the `input` container and monitor whether the Azure Functions App processes the input blob file and generates a result file in the `output` container. ```bash #!/bin/bash diff --git a/samples/function-app-service-bus/dotnet/README.md b/samples/function-app-service-bus/dotnet/README.md index a38f70b..a82fd6a 100644 --- a/samples/function-app-service-bus/dotnet/README.md +++ b/samples/function-app-service-bus/dotnet/README.md @@ -105,7 +105,7 @@ Getting IP address for container [ls-local-func-test-tdkqjh]... IP address [172.17.0.7] retrieved successfully for container [ls-local-func-test-tdkqjh] Getting the host port mapped to internal port 80 in container [ls-local-func-test-tdkqjh]... Mapped host port [42330] retrieved successfully for container [ls-local-func-test-tdkqjh] -Calling HTTP trigger function to retrieve the last [10] greetings via emulator... +Calling HTTP trigger function to retrieve the last [100] greetings via hostname [babo-func-test.azurewebsites.azure.localhost.localstack.cloud:4566]... { "requester": { "sent": [ diff --git a/samples/function-app-service-bus/dotnet/scripts/call-http-trigger.sh b/samples/function-app-service-bus/dotnet/scripts/call-http-trigger.sh index 25d2e53..46150fe 100755 --- a/samples/function-app-service-bus/dotnet/scripts/call-http-trigger.sh +++ b/samples/function-app-service-bus/dotnet/scripts/call-http-trigger.sh @@ -117,7 +117,7 @@ call_http_trigger_function() { # Get the container IP address echo "Getting IP address for container [$container_name]..." container_ip=$(get_docker_container_ip_address_by_name "$container_name") - greeting_count=10 + greeting_count=100 if [ $? -eq 0 ] && [ -n "$container_ip" ]; then echo "IP address [$container_ip] retrieved successfully for container [$container_name]" @@ -137,15 +137,12 @@ call_http_trigger_function() { exit 1 fi - # Retrieve LocalStack proxy port - proxy_port=$(curl http://localhost:4566/_localstack/proxy -s | jq '.proxy_port') - - if [ -n "$proxy_port" ]; then - # Call the GetGreetings HTTP trigger function to retrieve the last greetings via emulator - echo "Calling HTTP trigger function to retrieve the last [$greeting_count] greetings via emulator..." - curl --proxy "http://localhost:$proxy_port/" -s "http://$function_host_name/api/greetings?count=$greeting_count" | jq + if [ -n "$function_host_name" ]; then + # Call the GetGreetings HTTP trigger function to retrieve the last greetings via the function hostname + echo "Calling HTTP trigger function to retrieve the last [$greeting_count] greetings via function hostname [$function_host_name]..." + curl -s "http://$function_host_name/api/greetings?count=$greeting_count" | jq else - echo "Failed to retrieve LocalStack proxy port" + echo "Failed to retrieve function hostname" fi if [ -n "$container_ip" ]; then diff --git a/samples/function-app-service-bus/dotnet/scripts/deploy.sh b/samples/function-app-service-bus/dotnet/scripts/deploy.sh index d68fa06..cc47c8f 100755 --- a/samples/function-app-service-bus/dotnet/scripts/deploy.sh +++ b/samples/function-app-service-bus/dotnet/scripts/deploy.sh @@ -1,6 +1,6 @@ #!/bin/bash -PREFIX='local' +PREFIX='babo' SUFFIX='test' LOCATION='westeurope' RESOURCE_GROUP_NAME="${PREFIX}-rg" @@ -49,10 +49,23 @@ PE_NAMES=( "${PREFIX}-queue-storage-pe-${SUFFIX}" "${PREFIX}-table-storage-pe-${SUFFIX}" ) -PE_GROUP_IDS=("namespace" "blob" "queue" "table") -PE_CONNECTION_NAMES=("servicebus-connection" "blob-connection" "queue-connection" "table-connection") -PE_DNS_ZONES=("privatelink.servicebus.windows.net" "privatelink.blob.core.windows.net" "privatelink.queue.core.windows.net" "privatelink.table.core.windows.net") -PE_DNS_ZONE_LABELS=("servicebus-zone" "blob-zone" "queue-zone" "table-zone") +PE_GROUP_IDS=( + "namespace" + "blob" "queue" + "table" +) +PE_CONNECTION_NAMES=( + "servicebus-connection" + "blob-connection" + "queue-connection" + "table-connection" +) +PE_DNS_ZONES=( + "privatelink.servicebus.windows.net" + "privatelink.blob.core.windows.net" + "privatelink.queue.core.windows.net" + "privatelink.table.core.windows.net" +) # Change the current directory to the script's directory cd "$CURRENT_DIR" || exit @@ -640,7 +653,6 @@ for i in "${!PE_NAMES[@]}"; do PE_RESOURCE_ID="${PE_RESOURCE_IDS[$i]}" PE_CONNECTION="${PE_CONNECTION_NAMES[$i]}" PE_DNS_ZONE="${PE_DNS_ZONES[$i]}" - PE_DNS_ZONE_LABEL="${PE_DNS_ZONE_LABELS[$i]}" # Check if the private endpoint already exists echo "Checking if private endpoint [$PE_NAME] exists in the [$RESOURCE_GROUP_NAME] resource group..." @@ -679,15 +691,15 @@ for i in "${!PE_NAMES[@]}"; do # Check if the private DNS zone group is already created echo "Checking if the private DNS zone group [$PRIVATE_DNS_ZONE_GROUP_NAME] for the [$PE_NAME] private endpoint already exists..." - az network private-endpoint dns-zone-group show \ + NAME=$(az network private-endpoint dns-zone-group show \ --resource-group "$RESOURCE_GROUP_NAME" \ --endpoint-name "$PE_NAME" \ --name "$PRIVATE_DNS_ZONE_GROUP_NAME" \ --query name \ --output tsv \ - --only-show-errors &>/dev/null + --only-show-errors) - if [[ $? != 0 ]]; then + if [[ -z $NAME ]]; then echo "No private DNS zone group [$PRIVATE_DNS_ZONE_GROUP_NAME] for the [$PE_NAME] private endpoint actually exists" echo "Creating private DNS zone group [$PRIVATE_DNS_ZONE_GROUP_NAME] for the [$PE_NAME] private endpoint..." @@ -697,7 +709,7 @@ for i in "${!PE_NAMES[@]}"; do --resource-group "$RESOURCE_GROUP_NAME" \ --endpoint-name "$PE_NAME" \ --private-dns-zone "$PE_DNS_ZONE" \ - --zone-name "$PE_DNS_ZONE_LABEL" \ + --zone-name "$PE_DNS_ZONE" \ --only-show-errors 1>/dev/null if [[ $? == 0 ]]; then @@ -716,26 +728,6 @@ if [ $DEPLOY -eq 0 ]; then exit 0 fi -# Check if the application insights az extension is already installed -echo "Checking if [application-insights] az extension is already installed..." -az extension show --name application-insights &>/dev/null - -if [[ $? == 0 ]]; then - echo "[application-insights] az extension is already installed" -else - echo "[application-insights] az extension is not installed. Installing..." - - # Install application-insights az extension - az extension add --name application-insights 1>/dev/null - - if [[ $? == 0 ]]; then - echo "[application-insights] az extension successfully installed" - else - echo "Failed to install [application-insights] az extension" - exit - fi -fi - # Check if the application insights component already exists echo "Checking if [$APPLICATION_INSIGHTS_NAME] Application Insights component exists in the [$RESOURCE_GROUP_NAME] resource group..." az monitor app-insights component show \ @@ -1061,7 +1053,7 @@ if ! az appservice plan show \ --name $APP_SERVICE_PLAN_NAME \ --resource-group $RESOURCE_GROUP_NAME \ --location $LOCATION \ - --sku B1 \ + --sku S1 \ --is-linux \ --tags $TAGS \ --only-show-errors 1>/dev/null; then @@ -1162,6 +1154,7 @@ az functionapp config appsettings set \ --name $FUNCTION_APP_NAME \ --resource-group $RESOURCE_GROUP_NAME \ --settings \ + APPLICATIONINSIGHTS_AUTHENTICATION_STRING="ClientId=${CLIENT_ID};Authorization=AAD" \ AZURE_CLIENT_ID="$CLIENT_ID" \ SCM_DO_BUILD_DURING_DEPLOYMENT=false \ FUNCTIONS_WORKER_RUNTIME=${RUNTIME,,} \ @@ -1457,4 +1450,4 @@ fi # Print the list of resources in the resource group echo "Listing resources in resource group [$RESOURCE_GROUP_NAME]..." -az resource list --resource-group "$RESOURCE_GROUP_NAME" --output table \ No newline at end of file +az resource list --resource-group "$RESOURCE_GROUP_NAME" --output table diff --git a/samples/function-app-storage-http/dotnet/README.md b/samples/function-app-storage-http/dotnet/README.md index 0a315c7..0c5132c 100644 --- a/samples/function-app-storage-http/dotnet/README.md +++ b/samples/function-app-storage-http/dotnet/README.md @@ -163,194 +163,10 @@ All deployment methods have been fully tested against Azure and the LocalStack f Use the [call-http-triggers.sh](./scripts/call-http-triggers.sh) script to quickly test the sample's HTTP-triggered Azure Functions and verify player status or game session details. The script below demonstrates three methods for calling HTTP-triggered functions: -1. **Through the LocalStack for Azure emulator**: Call the function app via the emulator using its default host name. The emulator acts as a proxy to the function app. +1. **Via the default hostname**: Call the function app via the default hostname `.azurewebsites.azure.localhost.localstack.cloud:4566`. 2. **Via localhost and host port mapped to the container's port**: Use `127.0.0.1` with the host port mapped to the container's port `80`. 3. **Via container IP address**: Use the app container's IP address on port `80`. This technique is only available when accessing the function app from the Docker host machine. -```bash -#!/bin/bash - -get_docker_container_name_by_prefix() { - local app_prefix="$1" - local container_name - - # Check if Docker is running - if ! docker info >/dev/null 2>&1; then - echo "Error: Docker is not running" >&2 - return 1 - fi - - echo "Looking for containers with names starting with [$app_prefix]..." >&2 - - # Find the container using grep - container_name=$(docker ps --format "{{.Names}}" | grep "^${app_prefix}" | head -1) - - if [ -z "$container_name" ]; then - echo "Error: No running container found with name starting with [$app_prefix]" >&2 - return 1 - fi - - echo "Found matching container [$container_name]" >&2 - echo "$container_name" -} - -get_docker_container_ip_address_by_name() { - local container_name="$1" - local ip_address - - if [ -z "$container_name" ]; then - echo "Error: Container name is required" >&2 - return 1 - fi - - # Get IP address - ip_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$container_name") - - if [ -z "$ip_address" ]; then - echo "Error: Container [$container_name] has no IP address assigned" >&2 - return 1 - fi - - echo "$ip_address" -} - -get_docker_container_port_mapping() { - local container_name="$1" - local container_port="$2" - local host_port - - if [ -z "$container_name" ] || [ -z "$container_port" ]; then - echo "Error: Container name and container port are required" >&2 - return 1 - fi - - # Get host port mapping - host_port=$(docker inspect -f "{{(index (index .NetworkSettings.Ports \"${container_port}/tcp\") 0).HostPort}}" "$container_name") - - if [ -z "$host_port" ]; then - echo "Error: No host port mapping found for container [$container_name] port [$container_port]" >&2 - return 1 - fi - - echo "$host_port" -} - -call_http_trigger_functions() { - # Get the function app name - echo "Getting function app name..." - function_app_name=$(azlocal functionapp list --query '[0].name' --output tsv) - - if [ -n "$function_app_name" ]; then - echo "Function app [$function_app_name] successfully retrieved." - else - echo "Error: No function app found" - exit 1 - fi - - # Get the resource group name - echo "Getting resource group name for function app [$function_app_name]..." - resource_group_name=$(azlocal functionapp list --query '[0].resourceGroup' --output tsv) - - if [ -n "$resource_group_name" ]; then - echo "Resource group [$resource_group_name] successfully retrieved." - else - echo "Error: No resource group found for function app [$function_app_name]" - exit 1 - fi - - # Get the the default host name of the function app - echo "Getting the default host name of the function app [$function_app_name]..." - function_host_name=$(azlocal functionapp show \ - --name "$function_app_name" \ - --resource-group "$resource_group_name" \ - --query 'defaultHostName' \ - --output tsv) - - if [ -n "$function_host_name" ]; then - echo "Function app default host name [$function_host_name] successfully retrieved." - else - echo "Error: No function app default host name found" - exit 1 - fi - - # Get the Docker container name - echo "Finding container name with prefix [ls-$function_app_name]..." - container_name=$(get_docker_container_name_by_prefix "ls-$function_app_name") - - if [ $? -eq 0 ] && [ -n "$container_name" ]; then - echo "Container [$container_name] found successfully" - else - echo "Failed to get container name" - exit 1 - fi - - # Get the container IP address - echo "Getting IP address for container [$container_name]..." - container_ip=$(get_docker_container_ip_address_by_name "$container_name") - player_name='Leo' - game_session='1' - - if [ $? -eq 0 ] && [ -n "$container_ip" ]; then - echo "IP address [$container_ip] retrieved successfully for container [$container_name]" - else - echo "Failed to get container IP address" - exit 1 - fi - - # Get the mapped host port for function app HTTP trigger (internal port 80) - echo "Getting the host port mapped to internal port 80 in container [$container_name]..." - host_port=$(get_docker_container_port_mapping "$container_name" "80") - - if [ $? -eq 0 ] && [ -n "$host_port" ]; then - echo "Mapped host port [$host_port] retrieved successfully for container [$container_name]" - else - echo "Failed to get mapped host port for container [$container_name]" - exit 1 - fi - - # Retrieve LocalStack proxy port - proxy_port=$(curl http://localhost:4566/_localstack/proxy -s | jq '.proxy_port') - - if [ -n "$proxy_port" ]; then - # Call the GET HTTP trigger function that returns a player status in a specified game session via emulator - echo "Calling HTTP trigger function to retrieve player [$player_name] status in game session [$game_session] via emulator..." - curl --proxy "http://localhost:$proxy_port/" -s "http://$function_host_name/api/player/$game_session/$player_name/status" | jq - - # Call the POST HTTP trigger function that returns the game session details via emulator - echo "Calling HTTP trigger function to retrieve game session [$game_session] details via emulator..." - curl --proxy "http://localhost:$proxy_port/" -s -X POST -H "Content-Type: application/json" -d "{\"gameId\": $game_session}" "http://$function_host_name/api/game/session" | jq - else - echo "Failed to retrieve LocalStack proxy port" - fi - - if [ -n "$container_ip" ]; then - # Call the GET HTTP trigger function that returns a player status in a specified game session via the container IP address - echo "Calling HTTP trigger function to retrieve player [$player_name] status in game session [$game_session] via container IP address [$container_ip]..." - curl -s "http://$container_ip/api/player/$game_session/$player_name/status" | jq - - # Call the POST HTTP trigger function that returns the game session details via the container IP address - echo "Calling HTTP trigger function to retrieve game session [$game_session] details via container IP address [$container_ip]..." - curl -s -X POST -H "Content-Type: application/json" -d "{\"gameId\": $game_session}" "http://$container_ip/api/game/session" | jq - else - echo "Failed to retrieve container IP address" - fi - - if [ -n "$host_port" ]; then - # Call the GET HTTP trigger function that returns a player status in a specified game session via the host port - echo "Calling HTTP trigger function to retrieve player [$player_name] status in game session [$game_session] via host port [$host_port]..." - curl -s "http://localhost:$host_port/api/player/$game_session/$player_name/status" | jq - - # Call the POST HTTP trigger function that returns the game session details via the host port - echo "Calling HTTP trigger function to retrieve game session [$game_session] details via host port [$host_port]..." - curl -s -X POST -H "Content-Type: application/json" -d "{\"gameId\": $game_session}" "http://localhost:$host_port/api/game/session" | jq - else - echo "Failed to retrieve container IP address" - fi -} - -call_http_trigger_functions -``` - ## Storage Contents You can use [Azure Storage Explorer](https://learn.microsoft.com/en-us/azure/storage/storage-explorer/vs-azure-tools-storage-manage-with-storage-explorer) to confirm that your Azure Function app creates the expected storage entities in the emulated storage account. To do this: diff --git a/samples/function-app-storage-http/dotnet/scripts/call-http-triggers.sh b/samples/function-app-storage-http/dotnet/scripts/call-http-triggers.sh index e9a05db..21f4b0d 100755 --- a/samples/function-app-storage-http/dotnet/scripts/call-http-triggers.sh +++ b/samples/function-app-storage-http/dotnet/scripts/call-http-triggers.sh @@ -138,19 +138,16 @@ call_http_trigger_functions() { exit 1 fi - # Retrieve LocalStack proxy port - proxy_port=$(curl http://localhost:4566/_localstack/proxy -s | jq '.proxy_port') - - if [ -n "$proxy_port" ]; then - # Call the GET HTTP trigger function that returns a player status in a specified game session via emulator - echo "Calling HTTP trigger function to retrieve player [$player_name] status in game session [$game_session] via emulator..." - curl --proxy "http://localhost:$proxy_port/" -s "http://$function_host_name/api/player/$game_session/$player_name/status" | jq + if [ -n "$function_host_name" ]; then + # Call the GET HTTP trigger function that returns a player status in a specified game session via the function hostname + echo "Calling HTTP trigger function to retrieve player [$player_name] status in game session [$game_session] via function hostname [$function_host_name]..." + curl -s "http://$function_host_name/api/player/$game_session/$player_name/status" | jq - # Call the POST HTTP trigger function that returns the game session details via emulator - echo "Calling HTTP trigger function to retrieve game session [$game_session] details via emulator..." - curl --proxy "http://localhost:$proxy_port/" -s -X POST -H "Content-Type: application/json" -d "{\"gameId\": $game_session}" "http://$function_host_name/api/game/session" | jq + # Call the POST HTTP trigger function that returns the game session details via the function hostname + echo "Calling HTTP trigger function to retrieve game session [$game_session] details via function hostname [$function_host_name]..." + curl -s -X POST -H "Content-Type: application/json" -d "{\"gameId\": $game_session}" "http://$function_host_name/api/game/session" | jq else - echo "Failed to retrieve LocalStack proxy port" + echo "Failed to retrieve function hostname" fi if [ -n "$container_ip" ]; then @@ -174,7 +171,7 @@ call_http_trigger_functions() { echo "Calling HTTP trigger function to retrieve game session [$game_session] details via host port [$host_port]..." curl -s -X POST -H "Content-Type: application/json" -d "{\"gameId\": $game_session}" "http://localhost:$host_port/api/game/session" | jq else - echo "Failed to retrieve container IP address" + echo "Failed to retrieve host port" fi } diff --git a/samples/web-app-cosmosdb-mongodb-api/python/README.md b/samples/web-app-cosmosdb-mongodb-api/python/README.md index 2831794..b936381 100644 --- a/samples/web-app-cosmosdb-mongodb-api/python/README.md +++ b/samples/web-app-cosmosdb-mongodb-api/python/README.md @@ -82,211 +82,7 @@ You can use the `call-web-app.sh` Bash script below to call the web app. The scr 1. **Through the LocalStack for Azure emulator**: Call the web app via the emulator using its default host name. The emulator acts as a proxy to the web app. 2. **Via localhost and host port mapped to the container's port**: Use `127.0.0.1` with the host port mapped to the container's port `80`. 3. **Via container IP address**: Use the app container's IP address on port `80`. This technique is only available when accessing the web app from the Docker host machine. -4. **Via Runtime Gateway**: Use the `{web_app_name}website.localhost.localstack.cloud:4566` URL to call the web app via the LocalStack runtime gateway. - -```bash -#!/bin/bash - -get_docker_container_name_by_prefix() { - local app_prefix="$1" - local container_name - - # Check if Docker is running - if ! docker info >/dev/null 2>&1; then - echo "Error: Docker is not running" >&2 - return 1 - fi - - echo "Looking for containers with names starting with [$app_prefix]..." >&2 - - # Find the container using grep - container_name=$(docker ps --format "{{.Names}}" | grep "^${app_prefix}" | head -1) - - if [ -z "$container_name" ]; then - echo "Error: No running container found with name starting with [$app_prefix]" >&2 - return 1 - fi - - echo "Found matching container [$container_name]" >&2 - echo "$container_name" -} - -get_docker_container_ip_address_by_name() { - local container_name="$1" - local ip_address - - if [ -z "$container_name" ]; then - echo "Error: Container name is required" >&2 - return 1 - fi - - # Get IP address - ip_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$container_name") - - if [ -z "$ip_address" ]; then - echo "Error: Container [$container_name] has no IP address assigned" >&2 - return 1 - fi - - echo "$ip_address" -} - -get_docker_container_port_mapping() { - local container_name="$1" - local container_port="$2" - local host_port - - if [ -z "$container_name" ] || [ -z "$container_port" ]; then - echo "Error: Container name and container port are required" >&2 - return 1 - fi - - # Get host port mapping - host_port=$(docker inspect -f "{{(index (index .NetworkSettings.Ports \"${container_port}/tcp\") 0).HostPort}}" "$container_name") - - if [ -z "$host_port" ]; then - echo "Error: No host port mapping found for container [$container_name] port [$container_port]" >&2 - return 1 - fi - - echo "$host_port" -} - -call_web_app() { - # Get the web app name - echo "Getting web app name..." - web_app_name=$(azlocal webapp list --query '[0].name' --output tsv) - - if [ -n "$web_app_name" ]; then - echo "Web app [$web_app_name] successfully retrieved." - else - echo "Error: No web app found" - exit 1 - fi - - # 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) - - if [ -n "$resource_group_name" ]; then - echo "Resource group [$resource_group_name] successfully retrieved." - else - echo "Error: No resource group found for web app [$web_app_name]" - exit 1 - fi - - # 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 \ - --name "$web_app_name" \ - --resource-group "$resource_group_name" \ - --query 'defaultHostName' \ - --output tsv) - - if [ -n "$app_host_name" ]; then - echo "Web app default host name [$app_host_name] successfully retrieved." - else - echo "Error: No web app default host name found" - exit 1 - fi - - # Get the Docker container name - echo "Finding container name with prefix [ls-$web_app_name]..." - container_name=$(get_docker_container_name_by_prefix "ls-$web_app_name") - - if [ $? -eq 0 ] && [ -n "$container_name" ]; then - echo "Container [$container_name] found successfully" - else - echo "Failed to get container name" - exit 1 - fi - - # Get the container IP address - echo "Getting IP address for container [$container_name]..." - container_ip=$(get_docker_container_ip_address_by_name "$container_name") - - if [ $? -eq 0 ] && [ -n "$container_ip" ]; then - echo "IP address [$container_ip] retrieved successfully for container [$container_name]" - else - echo "Failed to get container IP address" - exit 1 - fi - - # Get the mapped host port for web app HTTP trigger (internal port 80) - echo "Getting the host port mapped to internal port 80 in container [$container_name]..." - host_port=$(get_docker_container_port_mapping "$container_name" "80") - - if [ $? -eq 0 ] && [ -n "$host_port" ]; then - echo "Mapped host port [$host_port] retrieved successfully for container [$container_name]" - else - echo "Failed to get mapped host port for container [$container_name]" - exit 1 - fi - - # Retrieve LocalStack proxy port - proxy_port=$(curl http://localhost:4566/_localstack/proxy -s | jq '.proxy_port') - - if [ -n "$proxy_port" ]; then - # Call the web app via emulator proxy - echo "Calling web app [$web_app_name] via emulator..." - curl --proxy "http://localhost:$proxy_port/" -s "http://$app_host_name/" 1> /dev/null - - if [ $? == 0 ]; then - echo "Web app call via emulator proxy port [$proxy_port] succeeded." - else - echo "Web app call via emulator proxy port [$proxy_port] failed." - fi - else - echo "Failed to retrieve LocalStack proxy port" - fi - - if [ -n "$container_ip" ]; then - # Call the web app via the container IP address - echo "Calling web app [$web_app_name] via container IP address [$container_ip]..." - curl -s "http://$container_ip/" 1> /dev/null - - if [ $? == 0 ]; then - echo "Web app call via container IP address [$container_ip] succeeded." - else - echo "Web app call via container IP address [$container_ip] failed." - fi - else - echo "Failed to retrieve container IP address" - fi - - if [ -n "$host_port" ]; then - # Call the web app via the host port - echo "Calling web app [$web_app_name] via host port [$host_port]..." - curl -s "http://127.0.0.1:$host_port/" 1> /dev/null - - if [ $? == 0 ]; then - echo "Web app call via host port [$host_port] succeeded." - else - echo "Web app call via host port [$host_port] failed." - fi - else - echo "Failed to retrieve host port" - fi - - gateway_port=4566 - - if [ -n "$gateway_port" ]; then - # Call the web app via the runtime gateway - echo "Calling web app [$web_app_name] via runtime gateway on port [$gateway_port]..." - curl -s "http://${web_app_name}website.localhost.localstack.cloud:$gateway_port/" 1> /dev/null - - if [ $? == 0 ]; then - echo "Web app call via runtime gateway on port [$gateway_port] succeeded." - else - echo "Web app call via runtime gateway on port [$gateway_port] failed." - fi - else - echo "Failed to retrieve runtime gateway port" - fi -} - -call_web_app -``` +4. **Via the default hostname**: Call the web app via the default hostname `.azurewebsites.azure.localhost.localstack.cloud:4566`. ## MongoDB Tooling diff --git a/samples/web-app-cosmosdb-mongodb-api/python/scripts/call-web-app.sh b/samples/web-app-cosmosdb-mongodb-api/python/scripts/call-web-app.sh index c45a3bd..5f79052 100755 --- a/samples/web-app-cosmosdb-mongodb-api/python/scripts/call-web-app.sh +++ b/samples/web-app-cosmosdb-mongodb-api/python/scripts/call-web-app.sh @@ -181,20 +181,18 @@ call_web_app() { echo "Failed to retrieve host port" fi - gateway_port=4566 - - if [ -n "$gateway_port" ]; then - # Call the web app via the runtime gateway - echo "Calling web app [$web_app_name] via runtime gateway on port [$gateway_port]..." - curl -s "http://${web_app_name}website.localhost.localstack.cloud:$gateway_port/" 1> /dev/null + if [ -n "$app_host_name" ]; then + # Call the web app via the default hostname + echo "Calling web app [$web_app_name] via default hostname [$app_host_name]..." + curl -s "http://$app_host_name/" 1> /dev/null if [ $? == 0 ]; then - echo "Web app call via runtime gateway on port [$gateway_port] succeeded." + echo "Web app call via default hostname [$app_host_name] succeeded." else - echo "Web app call via runtime gateway on port [$gateway_port] failed." + echo "Web app call via default hostname [$app_host_name] failed." fi else - echo "Failed to retrieve runtime gateway port" + echo "Failed to retrieve web app hostname" fi } diff --git a/samples/web-app-cosmosdb-nosql-api/python/README.md b/samples/web-app-cosmosdb-nosql-api/python/README.md index bd25834..a5c11b5 100644 --- a/samples/web-app-cosmosdb-nosql-api/python/README.md +++ b/samples/web-app-cosmosdb-nosql-api/python/README.md @@ -61,211 +61,7 @@ You can use the `call-web-app.sh` Bash script below to call the web app. The scr 1. **Through the LocalStack for Azure emulator**: Call the web app via the emulator using its default host name. The emulator acts as a proxy to the web app. 2. **Via localhost and host port mapped to the container's port**: Use `127.0.0.1` with the host port mapped to the container's port `80`. 3. **Via container IP address**: Use the app container's IP address on port `80`. This technique is only available when accessing the web app from the Docker host machine. -4. **Via Runtime Gateway**: Use the `{web_app_name}website.localhost.localstack.cloud:4566` URL to call the web app via the LocalStack runtime gateway. - -```bash -#!/bin/bash - -get_docker_container_name_by_prefix() { - local app_prefix="$1" - local container_name - - # Check if Docker is running - if ! docker info >/dev/null 2>&1; then - echo "Error: Docker is not running" >&2 - return 1 - fi - - echo "Looking for containers with names starting with [$app_prefix]..." >&2 - - # Find the container using grep - container_name=$(docker ps --format "{{.Names}}" | grep "^${app_prefix}" | head -1) - - if [ -z "$container_name" ]; then - echo "Error: No running container found with name starting with [$app_prefix]" >&2 - return 1 - fi - - echo "Found matching container [$container_name]" >&2 - echo "$container_name" -} - -get_docker_container_ip_address_by_name() { - local container_name="$1" - local ip_address - - if [ -z "$container_name" ]; then - echo "Error: Container name is required" >&2 - return 1 - fi - - # Get IP address - ip_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$container_name") - - if [ -z "$ip_address" ]; then - echo "Error: Container [$container_name] has no IP address assigned" >&2 - return 1 - fi - - echo "$ip_address" -} - -get_docker_container_port_mapping() { - local container_name="$1" - local container_port="$2" - local host_port - - if [ -z "$container_name" ] || [ -z "$container_port" ]; then - echo "Error: Container name and container port are required" >&2 - return 1 - fi - - # Get host port mapping - host_port=$(docker inspect -f "{{(index (index .NetworkSettings.Ports \"${container_port}/tcp\") 0).HostPort}}" "$container_name") - - if [ -z "$host_port" ]; then - echo "Error: No host port mapping found for container [$container_name] port [$container_port]" >&2 - return 1 - fi - - echo "$host_port" -} - -call_web_app() { - # Get the web app name - echo "Getting web app name..." - web_app_name=$(azlocal webapp list --query '[0].name' --output tsv) - - if [ -n "$web_app_name" ]; then - echo "Web app [$web_app_name] successfully retrieved." - else - echo "Error: No web app found" - exit 1 - fi - - # 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) - - if [ -n "$resource_group_name" ]; then - echo "Resource group [$resource_group_name] successfully retrieved." - else - echo "Error: No resource group found for web app [$web_app_name]" - exit 1 - fi - - # 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 \ - --name "$web_app_name" \ - --resource-group "$resource_group_name" \ - --query 'defaultHostName' \ - --output tsv) - - if [ -n "$app_host_name" ]; then - echo "Web app default host name [$app_host_name] successfully retrieved." - else - echo "Error: No web app default host name found" - exit 1 - fi - - # Get the Docker container name - echo "Finding container name with prefix [ls-$web_app_name]..." - container_name=$(get_docker_container_name_by_prefix "ls-$web_app_name") - - if [ $? -eq 0 ] && [ -n "$container_name" ]; then - echo "Container [$container_name] found successfully" - else - echo "Failed to get container name" - exit 1 - fi - - # Get the container IP address - echo "Getting IP address for container [$container_name]..." - container_ip=$(get_docker_container_ip_address_by_name "$container_name") - - if [ $? -eq 0 ] && [ -n "$container_ip" ]; then - echo "IP address [$container_ip] retrieved successfully for container [$container_name]" - else - echo "Failed to get container IP address" - exit 1 - fi - - # Get the mapped host port for web app HTTP trigger (internal port 80) - echo "Getting the host port mapped to internal port 80 in container [$container_name]..." - host_port=$(get_docker_container_port_mapping "$container_name" "80") - - if [ $? -eq 0 ] && [ -n "$host_port" ]; then - echo "Mapped host port [$host_port] retrieved successfully for container [$container_name]" - else - echo "Failed to get mapped host port for container [$container_name]" - exit 1 - fi - - # Retrieve LocalStack proxy port - proxy_port=$(curl http://localhost:4566/_localstack/proxy -s | jq '.proxy_port') - - if [ -n "$proxy_port" ]; then - # Call the web app via emulator proxy - echo "Calling web app [$web_app_name] via emulator..." - curl --proxy "http://localhost:$proxy_port/" -s "http://$app_host_name/" 1> /dev/null - - if [ $? == 0 ]; then - echo "Web app call via emulator proxy port [$proxy_port] succeeded." - else - echo "Web app call via emulator proxy port [$proxy_port] failed." - fi - else - echo "Failed to retrieve LocalStack proxy port" - fi - - if [ -n "$container_ip" ]; then - # Call the web app via the container IP address - echo "Calling web app [$web_app_name] via container IP address [$container_ip]..." - curl -s "http://$container_ip/" 1> /dev/null - - if [ $? == 0 ]; then - echo "Web app call via container IP address [$container_ip] succeeded." - else - echo "Web app call via container IP address [$container_ip] failed." - fi - else - echo "Failed to retrieve container IP address" - fi - - if [ -n "$host_port" ]; then - # Call the web app via the host port - echo "Calling web app [$web_app_name] via host port [$host_port]..." - curl -s "http://127.0.0.1:$host_port/" 1> /dev/null - - if [ $? == 0 ]; then - echo "Web app call via host port [$host_port] succeeded." - else - echo "Web app call via host port [$host_port] failed." - fi - else - echo "Failed to retrieve host port" - fi - - gateway_port=4566 - - if [ -n "$gateway_port" ]; then - # Call the web app via the runtime gateway - echo "Calling web app [$web_app_name] via runtime gateway on port [$gateway_port]..." - curl -s "http://${web_app_name}website.localhost.localstack.cloud:$gateway_port/" 1> /dev/null - - if [ $? == 0 ]; then - echo "Web app call via runtime gateway on port [$gateway_port] succeeded." - else - echo "Web app call via runtime gateway on port [$gateway_port] failed." - fi - else - echo "Failed to retrieve runtime gateway port" - fi -} - -call_web_app -``` +4. **Via the default hostname**: Call the web app via the default hostname `.azurewebsites.azure.localhost.localstack.cloud:4566`. ## CosmosDB Tooling diff --git a/samples/web-app-cosmosdb-nosql-api/python/scripts/call-web-app.sh b/samples/web-app-cosmosdb-nosql-api/python/scripts/call-web-app.sh index c45a3bd..5f79052 100755 --- a/samples/web-app-cosmosdb-nosql-api/python/scripts/call-web-app.sh +++ b/samples/web-app-cosmosdb-nosql-api/python/scripts/call-web-app.sh @@ -181,20 +181,18 @@ call_web_app() { echo "Failed to retrieve host port" fi - gateway_port=4566 - - if [ -n "$gateway_port" ]; then - # Call the web app via the runtime gateway - echo "Calling web app [$web_app_name] via runtime gateway on port [$gateway_port]..." - curl -s "http://${web_app_name}website.localhost.localstack.cloud:$gateway_port/" 1> /dev/null + if [ -n "$app_host_name" ]; then + # Call the web app via the default hostname + echo "Calling web app [$web_app_name] via default hostname [$app_host_name]..." + curl -s "http://$app_host_name/" 1> /dev/null if [ $? == 0 ]; then - echo "Web app call via runtime gateway on port [$gateway_port] succeeded." + echo "Web app call via default hostname [$app_host_name] succeeded." else - echo "Web app call via runtime gateway on port [$gateway_port] failed." + echo "Web app call via default hostname [$app_host_name] failed." fi else - echo "Failed to retrieve runtime gateway port" + echo "Failed to retrieve web app hostname" fi } diff --git a/samples/web-app-managed-identity/python/README.md b/samples/web-app-managed-identity/python/README.md index 3b0d85b..f905992 100644 --- a/samples/web-app-managed-identity/python/README.md +++ b/samples/web-app-managed-identity/python/README.md @@ -93,211 +93,7 @@ You can use the `call-web-app.sh` Bash script below to call the web app. The scr 1. **Through the LocalStack for Azure emulator**: Call the web app via the emulator using its default host name. The emulator acts as a proxy to the web app. 2. **Via localhost and host port mapped to the container's port**: Use `127.0.0.1` with the host port mapped to the container's port `80`. 3. **Via container IP address**: Use the app container's IP address on port `80`. This technique is only available when accessing the web app from the Docker host machine. -4. **Via Runtime Gateway**: Use the `{web_app_name}website.localhost.localstack.cloud:4566` URL to call the web app via the LocalStack runtime gateway. - -```bash -#!/bin/bash - -get_docker_container_name_by_prefix() { - local app_prefix="$1" - local container_name - - # Check if Docker is running - if ! docker info >/dev/null 2>&1; then - echo "Error: Docker is not running" >&2 - return 1 - fi - - echo "Looking for containers with names starting with [$app_prefix]..." >&2 - - # Find the container using grep - container_name=$(docker ps --format "{{.Names}}" | grep "^${app_prefix}" | head -1) - - if [ -z "$container_name" ]; then - echo "Error: No running container found with name starting with [$app_prefix]" >&2 - return 1 - fi - - echo "Found matching container [$container_name]" >&2 - echo "$container_name" -} - -get_docker_container_ip_address_by_name() { - local container_name="$1" - local ip_address - - if [ -z "$container_name" ]; then - echo "Error: Container name is required" >&2 - return 1 - fi - - # Get IP address - ip_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$container_name") - - if [ -z "$ip_address" ]; then - echo "Error: Container [$container_name] has no IP address assigned" >&2 - return 1 - fi - - echo "$ip_address" -} - -get_docker_container_port_mapping() { - local container_name="$1" - local container_port="$2" - local host_port - - if [ -z "$container_name" ] || [ -z "$container_port" ]; then - echo "Error: Container name and container port are required" >&2 - return 1 - fi - - # Get host port mapping - host_port=$(docker inspect -f "{{(index (index .NetworkSettings.Ports \"${container_port}/tcp\") 0).HostPort}}" "$container_name") - - if [ -z "$host_port" ]; then - echo "Error: No host port mapping found for container [$container_name] port [$container_port]" >&2 - return 1 - fi - - echo "$host_port" -} - -call_web_app() { - # Get the web app name - echo "Getting web app name..." - web_app_name=$(azlocal webapp list --query '[0].name' --output tsv) - - if [ -n "$web_app_name" ]; then - echo "Web app [$web_app_name] successfully retrieved." - else - echo "Error: No web app found" - exit 1 - fi - - # 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) - - if [ -n "$resource_group_name" ]; then - echo "Resource group [$resource_group_name] successfully retrieved." - else - echo "Error: No resource group found for web app [$web_app_name]" - exit 1 - fi - - # 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 \ - --name "$web_app_name" \ - --resource-group "$resource_group_name" \ - --query 'defaultHostName' \ - --output tsv) - - if [ -n "$app_host_name" ]; then - echo "Web app default host name [$app_host_name] successfully retrieved." - else - echo "Error: No web app default host name found" - exit 1 - fi - - # Get the Docker container name - echo "Finding container name with prefix [ls-$web_app_name]..." - container_name=$(get_docker_container_name_by_prefix "ls-$web_app_name") - - if [ $? -eq 0 ] && [ -n "$container_name" ]; then - echo "Container [$container_name] found successfully" - else - echo "Failed to get container name" - exit 1 - fi - - # Get the container IP address - echo "Getting IP address for container [$container_name]..." - container_ip=$(get_docker_container_ip_address_by_name "$container_name") - - if [ $? -eq 0 ] && [ -n "$container_ip" ]; then - echo "IP address [$container_ip] retrieved successfully for container [$container_name]" - else - echo "Failed to get container IP address" - exit 1 - fi - - # Get the mapped host port for web app HTTP trigger (internal port 80) - echo "Getting the host port mapped to internal port 80 in container [$container_name]..." - host_port=$(get_docker_container_port_mapping "$container_name" "80") - - if [ $? -eq 0 ] && [ -n "$host_port" ]; then - echo "Mapped host port [$host_port] retrieved successfully for container [$container_name]" - else - echo "Failed to get mapped host port for container [$container_name]" - exit 1 - fi - - # Retrieve LocalStack proxy port - proxy_port=$(curl http://localhost:4566/_localstack/proxy -s | jq '.proxy_port') - - if [ -n "$proxy_port" ]; then - # Call the web app via emulator proxy - echo "Calling web app [$web_app_name] via emulator..." - curl --proxy "http://localhost:$proxy_port/" -s "http://$app_host_name/" 1> /dev/null - - if [ $? == 0 ]; then - echo "Web app call via emulator proxy port [$proxy_port] succeeded." - else - echo "Web app call via emulator proxy port [$proxy_port] failed." - fi - else - echo "Failed to retrieve LocalStack proxy port" - fi - - if [ -n "$container_ip" ]; then - # Call the web app via the container IP address - echo "Calling web app [$web_app_name] via container IP address [$container_ip]..." - curl -s "http://$container_ip/" 1> /dev/null - - if [ $? == 0 ]; then - echo "Web app call via container IP address [$container_ip] succeeded." - else - echo "Web app call via container IP address [$container_ip] failed." - fi - else - echo "Failed to retrieve container IP address" - fi - - if [ -n "$host_port" ]; then - # Call the web app via the host port - echo "Calling web app [$web_app_name] via host port [$host_port]..." - curl -s "http://127.0.0.1:$host_port/" 1> /dev/null - - if [ $? == 0 ]; then - echo "Web app call via host port [$host_port] succeeded." - else - echo "Web app call via host port [$host_port] failed." - fi - else - echo "Failed to retrieve host port" - fi - - gateway_port=4566 - - if [ -n "$gateway_port" ]; then - # Call the web app via the runtime gateway - echo "Calling web app [$web_app_name] via runtime gateway on port [$gateway_port]..." - curl -s "http://${web_app_name}website.localhost.localstack.cloud:$gateway_port/" 1> /dev/null - - if [ $? == 0 ]; then - echo "Web app call via runtime gateway on port [$gateway_port] succeeded." - else - echo "Web app call via runtime gateway on port [$gateway_port] failed." - fi - else - echo "Failed to retrieve runtime gateway port" - fi -} - -call_web_app -``` +4. **Via the default hostname**: Call the web app via the default hostname `.azurewebsites.azure.localhost.localstack.cloud:4566`. ## Storage Contents diff --git a/samples/web-app-managed-identity/python/scripts/call-web-app.sh b/samples/web-app-managed-identity/python/scripts/call-web-app.sh index c45a3bd..5f79052 100644 --- a/samples/web-app-managed-identity/python/scripts/call-web-app.sh +++ b/samples/web-app-managed-identity/python/scripts/call-web-app.sh @@ -181,20 +181,18 @@ call_web_app() { echo "Failed to retrieve host port" fi - gateway_port=4566 - - if [ -n "$gateway_port" ]; then - # Call the web app via the runtime gateway - echo "Calling web app [$web_app_name] via runtime gateway on port [$gateway_port]..." - curl -s "http://${web_app_name}website.localhost.localstack.cloud:$gateway_port/" 1> /dev/null + if [ -n "$app_host_name" ]; then + # Call the web app via the default hostname + echo "Calling web app [$web_app_name] via default hostname [$app_host_name]..." + curl -s "http://$app_host_name/" 1> /dev/null if [ $? == 0 ]; then - echo "Web app call via runtime gateway on port [$gateway_port] succeeded." + echo "Web app call via default hostname [$app_host_name] succeeded." else - echo "Web app call via runtime gateway on port [$gateway_port] failed." + echo "Web app call via default hostname [$app_host_name] failed." fi else - echo "Failed to retrieve runtime gateway port" + echo "Failed to retrieve web app hostname" fi } diff --git a/samples/web-app-sql-database/python/README.md b/samples/web-app-sql-database/python/README.md index 950a8cb..363d83d 100644 --- a/samples/web-app-sql-database/python/README.md +++ b/samples/web-app-sql-database/python/README.md @@ -96,211 +96,7 @@ You can use the `call-web-app.sh` Bash script below to call the web app. The scr 1. **Through the LocalStack for Azure emulator**: Call the web app via the emulator using its default host name. The emulator acts as a proxy to the web app. 2. **Via localhost and host port mapped to the container's port**: Use `127.0.0.1` with the host port mapped to the container's port `80`. 3. **Via container IP address**: Use the app container's IP address on port `80`. This technique is only available when accessing the web app from the Docker host machine. -4. **Via Runtime Gateway**: Use the `{web_app_name}website.localhost.localstack.cloud:4566` URL to call the web app via the LocalStack runtime gateway. - -```bash -#!/bin/bash - -get_docker_container_name_by_prefix() { - local app_prefix="$1" - local container_name - - # Check if Docker is running - if ! docker info >/dev/null 2>&1; then - echo "Error: Docker is not running" >&2 - return 1 - fi - - echo "Looking for containers with names starting with [$app_prefix]..." >&2 - - # Find the container using grep - container_name=$(docker ps --format "{{.Names}}" | grep "^${app_prefix}" | head -1) - - if [ -z "$container_name" ]; then - echo "Error: No running container found with name starting with [$app_prefix]" >&2 - return 1 - fi - - echo "Found matching container [$container_name]" >&2 - echo "$container_name" -} - -get_docker_container_ip_address_by_name() { - local container_name="$1" - local ip_address - - if [ -z "$container_name" ]; then - echo "Error: Container name is required" >&2 - return 1 - fi - - # Get IP address - ip_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$container_name") - - if [ -z "$ip_address" ]; then - echo "Error: Container [$container_name] has no IP address assigned" >&2 - return 1 - fi - - echo "$ip_address" -} - -get_docker_container_port_mapping() { - local container_name="$1" - local container_port="$2" - local host_port - - if [ -z "$container_name" ] || [ -z "$container_port" ]; then - echo "Error: Container name and container port are required" >&2 - return 1 - fi - - # Get host port mapping - host_port=$(docker inspect -f "{{(index (index .NetworkSettings.Ports \"${container_port}/tcp\") 0).HostPort}}" "$container_name") - - if [ -z "$host_port" ]; then - echo "Error: No host port mapping found for container [$container_name] port [$container_port]" >&2 - return 1 - fi - - echo "$host_port" -} - -call_web_app() { - # Get the web app name - echo "Getting web app name..." - web_app_name=$(azlocal webapp list --query '[0].name' --output tsv) - - if [ -n "$web_app_name" ]; then - echo "Web app [$web_app_name] successfully retrieved." - else - echo "Error: No web app found" - exit 1 - fi - - # 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) - - if [ -n "$resource_group_name" ]; then - echo "Resource group [$resource_group_name] successfully retrieved." - else - echo "Error: No resource group found for web app [$web_app_name]" - exit 1 - fi - - # 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 \ - --name "$web_app_name" \ - --resource-group "$resource_group_name" \ - --query 'defaultHostName' \ - --output tsv) - - if [ -n "$app_host_name" ]; then - echo "Web app default host name [$app_host_name] successfully retrieved." - else - echo "Error: No web app default host name found" - exit 1 - fi - - # Get the Docker container name - echo "Finding container name with prefix [ls-$web_app_name]..." - container_name=$(get_docker_container_name_by_prefix "ls-$web_app_name") - - if [ $? -eq 0 ] && [ -n "$container_name" ]; then - echo "Container [$container_name] found successfully" - else - echo "Failed to get container name" - exit 1 - fi - - # Get the container IP address - echo "Getting IP address for container [$container_name]..." - container_ip=$(get_docker_container_ip_address_by_name "$container_name") - - if [ $? -eq 0 ] && [ -n "$container_ip" ]; then - echo "IP address [$container_ip] retrieved successfully for container [$container_name]" - else - echo "Failed to get container IP address" - exit 1 - fi - - # Get the mapped host port for web app HTTP trigger (internal port 80) - echo "Getting the host port mapped to internal port 80 in container [$container_name]..." - host_port=$(get_docker_container_port_mapping "$container_name" "80") - - if [ $? -eq 0 ] && [ -n "$host_port" ]; then - echo "Mapped host port [$host_port] retrieved successfully for container [$container_name]" - else - echo "Failed to get mapped host port for container [$container_name]" - exit 1 - fi - - # Retrieve LocalStack proxy port - proxy_port=$(curl http://localhost:4566/_localstack/proxy -s | jq '.proxy_port') - - if [ -n "$proxy_port" ]; then - # Call the web app via emulator proxy - echo "Calling web app [$web_app_name] via emulator..." - curl --proxy "http://localhost:$proxy_port/" -s "http://$app_host_name/" 1> /dev/null - - if [ $? == 0 ]; then - echo "Web app call via emulator proxy port [$proxy_port] succeeded." - else - echo "Web app call via emulator proxy port [$proxy_port] failed." - fi - else - echo "Failed to retrieve LocalStack proxy port" - fi - - if [ -n "$container_ip" ]; then - # Call the web app via the container IP address - echo "Calling web app [$web_app_name] via container IP address [$container_ip]..." - curl -s "http://$container_ip/" 1> /dev/null - - if [ $? == 0 ]; then - echo "Web app call via container IP address [$container_ip] succeeded." - else - echo "Web app call via container IP address [$container_ip] failed." - fi - else - echo "Failed to retrieve container IP address" - fi - - if [ -n "$host_port" ]; then - # Call the web app via the host port - echo "Calling web app [$web_app_name] via host port [$host_port]..." - curl -s "http://127.0.0.1:$host_port/" 1> /dev/null - - if [ $? == 0 ]; then - echo "Web app call via host port [$host_port] succeeded." - else - echo "Web app call via host port [$host_port] failed." - fi - else - echo "Failed to retrieve host port" - fi - - gateway_port=4566 - - if [ -n "$gateway_port" ]; then - # Call the web app via the runtime gateway - echo "Calling web app [$web_app_name] via runtime gateway on port [$gateway_port]..." - curl -s "http://${web_app_name}website.localhost.localstack.cloud:$gateway_port/" 1> /dev/null - - if [ $? == 0 ]; then - echo "Web app call via runtime gateway on port [$gateway_port] succeeded." - else - echo "Web app call via runtime gateway on port [$gateway_port] failed." - fi - else - echo "Failed to retrieve runtime gateway port" - fi -} - -call_web_app -``` +4. **Via the default hostname**: Call the web app via the default hostname `.azurewebsites.azure.localhost.localstack.cloud:4566`. ## SQL Server Tooling diff --git a/samples/web-app-sql-database/python/scripts/deploy.sh b/samples/web-app-sql-database/python/scripts/deploy.sh index efa87d0..ff33750 100755 --- a/samples/web-app-sql-database/python/scripts/deploy.sh +++ b/samples/web-app-sql-database/python/scripts/deploy.sh @@ -1,7 +1,7 @@ #!/bin/bash # Variables -PREFIX='local' +PREFIX='babo' SUFFIX='test' LOCATION='westeurope' RESOURCE_GROUP_NAME="${PREFIX}-rg" diff --git a/samples/web-app-sql-database/python/scripts/get-web-app-url.sh b/samples/web-app-sql-database/python/scripts/get-web-app-url.sh index 035929d..315ef7e 100755 --- a/samples/web-app-sql-database/python/scripts/get-web-app-url.sh +++ b/samples/web-app-sql-database/python/scripts/get-web-app-url.sh @@ -181,6 +181,20 @@ call_web_app() { echo "Failed to retrieve host port" fi + if [ -n "$app_host_name" ]; then + # Call the web app via the default hostname + echo "Calling web app [$web_app_name] via default hostname [$app_host_name]..." + curl -s "http://$app_host_name/" 1> /dev/null + + if [ $? == 0 ]; then + echo "Web app call via default hostname [$app_host_name] succeeded." + else + echo "Web app call via default hostname [$app_host_name] failed." + fi + else + echo "Failed to retrieve web app hostname" + fi + echo "Validating certificate from Key Vault..." KV_RESPONSE=$(curl -sk "https://$container_ip:8443/api/certificate") KV_THUMBPRINT=$(echo "$KV_RESPONSE" | jq -r '.thumbprint') From 8b1f07c7fb2ed4591381ade1ec28f041a14fe8fc Mon Sep 17 00:00:00 2001 From: Paolo Salvatori Date: Tue, 14 Apr 2026 17:05:14 +0200 Subject: [PATCH 9/9] Fixed resource group name --- samples/function-app-service-bus/dotnet/scripts/deploy.sh | 2 +- samples/web-app-sql-database/python/scripts/deploy.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/function-app-service-bus/dotnet/scripts/deploy.sh b/samples/function-app-service-bus/dotnet/scripts/deploy.sh index cc47c8f..91a51fe 100755 --- a/samples/function-app-service-bus/dotnet/scripts/deploy.sh +++ b/samples/function-app-service-bus/dotnet/scripts/deploy.sh @@ -1,6 +1,6 @@ #!/bin/bash -PREFIX='babo' +PREFIX='local' SUFFIX='test' LOCATION='westeurope' RESOURCE_GROUP_NAME="${PREFIX}-rg" diff --git a/samples/web-app-sql-database/python/scripts/deploy.sh b/samples/web-app-sql-database/python/scripts/deploy.sh index ff33750..efa87d0 100755 --- a/samples/web-app-sql-database/python/scripts/deploy.sh +++ b/samples/web-app-sql-database/python/scripts/deploy.sh @@ -1,7 +1,7 @@ #!/bin/bash # Variables -PREFIX='babo' +PREFIX='local' SUFFIX='test' LOCATION='westeurope' RESOURCE_GROUP_NAME="${PREFIX}-rg"