AZ-204 - Azure Function App
Overview of Function Apps
Azure Functions is a serverless compute service that lets you run event-driven code without provisioning or managing infrastructure. You write the function code, and Azure handles scaling, infrastructure, and execution.
Key Concepts
Function App
A Function App is the execution context that hosts one or more individual functions. All functions in a Function App share the same configuration, app settings, and hosting plan.
Triggers
A trigger defines how a function is invoked. Every function must have exactly one trigger. Triggers include HTTP requests, timer schedules, queue messages, blob changes, and more.
Bindings
Bindings are a declarative way to connect data to your function. They can be input bindings (read data) or output bindings (write data) and eliminate the need for manual SDK calls.
Hosting Plans
| Plan | Scaling | Key Feature |
|---|---|---|
| Consumption | Auto-scale to zero | Pay only when functions execute; 5-min default timeout (max 10 min) |
| Premium | Pre-warmed instances | No cold start; VNET integration; unlimited execution duration |
| Dedicated (App Service) | Manual/auto within plan | Use existing App Service Plan; always-on available; predictable billing |
Creating a Function App
You can create a Function App through the Azure Portal, Azure CLI, Visual Studio, or VS Code. Key settings to configure include runtime stack, region, hosting plan, and storage account.
HTTP Trigger Function
An HTTP trigger invokes a function via an HTTP request. It is the most common trigger type and supports GET, POST, and other HTTP methods.
Authorization Levels
| Level | Description |
|---|---|
| Anonymous | No API key required -- anyone can call the function |
| Function | Requires a function-specific API key |
| Admin | Requires the master (host) key -- highest privilege |
Timer Trigger Function
A timer trigger runs a function on a schedule using a CRON expression. Useful for periodic cleanup, report generation, or data processing tasks.
CRON Expression Format
Azure Functions uses a 6-field CRON expression: {second} {minute} {hour} {day} {month} {day-of-week}
0 */5 * * * * runs every 5 minutes. 0 0 9 * * 1-5 runs at 9:00 AM Monday through Friday.Adding a Blob Output Binding
Output bindings let your function write data to external services declaratively. A Blob output binding writes data to Azure Blob Storage without requiring explicit SDK code.
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequest req,
[Blob("output-container/{rand-guid}.txt", FileAccess.Write)] TextWriter writer)
{
await writer.WriteAsync("Hello from Azure Functions!");
return new OkResult();
}
Monitoring Function Events and Errors
Azure Functions integrates with Application Insights for monitoring. You can track function invocations, execution duration, success/failure rates, and custom telemetry.
Built-in Monitoring
The Azure Portal provides a Monitor tab for each function showing recent invocations, success/failure status, and execution duration.
Application Insights Integration
Connect your Function App to Application Insights for detailed telemetry, custom queries (KQL), live metrics, and alerting.
Function Core Tools
Azure Functions Core Tools is a command-line tool for developing and testing functions locally before deploying to Azure. It provides a local runtime that mimics the cloud environment.
func new --template "HTTP trigger" --name MyHttpFunction
func start
Visual Studio and Functions
Visual Studio provides rich tooling for Azure Functions including project templates, local debugging with breakpoints, and integrated publish-to-Azure workflows.
Key Terms
| Term | Definition |
|---|---|
| Trigger | Defines how a function is invoked. Every function has exactly one trigger (HTTP, Timer, Queue, Blob, etc.). |
| Binding | A declarative connection to data. Input bindings read data; output bindings write data -- without manual SDK calls. |
| Consumption Plan | A serverless hosting plan where Azure scales automatically and you pay only for execution time. Default timeout is 5 minutes. |
| Premium Plan | A hosting plan with pre-warmed instances (no cold start), VNET integration, and unlimited execution duration. |
| Authorization Level | Controls who can call an HTTP-triggered function: Anonymous (no key), Function (function key), or Admin (master key). |
| Function Core Tools | CLI tool for local Azure Functions development, testing, and deployment. |
- Every function has exactly ONE trigger but can have MULTIPLE input and output bindings.
- Consumption plan: auto-scale to zero, pay per execution, 5-min default timeout (max 10).
- Premium plan: no cold start, VNET integration, unlimited duration.
- HTTP trigger authorization levels: Anonymous, Function, Admin.
- Timer trigger uses 6-field CRON expressions (includes seconds).
- Every Function App requires a Storage Account.
- Application Insights is the recommended monitoring solution for Functions.
Practice Questions
Q1. A developer needs a function that runs every day at midnight. Which trigger type should they use?
- HTTP Trigger
- Queue Trigger
- Timer Trigger
- Blob Trigger
Answer: C
Timer triggers run functions on a schedule defined by a CRON expression. For daily execution at midnight, the CRON expression would be 0 0 0 * * *.
Q2. Which hosting plan eliminates cold starts for Azure Functions?
- Consumption Plan
- Premium Plan
- Dedicated (App Service) Plan
- Free Plan
Answer: B
The Premium plan uses pre-warmed instances to eliminate cold starts. The Consumption plan scales to zero when idle, causing cold starts on first invocation.
Q3. How many triggers can a single Azure Function have?
- Unlimited
- Up to 5
- Exactly one
- At least two
Answer: C
Every Azure Function must have exactly one trigger. A function can have multiple input and output bindings, but only one trigger defines how the function is invoked.
Q4. Which authorization level requires the master host key to invoke an HTTP-triggered function?
- Anonymous
- Function
- Admin
- System
Answer: C
The Admin authorization level requires the master (host) key, which is the highest privilege level. Function level requires a function-specific key, and Anonymous requires no key.
Q5. What is required for every Azure Function App regardless of hosting plan?
- A Virtual Network
- An Azure Storage Account
- Application Insights
- A custom domain
Answer: B
Every Azure Function App requires an Azure Storage Account for internal operations such as managing triggers, logging executions, and storing function code.
AZ-204 Developing Azure Solutions - Table of Contents
Master all exam topics with comprehensive study guides and practice questions.