This folder contains Bash scripts for deploying an Azure Functions application with supporting Azure services using the azlocal CLI. The deployment creates a complete gaming scoreboard system using Azure Functions and Azure Storage Account with direct Azure CLI commands through the LocalStack Azure emulator. For more information, see Azure Functions Sample with LocalStack for Azure.
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
- .NET SDK: Required for building and publishing the C# Azure Functions application
- Docker: Container runtime required for LocalStack
- Azure CLI: Azure command-line interface
- azlocal CLI: LocalStack Azure CLI wrapper
- funclocal CLI: LocalStack Functions Core Tools wrapper
- 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.
This deploy.sh script creates the following Azure resources using Azure CLI commands:
- Azure Resource Group: Logical container for all gaming system resources.
- Azure Storage Account: Provides blob containers, queues, and tables for the gaming system.
- Azure Linux Function App Serverless compute platform hosting the gaming logic with consumption plan.
The system implements a complete gaming scoreboard with multiple Azure Functions that handle HTTP requests, process blob uploads, manage queue messages, and maintain game statistics. For more information, see Azure Functions Sample with LocalStack for Azure.
See deploy.sh for the complete deployment script. The script performs:
- Detects environment (LocalStack vs Azure Cloud) and selects appropriate CLI
- Creates resource group if it doesn't exist
- Creates Storage Account and retrieves access key
- Creates Function App with consumption plan
- Constructs storage connection string
- Configures Function App settings (storage, queue, table, timer configurations)
- Publishes the .NET application using
funclocalorfunc azure functionapp publish
-
You can set up the Azure emulator by utilizing LocalStack for Azure Docker image. Before starting, ensure you have a valid
LOCALSTACK_AUTH_TOKENto access the Azure emulator. Refer to the Auth Token guide to obtain your Auth Token and specify it in theLOCALSTACK_AUTH_TOKENenvironment 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-alpha
-
Start 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 start
-
Navigate to the scripts directory
cd samples/function-app-and-storage/dotnet/scripts -
Make the script executable:
chmod +x deploy.sh
-
Run the deployment script:
./deploy.sh
You can customize the deployment by modifying the variables at the top of deploy.sh:
# Customizable variables
PREFIX='myapp' # Change resource name prefix
SUFFIX='prod' # Change resource name suffix
LOCATION='eastus' # Change deployment region
RUNTIME="DOTNET-ISOLATED" # Runtime type
RUNTIME_VERSION="9" # Runtime versionThe script configures the following application settings for the gaming system:
| Setting | Purpose | Default Value |
|---|---|---|
AzureWebJobsStorage |
Functions runtime storage | Auto-generated connection string |
STORAGE_ACCOUNT_CONNECTION_STRING |
Application storage access | Auto-generated connection string |
INPUT_STORAGE_CONTAINER_NAME |
Blob input container | input |
OUTPUT_STORAGE_CONTAINER_NAME |
Blob output container | output |
INPUT_QUEUE_NAME |
Message input queue | input |
OUTPUT_QUEUE_NAME |
Message output queue | output |
TRIGGER_QUEUE_NAME |
Queue trigger name | trigger |
INPUT_TABLE_NAME |
Scoreboards table | scoreboards |
OUTPUT_TABLE_NAME |
Winners table | winners |
PLAYER_NAMES |
Game player list | Comma-separated names |
TIMER_SCHEDULE |
Scheduled function trigger | 0 */1 * * * * (every minute) |
FUNCTIONS_WORKER_RUNTIME |
Runtime specification | dotnet-isolated |
-
azlocal start-interception:- Redirects Azure CLI calls to LocalStack endpoints
- Enables local development without Azure subscription
- Maintains compatibility with standard Azure CLI syntax
-
funclocal azure functionapp publish:- Deploys function app to LocalStack Azure emulator
- Wraps the Azure Functions Core Tools
- Provides local testing environment for Azure Functions
-
azlocal stop-interception:- Restores normal Azure CLI behavior
- Cleans up LocalStack session state
- Returns CLI to standard Azure cloud operations
After 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 function app status
az functionapp show \
--name local-func-test \
--resource-group local-rg \
--output table
# Check storage account properties
az storage account show \
--name localstoragetest \
--resource-group local-rg \
--output table
# List storage containers
az storage container list \
--account-name localstoragetest \
--output table \
--only-show-errors
# List storage queues
az storage queue list \
--account-name localstoragetest \
--output table \
--only-show-errors
# List storage tables
az storage table list \
--account-name localstoragetest \
--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.
- Azure CLI Documentation
- Azure Functions CLI Documentation
- Azure Functions Methods Documentation - Detailed documentation of all implemented functions
- LocalStack for Azure Documentation