Skip to content

Latest commit

 

History

History
167 lines (121 loc) · 6.97 KB

File metadata and controls

167 lines (121 loc) · 6.97 KB

Bicep Deployment

This directory contains the main.bicep Bicep module and deploy.sh deployment script for creating an Azure Functions application with supporting Azure services. The deployment creates a complete gaming scoreboard system using Azure Storage Account, App Service Plan, and Azure Functions with Infrastructure as Code (IaC) using Azure Bicep. For more information, see Azure Functions Sample with LocalStack for Azure.

Prerequisites

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
  • Bicep extension: VS Code extension for Bicep language support and IntelliSense
  • .NET SDK: Required for building and publishing the C# Azure Functions application
  • 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)
  • jq: JSON processor for scripting and parsing command outputs

Installing lstk CLI

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/lstk

or npm:

npm install -g @localstack/lstk

Alternatively, download a pre-built binary from the lstk releases page. For more information, see the lstk CLI documentation and the lstk GitHub repository.

Architecture Overview

The deploy.sh script creates the Azure Resource Group for all the Azure resources, while the main.bicep Bicep module creates the following Azure resources:

  1. Azure Storage Account: Provides blob containers, queues, and tables for the gaming system
    • StorageV2 kind with Hot access tier
    • Provides blob containers, queues, and tables for the sample application
  2. Azure App Service Plan: Hosting plan for the Azure Functions application
    • Linux-based hosting plan for containerized workloads
    • Standard sku
  3. Azure Linux Function App Serverless compute platform hosting the gaming logic with consumption plan
    • Linux Function App with .NET isolated runtime
    • Comprehensive application settings for gaming system configuration

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.

Provisioning Scripts

See deploy.sh for the complete deployment automation script. The script performs:

  • Creates the resource group if it doesn't exist
  • Optionally validates the Bicep template
  • Optionally runs what-if deployment for preview
  • Deploys themain.bicep template with parameters from main.bicepparam
  • Extracts deployment outputs (Function App name, Storage Account details)
  • Builds and publishes the .NET application
  • Creates a zip package and deploys to the Function App

Deployment

  1. 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
  2. Start the LocalStack Azure emulator with the lstk CLI:

    export LOCALSTACK_AUTH_TOKEN=<your_auth_token>
    lstk start --type azure
  3. Navigate to the scripts directory

    cd samples/function-app-storage-http/dotnet/bicep
  4. Make the script executable:

    chmod +x deploy.sh
  5. Run the deployment script:

    ./deploy.sh

Validation

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-errors

Cleanup

To 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 table

This will remove all Azure resources created by the CLI deployment script.

Related Documentation