This directory includes Bash scripts designed for deploying and testing the sample Web App utilizing the lstk CLI. For further details about the sample application, refer to the Azure Web App with Azure CosmosDB for NoSQL API.
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
- lstk CLI: LocalStack command-line interface (proxies the Azure CLI via
lstk az) - Python: Python runtime (version 3.12 or above)
- jq: JSON processor for scripting and parsing command outputs
Deploying to LocalStack requires the lstk CLI, which routes Azure CLI commands to the emulator (run lstk az start-interception before deploying). Install it using Homebrew:
brew install localstack/tap/lstkor npm:
npm install -g @localstack/lstkAlternatively, download a pre-built binary from the lstk releases page. For more information, see the lstk CLI documentation and the lstk GitHub repository.
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-azureStart the LocalStack Azure emulator with the lstk CLI:
# Set the authentication token
export LOCALSTACK_AUTH_TOKEN=<your_auth_token>
# Start the LocalStack Azure emulator
lstk start --type azure
# Route all Azure CLI calls to the LocalStack Azure emulator
lstk az start-interceptionNavigate to the scripts folder:
cd samples/web-app-cosmosdb-nosql-api/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
PREFIX='local'
SUFFIX='test'
RESOURCE_GROUP_NAME="${PREFIX}-rg"
WEB_APP_NAME="${PREFIX}-webapp-nosql-${SUFFIX}"
APP_SERVICE_PLAN_NAME="${WEB_APP_NAME}"
COSMOSDB_ACCOUNT_NAME="${WEB_APP_NAME}"
# Check resource group
echo -e "[$RESOURCE_GROUP_NAME] resource group:\n"
az group show \
--name "$RESOURCE_GROUP_NAME" \
--output table \
--only-show-errors
# Check App Service Plan
echo -e "\n[$APP_SERVICE_PLAN_NAME] app service plan:\n"
az appservice plan show \
--resource-group "$RESOURCE_GROUP_NAME" \
--name "$APP_SERVICE_PLAN_NAME" \
--output table \
--only-show-errors
# Check Azure Web App
echo -e "\n[$WEB_APP_NAME] web app:\n"
az webapp show \
--name "$WEB_APP_NAME" \
--resource-group "$RESOURCE_GROUP_NAME" \
--query '{Name:name,State:state,Location:location,DefaultHostName:defaultHostName}' \
--output table \
--only-show-errors
# Check Azure Cosmos DB account
echo -e "\n[$COSMOSDB_ACCOUNT_NAME] cosmos db account:\n"
az cosmosdb show \
--name "$COSMOSDB_ACCOUNT_NAME" \
--resource-group "$RESOURCE_GROUP_NAME" \
--query '{Name:name,Location:location,ResourceGroup:resourceGroup,DocumentEndpoint:documentEndpoint,Kind:kind}' \
--output table \
--only-show-errors
# List resources
echo -e "\n[$RESOURCE_GROUP_NAME] all resources:\n"
az resource list \
--resource-group "$RESOURCE_GROUP_NAME" \
--output table \
--only-show-errorsTo 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.