This directory includes Bash scripts designed for deploying and testing the sample Web App utilizing the azlocal CLI. For further details about the sample application, refer to the Azure Web App with Azure SQL Database.
Before deploying this solution, ensure you have the following tools installed:
- LocalStack for Azure: Local Azure cloud emulator for development and testing
- Visual Studio Code: Code editor installed on one of the supported platforms
- Docker: Container runtime required for LocalStack
- Azure CLI: Azure command-line interface
- Azlocal CLI: LocalStack Azure CLI wrapper
- Python: Python runtime (version 3.12 or above)
- jq: JSON processor for scripting and parsing command outputs
The deploy.sh Bash script uses the azlocal CLI to work with LocalStack. Install it using:
pip install azlocalFor more information, see Get started with the az tool on LocalStack.
The deploy.sh Bash script creates the following Azure resources using Azure CLI commands:
- Azure Resource Group: Logical container for all resources
- Azure SQL Server: Logical server hosting one or more Azure SQL Databases.
- Azure SQL Database: The
PlannerDBdatabase storing relational vacation activity data. - Azure App Service Plan: The compute resource that hosts the web application.
- Azure Web App: Hosts the Python Flask single-page application (Vacation Planner), connected to Azure SQL Database.
- App Service Source Control: (Optional) Configures automatic deployment from a public GitHub repository.
- Azure Key Vault: Stores the SQL connection string in a secret.
The system implements a Vacation Planner web application that stores and retrieves activity data from Azure SQL Database. For more information, see Azure Web App with Azure SQL Database.
You can set up the Azure emulator by utilizing 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 to obtain your Auth Token and specify it in the LOCALSTACK_AUTH_TOKEN environment variable. The Azure Docker image is available on the LocalStack Docker Hub. To pull the Azure Docker image, execute the following command:
docker pull localstack/localstack-azure-alphaStart the LocalStack Azure emulator using the localstack CLI, execute the following command:
# Set the authentication token
export LOCALSTACK_AUTH_TOKEN=<your_auth_token>
# 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-interceptionNavigate to the scripts folder:
cd samples/web-app-sql-database/python/scriptsMake the script executable:
chmod +x deploy.shRun the deployment script:
./deploy.shAfter deployment, you can use the validate.sh script to verify that all resources were created and configured correctly:
#!/bin/bash
# Variables
# Check resource group
az group show \
--name local-rg \
--output table
# List resources
az resource list \
--resource-group local-rg \
--output table
# Check Azure Web App
az webapp show \
--name local-webapp-test \
--resource-group local-rg \
--output table
# Check Azure SQL Server
az sql server show \
--name local-sqlserver-test \
--resource-group local-rg \
--output table
# Check Azure SQL Database
az sql db show \
--name PlannerDB \
--server local-sqlserver-test \
--resource-group local-rg \
--output tableTo destroy all created resources:
# Delete resource group and all contained resources
az group delete --name local-rg --yes --no-wait
# Verify deletion
az group list --output tableThis will remove all Azure resources created by the CLI deployment script.