Func Runner Help

Bicep File Documentation

The included Azure Bicep template automates the deployment of key Azure resources necessary for running Func Runner in a production environment. The resources include a Function App, a Storage Account, an App Service Plan, Application Insights, and a storage queue. The template is designed to facilitate easy deployment and configuration of these resources in a specified Azure region.

Parameters

The template includes several parameters that allow customization of the deployment:

  • openAiApiKey (string): The API key for accessing OpenAI services, stored as an environment variable in the Function App.

  • functionAppName (string): The name of the Function App to be created.

    • Uniqueness Requirements: Must be unique across all of Azure. No two Function Apps anywhere in Azure can share the same name, regardless of subscription, region, or resource group.

    • Format Requirements: Must be between 3 and 60 characters, containing only letters, numbers, and hyphens (-). Cannot start or end with a hyphen. The name must be globally unique because it forms part of the default URL (e.g., https://<functionAppName>.azurewebsites.net).

  • location (string, default: 'eastus'): The Azure region where resources will be deployed.

  • storageAccountName (string, default: 'funcrunnerstorage'): The name for the Storage Account used by the Function App.

    • Uniqueness Requirements: Must be globally unique within Azure because the storage account's name is used in DNS.

    • Format Requirements: Must be between 3 and 24 characters, using only lowercase letters and numbers. Cannot contain uppercase letters, special characters, or start with a digit.

  • appServicePlanName (string, default: 'funcRunnerServicePlan'): The name of the App Service Plan that hosts the Function App.

    • Uniqueness Requirements: Must be unique within the resource group but does not need to be unique across the entire Azure subscription or region.

    • Format Requirements: Can include letters, numbers, underscores, and hyphens.

  • durableTaskHubName (string, default: 'funcRunnerTaskHub'): The name of the Durable Task Hub.

    • Uniqueness Requirements: Unique within the scope of the Azure Function App. Should not conflict with other task hubs within the same app.

    • Format Requirements: No strict format rules, but recommended to use alphanumeric characters, underscores, and hyphens.

  • workerRuntime (string, default: 'python'): Specifies the runtime stack for the Function App, set to Python.

  • linuxFxVersion (string, default: 'python|3.11'): Specifies the version of the runtime stack for the Function App.

  • queueName (string, default: 'openai-runs'): The name of the storage queue used for handling function executions and message processing.

    • Uniqueness Requirements: Must be unique within the Azure Storage Account but not globally.

    • Format Requirements: Must be between 3 and 63 characters, only containing lowercase letters, numbers, and hyphens (-). Cannot start or end with a hyphen.

Resources

The template deploys the following Azure resources:

Storage Account (Microsoft.Storage/storageAccounts)

  • Purpose: Provides storage for Azure Functions, including logs, data, and message queues.

  • Configuration:

  • Located in the specified region (location).

  • Uses Standard_LRS SKU for locally redundant storage.

  • Configured as StorageV2 for generalized storage capabilities.

App Service Plan (Microsoft.Web/serverfarms)

  • Purpose: Hosts the Function App, providing the necessary compute resources.

  • Configuration:

  • Located in the specified region (location).

  • Uses the dynamic consumption SKU Y1 for cost-effective scaling based on demand.

Application Insights (Microsoft.Insights/components)

  • Purpose: Provides monitoring and telemetry for the Function App, allowing for performance tracking and diagnostics.

  • Configuration:

  • Located in the specified region (location).

  • Configured for web application monitoring.

Function App (Microsoft.Web/sites)

  • Purpose: Runs the serverless functions that are part of the application, configured for Python 3.11 runtime.

  • Configuration:

  • Uses the specified App Service Plan.

  • Configured with several application settings, including the OpenAI API key, durable task hub name, and other environment-specific configurations.

  • Includes Linux-based hosting (linuxFxVersion set to python|3.11).

Queue Service and Storage Queue

  • Resources: (Microsoft.Storage/storageAccounts/queueServices) and (Microsoft.Storage/storageAccounts/queueServices/queues)

  • Purpose: Provides queue services for managing function triggers and processing.

  • Configuration:

  • Includes a default queue service and a named queue (queueName) for handling messages related to function executions.

How to Use This Template

  1. Set Up Your Environment: Ensure that you have the Azure CLI and Bicep CLI installed and configured.

  2. Customize Parameters: Modify the parameters in the template or provide a parameter file to tailor the deployment to your needs.

  3. Deploy the Template: Use the Azure CLI to deploy the template to your desired resource group:

az login az deployment group create \ --resource-group <YourResourceGroup> \ --template-file template.bicep \ --parameters \ openAiApiKey='<YOUR_OPENAI_API_KEY>' \ functionAppName='myFunctionApp' \ location='eastus' \ storageAccountName='myfuncrunnerstorage' \ appServicePlanName='myFuncRunnerServicePlan' \ durableTaskHubName='myFuncRunnerTaskHub' \ workerRuntime='python' \ linuxFxVersion='python|3.11' \ queueName='openai-runs'
Last modified: 06 November 2024