Configure Function Settings
On this page
Introduction
Function settings allow you to fine-tune the behavior of individual Azure Functions within your Function App. These settings can control aspects like execution timeouts, retry policies, and integration points. Understanding how to configure these settings is crucial for optimizing performance, reliability, and cost-effectiveness.
Accessing Function Settings
You can configure function settings through the Azure portal or by using the Azure CLI/PowerShell.
Azure Portal
- Navigate to your Function App in the Azure portal.
- In the left-hand menu, under Functions, select the specific function you want to configure.
- Under the function's menu, find and click on Configuration.
- Here, you'll see various settings categories, including Application settings, Connection strings, and Path mappings. For function-specific settings, you might find them within the General settings or related sections for that function type.
Azure CLI
You can use the Azure CLI to view and update function configurations. For example, to get the settings for a specific function:
az functionapp function show --resource-group <your-resource-group> --name <your-function-app> --function-name <your-function-name>Updating settings typically involves modifying the Function App's configuration, which can affect all functions. Specific function settings might be managed through code or other deployment mechanisms.
Common Function Settings
While many configurations are managed at the Function App level, some settings are more directly related to individual functions. The availability and nature of these settings can vary depending on the function's trigger and runtime.
Execution Timeout
This setting determines the maximum amount of time a function execution can run before it's terminated. The default varies by host version and plan.
- Consumption plan: Default 5 minutes, maximum 10 minutes.
- Premium plan: Default 30 minutes, maximum 60 minutes.
- Dedicated (App Service) plan: Default 30 minutes, maximum unlimited (though practically limited by infrastructure).
You can configure this in the host.json file for the Function App, which applies to all functions unless overridden at the function level (if supported by the host).
Retry Policies
For event-driven triggers (like queues or blobs), you can configure retry policies to automatically re-execute a function if it fails. This is typically defined in host.json.
{
  "version": "2.0",
  "extensions": {
    "queues": {
      "maxDequeueCount": 5,
      "newBatchSize": 16,
      "batchSize": 16,
      "visibilityTimeout": "00:00:10",
      "deadLetterQueue": {
        "isEnabled": true
      }
    }
  }
}maxDequeueCount specifies how many times a message can be dequeued before being moved to a poison queue (if enabled).
Input/Output Binding Settings
While the core configuration of bindings is done in function.json (for v1/v2) or through attributes (for v3+), specific advanced configurations or behaviors for certain bindings might be adjustable. For instance, a blob trigger might have settings related to how frequently it checks for new blobs.
Examples
Configuring Timeout in host.json
                To set a function timeout of 5 minutes for all functions on the consumption plan:
{
  "version": "2.0",
  "functionTimeout": "00:05:00",
  "extensions": {
    "http": {
      "routePrefix": "api"
    }
  }
}Configuring Queue Trigger Retries
Set a queue trigger to retry up to 3 times before sending to a dead-letter queue:
{
  "version": "2.0",
  "extensions": {
    "queues": {
      "maxDequeueCount": 3,
      "deadLetterQueue": {
        "isEnabled": true
      }
    }
  }
}Best Practices
- Use host.jsonfor Global Settings: Configure timeouts and retry policies that apply to all functions in your Function App within thehost.jsonfile.
- Understand Plan Limits: Be aware of the execution timeout limits imposed by your chosen App Service plan (Consumption, Premium, Dedicated).
- Implement Idempotency: Design your functions to be idempotent, especially when dealing with retries. This ensures that executing the same operation multiple times has the same effect as executing it once.
- Leverage Dead-Letter Queues: Use dead-letter queues for asynchronous triggers to capture messages that repeatedly fail processing, allowing for investigation without blocking the main queue.
- Monitor Function Performance: Regularly monitor function execution times and error rates to identify potential configuration issues or areas for optimization.
- Avoid Over-Configuration: Only configure settings that are necessary. Unnecessary complexity can lead to maintenance issues.