This directory contains Azure CLI scripts for provisioning Azure Database for PostgreSQL Flexible Server resources in LocalStack for Azure. Refer to the Azure Database for PostgreSQL Flexible Server guide for details about the sample application.
Before deploying this solution, ensure you have the following tools installed:
- LocalStack for Azure: Local Azure cloud emulator for development and testing
- 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 instead of the standard Azure 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 script creates the following Azure resources:
- Azure Resource Group: Logical container for all resources.
- Azure Database for PostgreSQL Flexible Server: Managed PostgreSQL database server with version 16.
- PostgreSQL Databases: Two databases (
sampledbandanalyticsdb). - Firewall Rules: Three firewall rules for development access.
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:
export LOCALSTACK_AUTH_TOKEN=<your_auth_token>
IMAGE_NAME=localstack/localstack-azure-alpha localstack startNavigate to the scripts folder:
cd samples/postgresql-flexible-server/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:
chmod +x validate.sh
./validate.shTo destroy all created resources:
# Delete resource group and all contained resources
azlocal group delete --name rg-pgflex --yes --no-wait
# Verify deletion
azlocal group list --output tableThis will remove all Azure resources created by the CLI deployment script.