diff --git a/README.md b/README.md
index 1b80ab1c..32804949 100644
--- a/README.md
+++ b/README.md
@@ -38,6 +38,7 @@ Each sample is a self-contained project with its own README, Azure CLI scripts a
| Function App with Service Bus ([.NET](./samples/function-app-service-bus/dotnet/README.md)) | An Azure Functions app on an App Service plan that exchanges messages through Service Bus queues: an HTTP trigger sends greetings and a queue trigger consumes them, connecting with either a connection string or a managed identity. |
| Web App with Cosmos DB for MongoDB API ([Python](./samples/web-app-cosmosdb-mongodb-api/python/README.md), [.NET](./samples/web-app-cosmosdb-mongodb-api/dotnet/README.md)) | The *Vacation Planner* single-page web app on an Azure Web App with regional VNet integration, storing activities in the `activities` collection of an Azure Cosmos DB for MongoDB account reached through a private endpoint. |
| Web App with CosmosDB for NoSQL API ([Python](./samples/web-app-cosmosdb-nosql-api/python/README.md), [.NET](./samples/web-app-cosmosdb-nosql-api/dotnet/README.md)) | The *Vacation Planner* single-page web app on an Azure Web App, storing activities as JSON items in the `activities` container of an Azure Cosmos DB for NoSQL database partitioned by user, and reaching the account with its key or with a system-assigned or user-assigned managed identity through Microsoft Entra ID; deployed with Azure CLI scripts, Bicep or Terraform. |
+| Web App with Azure Managed Redis ([Python](./samples/web-app-managed-redis/python/README.md), [.NET](./samples/web-app-managed-redis/dotnet/README.md)) | The *Vacation Planner* single-page web app on an Azure Web App, storing activities as the fields of a Redis hash in the `default` database of an Azure Managed Redis cluster over TLS, and reaching it with its access key or with a system-assigned or user-assigned managed identity through Microsoft Entra ID and the database's `default` access policy; deployed with Azure CLI scripts, Bicep or Terraform. |
| Web App with Managed Identities ([Python](./samples/web-app-managed-identity/python/README.md), [.NET](./samples/web-app-managed-identity/dotnet/README.md)) | The *Vacation Planner* single-page web app on an Azure Web App, storing each activity as a blob in an `activities` container and accessing Blob Storage through a user-assigned or system-assigned managed identity rather than connection strings. |
| Web App with SQL Database ([Python](./samples/web-app-sql-database/python/README.md), [.NET](./samples/web-app-sql-database/dotnet/README.md)) | The *Vacation Planner* single-page web app on an Azure Web App, storing activities in an Azure SQL Database. The connection string and the HTTPS certificate are read from Azure Key Vault, and an API endpoint verifies the Key Vault certificate. |
| Web App with PostgreSQL Database ([Python](./samples/web-app-postgresql-flexible-server/python/README.md), [.NET](./samples/web-app-postgresql-flexible-server/dotnet/README.md)) | The *Vacation Planner* single-page web app on an Azure Web App, storing activities in an Azure Database for PostgreSQL flexible server injected into a virtual network (delegated subnet and private DNS zone), with the database and application user created by the deploy scripts. |
diff --git a/run-samples.sh b/run-samples.sh
index 9def2a59..f6e136f7 100755
--- a/run-samples.sh
+++ b/run-samples.sh
@@ -46,6 +46,12 @@ SAMPLES=(
"samples/web-app-cosmosdb-nosql-api/python|MANAGED_IDENTITY_TYPE=UserAssigned bash scripts/deploy.sh|MANAGED_IDENTITY_TYPE=UserAssigned bash scripts/validate.sh"
"samples/web-app-cosmosdb-nosql-api/dotnet|MANAGED_IDENTITY_TYPE=SystemAssigned bash scripts/deploy.sh|MANAGED_IDENTITY_TYPE=SystemAssigned bash scripts/validate.sh"
"samples/web-app-cosmosdb-nosql-api/dotnet|MANAGED_IDENTITY_TYPE=UserAssigned bash scripts/deploy.sh|MANAGED_IDENTITY_TYPE=UserAssigned bash scripts/validate.sh"
+ "samples/web-app-managed-redis/python|bash scripts/deploy.sh|bash scripts/validate.sh && bash scripts/call-web-app.sh && bash scripts/query-telemetry.sh && bash scripts/query-logs-and-metrics.sh"
+ "samples/web-app-managed-redis/dotnet|bash scripts/deploy.sh|bash scripts/validate.sh && bash scripts/call-web-app.sh && bash scripts/query-telemetry.sh && bash scripts/query-logs-and-metrics.sh"
+ "samples/web-app-managed-redis/python|MANAGED_IDENTITY_TYPE=SystemAssigned bash scripts/deploy.sh|MANAGED_IDENTITY_TYPE=SystemAssigned bash scripts/validate.sh"
+ "samples/web-app-managed-redis/python|MANAGED_IDENTITY_TYPE=UserAssigned bash scripts/deploy.sh|MANAGED_IDENTITY_TYPE=UserAssigned bash scripts/validate.sh"
+ "samples/web-app-managed-redis/dotnet|MANAGED_IDENTITY_TYPE=SystemAssigned bash scripts/deploy.sh|MANAGED_IDENTITY_TYPE=SystemAssigned bash scripts/validate.sh"
+ "samples/web-app-managed-redis/dotnet|MANAGED_IDENTITY_TYPE=UserAssigned bash scripts/deploy.sh|MANAGED_IDENTITY_TYPE=UserAssigned bash scripts/validate.sh"
"samples/web-app-managed-identity/python|bash scripts/user-assigned.sh|bash scripts/validate.sh && bash scripts/call-web-app.sh && bash scripts/query-telemetry.sh && bash scripts/query-logs-and-metrics.sh"
"samples/web-app-managed-identity/dotnet|bash scripts/user-assigned.sh|bash scripts/validate.sh && bash scripts/call-web-app.sh && bash scripts/query-telemetry.sh && bash scripts/query-logs-and-metrics.sh"
"samples/web-app-sql-database/python|bash scripts/deploy.sh|bash scripts/validate.sh && bash scripts/call-web-app.sh && bash scripts/query-telemetry.sh && bash scripts/query-logs-and-metrics.sh"
@@ -82,6 +88,10 @@ TERRAFORM_SAMPLES=(
"samples/web-app-cosmosdb-nosql-api/python/terraform|MANAGED_IDENTITY_TYPE=UserAssigned bash deploy.sh|MANAGED_IDENTITY_TYPE=UserAssigned bash ../scripts/validate.sh && bash ../scripts/query-telemetry.sh && bash ../scripts/query-logs-and-metrics.sh"
"samples/web-app-cosmosdb-nosql-api/dotnet/terraform|MANAGED_IDENTITY_TYPE=SystemAssigned bash deploy.sh|MANAGED_IDENTITY_TYPE=SystemAssigned bash ../scripts/validate.sh && bash ../scripts/query-telemetry.sh && bash ../scripts/query-logs-and-metrics.sh"
"samples/web-app-cosmosdb-nosql-api/dotnet/terraform|MANAGED_IDENTITY_TYPE=UserAssigned bash deploy.sh|MANAGED_IDENTITY_TYPE=UserAssigned bash ../scripts/validate.sh && bash ../scripts/query-telemetry.sh && bash ../scripts/query-logs-and-metrics.sh"
+ "samples/web-app-managed-redis/python/terraform|MANAGED_IDENTITY_TYPE=SystemAssigned bash deploy.sh|MANAGED_IDENTITY_TYPE=SystemAssigned bash ../scripts/validate.sh && bash ../scripts/query-telemetry.sh && bash ../scripts/query-logs-and-metrics.sh"
+ "samples/web-app-managed-redis/python/terraform|MANAGED_IDENTITY_TYPE=UserAssigned bash deploy.sh|MANAGED_IDENTITY_TYPE=UserAssigned bash ../scripts/validate.sh && bash ../scripts/query-telemetry.sh && bash ../scripts/query-logs-and-metrics.sh"
+ "samples/web-app-managed-redis/dotnet/terraform|MANAGED_IDENTITY_TYPE=SystemAssigned bash deploy.sh|MANAGED_IDENTITY_TYPE=SystemAssigned bash ../scripts/validate.sh && bash ../scripts/query-telemetry.sh && bash ../scripts/query-logs-and-metrics.sh"
+ "samples/web-app-managed-redis/dotnet/terraform|MANAGED_IDENTITY_TYPE=UserAssigned bash deploy.sh|MANAGED_IDENTITY_TYPE=UserAssigned bash ../scripts/validate.sh && bash ../scripts/query-telemetry.sh && bash ../scripts/query-logs-and-metrics.sh"
"samples/web-app-managed-identity/python/terraform|bash deploy.sh|bash ../scripts/query-telemetry.sh && bash ../scripts/query-logs-and-metrics.sh"
"samples/web-app-managed-identity/dotnet/terraform|bash deploy.sh|bash ../scripts/query-telemetry.sh && bash ../scripts/query-logs-and-metrics.sh"
"samples/web-app-sql-database/python/terraform|bash deploy.sh|bash ../scripts/validate.sh && bash ../scripts/query-telemetry.sh && bash ../scripts/query-logs-and-metrics.sh"
@@ -120,6 +130,10 @@ BICEP_SAMPLES=(
"samples/web-app-cosmosdb-nosql-api/python/bicep|MANAGED_IDENTITY_TYPE=UserAssigned bash deploy.sh|MANAGED_IDENTITY_TYPE=UserAssigned bash ../scripts/validate.sh && bash ../scripts/query-telemetry.sh && bash ../scripts/query-logs-and-metrics.sh"
"samples/web-app-cosmosdb-nosql-api/dotnet/bicep|MANAGED_IDENTITY_TYPE=SystemAssigned bash deploy.sh|MANAGED_IDENTITY_TYPE=SystemAssigned bash ../scripts/validate.sh && bash ../scripts/query-telemetry.sh && bash ../scripts/query-logs-and-metrics.sh"
"samples/web-app-cosmosdb-nosql-api/dotnet/bicep|MANAGED_IDENTITY_TYPE=UserAssigned bash deploy.sh|MANAGED_IDENTITY_TYPE=UserAssigned bash ../scripts/validate.sh && bash ../scripts/query-telemetry.sh && bash ../scripts/query-logs-and-metrics.sh"
+ "samples/web-app-managed-redis/python/bicep|MANAGED_IDENTITY_TYPE=SystemAssigned bash deploy.sh|MANAGED_IDENTITY_TYPE=SystemAssigned bash ../scripts/validate.sh && bash ../scripts/query-telemetry.sh && bash ../scripts/query-logs-and-metrics.sh"
+ "samples/web-app-managed-redis/python/bicep|MANAGED_IDENTITY_TYPE=UserAssigned bash deploy.sh|MANAGED_IDENTITY_TYPE=UserAssigned bash ../scripts/validate.sh && bash ../scripts/query-telemetry.sh && bash ../scripts/query-logs-and-metrics.sh"
+ "samples/web-app-managed-redis/dotnet/bicep|MANAGED_IDENTITY_TYPE=SystemAssigned bash deploy.sh|MANAGED_IDENTITY_TYPE=SystemAssigned bash ../scripts/validate.sh && bash ../scripts/query-telemetry.sh && bash ../scripts/query-logs-and-metrics.sh"
+ "samples/web-app-managed-redis/dotnet/bicep|MANAGED_IDENTITY_TYPE=UserAssigned bash deploy.sh|MANAGED_IDENTITY_TYPE=UserAssigned bash ../scripts/validate.sh && bash ../scripts/query-telemetry.sh && bash ../scripts/query-logs-and-metrics.sh"
"samples/web-app-managed-identity/python/bicep|bash deploy.sh|bash ../scripts/query-telemetry.sh && bash ../scripts/query-logs-and-metrics.sh"
"samples/web-app-managed-identity/dotnet/bicep|bash deploy.sh|bash ../scripts/query-telemetry.sh && bash ../scripts/query-logs-and-metrics.sh"
"samples/web-app-mysql-flexible-server/python/bicep|bash deploy.sh|bash ../scripts/query-telemetry.sh && bash ../scripts/query-logs-and-metrics.sh"
@@ -193,8 +207,11 @@ ARM64_SAMPLE_DIRS=(
# Fail loudly if an entry no longer matches a registered sample: a rename would otherwise
# silently drop that sample's arm64 coverage while CI stays green.
+# The registered folders go to grep -q as a here-string, not a pipe: under pipefail the writers die of SIGPIPE
+# once grep -q has its match early in a long list, and the match reads as a failure (as in build-matrix.sh).
+_registered_dirs=$(printf '%s\n' "${ALL_SAMPLES[@]}" | cut -d'|' -f1 | sed -E 's#/(terraform|bicep)$##')
for _arm64_dir in "${ARM64_SAMPLE_DIRS[@]}"; do
- if ! printf '%s\n' "${ALL_SAMPLES[@]}" | cut -d'|' -f1 | sed -E 's#/(terraform|bicep)$##' | grep -qxF "$_arm64_dir"; then
+ if ! grep -qxF "$_arm64_dir" <<<"$_registered_dirs"; then
echo >&2 "ARM64_SAMPLE_DIRS entry '$_arm64_dir' matches no registered sample - fix the path or remove the entry."
exit 1
fi
diff --git a/samples/web-app-managed-redis/dotnet/README.md b/samples/web-app-managed-redis/dotnet/README.md
new file mode 100644
index 00000000..dd05b202
--- /dev/null
+++ b/samples/web-app-managed-redis/dotnet/README.md
@@ -0,0 +1,389 @@
+# Azure Web App with Azure Managed Redis
+
+This sample demonstrates an ASP.NET Core Razor Pages single-page web application called *Vacation Planner* hosted on an [Azure Web App](https://learn.microsoft.com/en-us/azure/app-service/overview). The app runs on an Azure App Service Plan and stores the activities of its user in a Redis hash, one field per activity, in the database of an [Azure Managed Redis](https://learn.microsoft.com/en-us/azure/redis/overview) cluster. It reaches the database with [StackExchange.Redis](https://stackexchange.github.io/StackExchange.Redis/), over TLS, with the database's access key or, passwordless, with a managed identity through Microsoft Entra ID.
+
+Every `run-samples.sh` entry of the .NET sample has been validated against the LocalStack for Azure emulator: the Azure CLI scripts with `MANAGED_IDENTITY_TYPE` set to `None`, `SystemAssigned` and `UserAssigned`, and the Bicep and Terraform deployments with `SystemAssigned` and `UserAssigned`; the sample has not been run against real Azure yet.
+
+## Architecture
+
+The following diagram illustrates the architecture of the solution:
+
+```mermaid
+%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 70}}}%%
+flowchart LR
+ client((Client))
+
+ subgraph plan["App Service plan (B1, Linux)"]
+ webapp["Web App ASP.NET Core · Vacation Planner GET / · POST / · POST /delete/{id} GET /api/activities"]
+ end
+
+ identity["Managed identity system-assigned or user-assigned"]
+ entra["Microsoft Entra ID"]
+
+ subgraph redis["Azure Managed Redis (Balanced_B0)"]
+ database[("default database TLS · EnterpriseCluster hash vacationplanner:activities:{user}")]
+ policy["Access policy assignment default policy → object id"]
+ policy -.->|"authorizes"| database
+ end
+
+ insights["Application Insights workspace-based"]
+ workspace[("Log Analytics workspace")]
+ insights -->|"stores its telemetry in"| workspace
+
+ client -->|"1: HTTPS"| webapp
+ webapp -.->|"assigned"| identity
+ identity -->|"2: token for redis.azure.com"| entra
+ webapp -->|"3: AUTH object id + token (or the access key) HSET · HGETALL · HDEL"| database
+ webapp -->|"requests · dependencies · traces custom events · custom metrics"| insights
+ webapp -. "diagnostic settings: resource logs · platform metrics" .-> workspace
+ redis -. "diagnostic settings: ConnectionEvents · AllMetrics" .-> workspace
+ plan -.-> workspace
+
+ style plan fill:#ffffff,stroke:#999999,color:#333333
+ style redis fill:#ffffff,stroke:#999999,color:#333333
+```
+
+- **Azure Web App**: Hosts the ASP.NET Core application, which serves the page of the activities and their JSON API (`/api/activities`)
+- **Azure App Service Plan**: Provides compute resources for the web app
+- **Azure Managed Redis**: A `Balanced_B0` cluster whose `default` database stores the activities. Clients connect over TLS, on the host name of the cluster and the port of the database. The database uses the `EnterpriseCluster` clustering policy, which serves every key on one endpoint, so a client that is not cluster-aware, as the app's is, reaches all of them
+- **Managed identity**: The web app authenticates to the database with Microsoft Entra ID, as a system-assigned or user-assigned managed identity that the database's `default` access policy is assigned to, instead of the access key. The Bicep and Terraform deployments always use one, the Azure CLI scripts with `MANAGED_IDENTITY_TYPE=SystemAssigned` or `UserAssigned`. See [Microsoft Entra ID authentication](#microsoft-entra-id-authentication)
+- **Azure Log Analytics workspace**: Centralizes the diagnostic logs and metrics of the web app, its plan, the Azure Managed Redis cluster and its database, the telemetry of Application Insights, and the audit records of the queries run on it
+- **Azure Application Insights**: A workspace-based resource that collects the requests, the calls to Azure Managed Redis, the log records, the exceptions, the custom events and the custom metric of the web app, which the Microsoft OpenTelemetry Distro sends to the connection string of the `APPLICATIONINSIGHTS_CONNECTION_STRING` app setting. See [Application Insights](#application-insights)
+
+## Prerequisites
+
+- [lstk CLI](https://docs.localstack.cloud/aws/developer-tools/running-localstack/lstk/)
+- [Azure Subscription](https://azure.microsoft.com/free/)
+- [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli)
+- [Terraform](https://developer.hashicorp.com/terraform/downloads), if you plan to install the sample via Terraform.
+- [.NET SDK 10.0](https://dotnet.microsoft.com/en-us/download/dotnet/10.0)
+- [ASP.NET Core](https://learn.microsoft.com/en-us/aspnet/core/)
+- [jq](https://jqlang.org/), used by the validation script
+
+> [!IMPORTANT]
+> **Macs with Apple silicon**: this sample deploys a web app from code. The emulator builds it with Microsoft's Oryx build image and runs it on an Oryx runtime image, and Microsoft publishes both for amd64 only ([microsoft/Oryx#2133](https://github.com/microsoft/Oryx/issues/2133) asks for arm64).
+> On a Mac with Apple silicon they run only under Docker Desktop's amd64 emulation: in Docker Desktop's settings, under **General**, select the **Apple Virtualization framework** as the Virtual Machine Manager and turn on **Use Rosetta for x86_64/amd64 emulation on Apple Silicon**.
+> Under QEMU, which Docker Desktop uses otherwise (Rosetta off, or Docker VMM, which has no Rosetta), the sample is not expected to work: Oryx is a .NET app, and [.NET does not support QEMU](https://github.com/dotnet/core/blob/main/release-notes/8.0/supported-os.md).
+> The sample does not run on an arm64 Linux host without amd64 emulation.
+
+## Deployment
+
+Set up the Azure emulator using the LocalStack for Azure Docker image. Before starting, ensure you have a valid `LOCALSTACK_AUTH_TOKEN` to access the Azure emulator. Refer to the [Auth Token guide](https://docs.localstack.cloud/getting-started/auth-token/) to obtain your Auth Token and set it in the `LOCALSTACK_AUTH_TOKEN` environment variable. The Azure Docker image is available on the [LocalStack Docker Hub](https://hub.docker.com/r/localstack/localstack-azure). To pull the image, execute:
+
+```bash
+docker pull localstack/localstack-azure
+```
+
+Start the LocalStack Azure emulator by running:
+
+```bash
+# Set the authentication token
+export LOCALSTACK_AUTH_TOKEN=
+
+# Start the LocalStack Azure emulator
+lstk start --type azure
+
+# Route all Azure CLI calls to the LocalStack Azure emulator
+lstk az start-interception
+```
+
+Deploy the application to LocalStack for Azure using:
+
+- [Azure CLI Deployment](./scripts/README.md)
+- [Bicep Deployment](./bicep/README.md)
+- [Terraform Deployment](./terraform/README.md)
+
+> [!NOTE]
+> When you deploy the application to LocalStack for Azure for the first time, the initialization process involves downloading and building Docker images. This is a one-time operation—subsequent deployments will be significantly faster. Depending on your internet connection and system resources, this initial setup may take several minutes.
+
+### Microsoft Entra ID authentication
+
+The web app reaches the Azure Managed Redis database either with the database's primary access key, in the `AZURE_REDIS_ACCESS_KEY` app setting, or with [Microsoft Entra ID](https://learn.microsoft.com/en-us/azure/redis/entra-for-authentication), as a managed identity that the database's built-in `default` access policy, which grants every command on every key, is assigned to, with no key anywhere. `MANAGED_IDENTITY_TYPE` picks one:
+
+| Deployment | `MANAGED_IDENTITY_TYPE` | Default |
+| --- | --- | --- |
+| [Azure CLI](./scripts/README.md) | `None` (the access key), `SystemAssigned` or `UserAssigned` | `None` |
+| [Bicep](./bicep/README.md) | `SystemAssigned` or `UserAssigned` | `UserAssigned` |
+| [Terraform](./terraform/README.md) | `SystemAssigned` or `UserAssigned` | `UserAssigned` |
+
+The three deployments give the resources the same names, so the validation script checks any of them. Pass it the same `MANAGED_IDENTITY_TYPE`:
+
+```bash
+# Azure CLI, with the web app's system-assigned identity
+MANAGED_IDENTITY_TYPE=SystemAssigned bash scripts/deploy.sh
+MANAGED_IDENTITY_TYPE=SystemAssigned bash scripts/validate.sh
+
+# Bicep, with a user-assigned identity (for Terraform, run terraform/deploy.sh)
+MANAGED_IDENTITY_TYPE=UserAssigned bash bicep/deploy.sh
+MANAGED_IDENTITY_TYPE=UserAssigned bash scripts/validate.sh
+```
+
+With a managed identity, each deployment:
+
+- gives the web app a system-assigned managed identity, or creates a user-assigned managed identity, assigns it to the web app, and passes its client id in the `AZURE_CLIENT_ID` app setting
+- assigns the database's `default` access policy to the identity's object (principal) id. It's an access policy assignment of the database itself, not an Azure RBAC role assignment: the Azure CLI scripts run `az redisenterprise database access-policy-assignment create`, the Bicep template deploys a `Microsoft.Cache/redisEnterprise/databases/accessPolicyAssignments` resource ([managed-redis-access-policy-assignment.bicep](./bicep/modules/managed-redis-access-policy-assignment.bicep)), and the Terraform configuration an `azurerm_managed_redis_access_policy_assignment` resource ([managed_redis_access_policy_assignment](./terraform/modules/managed_redis_access_policy_assignment))
+- disables access keys authentication on the database, so that nothing can authenticate with a key
+
+Without a key, the app configures its `ConnectionMultiplexer` with [Microsoft.Azure.StackExchangeRedis](https://github.com/Azure/Microsoft.Azure.StackExchangeRedis) (see [RedisActivityStore.cs](./src/Services/RedisActivityStore.cs)). It gets a token for the `https://redis.azure.com/.default` scope from `DefaultAzureCredential`, which uses the web app's managed identity, on Azure and in the emulator alike, and sends `AUTH