Azure Functions is a serverless compute service offered by Microsoft Azure, enabling developers to execute code without provisioning servers. Chapter 3 focuses on creating and managing Azure Functions, understanding triggers, bindings, and durable functions, and exploring local development techniques. These Azure Functions MCQ questions and answers are designed to help IT professionals and students master the concepts and prepare for Azure certifications. Dive in to test your knowledge of HTTP triggers, bindings like Blob and Cosmos DB, state management with durable functions, and best practices for dependency injection and testing.
Multiple-Choice Questions (MCQs)
Creating Functions: HTTP Trigger, Timer Trigger, and Queue Trigger
What is an HTTP trigger in Azure Functions? a) A trigger that runs on file changes b) A trigger that responds to HTTP requests c) A trigger that monitors Azure queues d) A trigger that executes based on time intervals
Which Azure Function trigger is best for scheduling tasks? a) HTTP Trigger b) Timer Trigger c) Queue Trigger d) Event Hub Trigger
What is required to configure a Queue Trigger in Azure Functions? a) Blob container name b) Queue name and storage account connection c) Service Bus connection string d) Cosmos DB account URI
How does an Azure Timer Trigger define its schedule? a) Using a JSON file b) By specifying a CRON expression c) By setting environment variables d) Through the Azure portal UI only
What is the default HTTP method supported by an HTTP-triggered function? a) POST b) GET c) Both GET and POST d) PUT
Input and Output Bindings: Blob, Cosmos DB, Service Bus, and Event Hubs
What is the purpose of input bindings in Azure Functions? a) To trigger the function execution b) To fetch data from external sources c) To connect functions with Azure monitoring tools d) To enable cross-region deployments
Which of these is NOT a valid output binding for Azure Functions? a) Blob Storage b) Cosmos DB c) SQL Server d) Redis Cache
How do you connect an Azure Function to a Cosmos DB container? a) By specifying the database name in app settings b) Using a connection string in the bindings configuration c) By enabling Managed Identity d) Through manual endpoint configuration
Which binding is commonly used for real-time streaming data? a) Blob Storage b) Service Bus c) Event Hubs d) Queue Storage
What configuration file defines input and output bindings for an Azure Function? a) appsettings.json b) host.json c) local.settings.json d) function.json
Writing Durable Functions for State Management
What is the main purpose of Durable Functions? a) To scale serverless functions automatically b) To provide long-running stateful workflows c) To optimize input/output bindings d) To integrate with Azure Logic Apps
Which Durable Function pattern is used for managing a workflow with multiple steps? a) Fan-out/fan-in b) Async HTTP APIs c) Chaining d) Monitoring
How is state preserved in a Durable Function? a) Using Azure Key Vault b) Through Azure Storage c) By enabling durable queues d) Using environment variables
Which type of Durable Function is best for running parallel tasks? a) Orchestrator Function b) Activity Function c) Timer Function d) HTTP Trigger
What language does the Durable Task Framework primarily use? a) Python b) C# c) JavaScript d) All supported Azure Functions languages
Dependency Injection in Azure Functions
What is the benefit of dependency injection in Azure Functions? a) Reduces execution time b) Simplifies unit testing and promotes reusability c) Optimizes bindings performance d) Ensures cross-region deployment
Which method registers services for dependency injection in Azure Functions? a) ConfigureAppSettings() b) ConfigureServices() c) AddFunctionsBindings() d) InitializeDependencies()
Dependency injection is supported natively in which Azure Functions runtime version? a) Version 1.x b) Version 2.x and above c) Only in version 3.x d) All versions
What is the correct lifecycle for injected dependencies in Azure Functions? a) Singleton b) Scoped c) Transient d) Per-function instance
What library provides dependency injection support in Azure Functions? a) Azure.Functions.DependencyInjection b) Microsoft.Extensions.DependencyInjection c) Functions.DI.Core d) Azure.Services.Injector
Local Development and Testing Using Core Tools
What tool is primarily used for local development of Azure Functions? a) Azure CLI b) Azure Functions Core Tools c) Visual Studio Code only d) Azure DevOps
Which file stores local environment settings for Azure Functions? a) appsettings.json b) local.settings.json c) function.json d) host.json
What command is used to start an Azure Function locally? a) az function start b) func start c) start-function-app d) run azure function
How can you test Azure Functions locally using HTTP triggers? a) Using Azure Monitor b) By running the function and sending HTTP requests via Postman c) By deploying to a staging environment d) By using built-in Azure diagnostics
What is required to debug Azure Functions locally? a) Azure subscription b) Local emulator c) IDE with debugging support and Core Tools d) Azure DevOps pipeline
Scenario-Based Questions
An Azure Timer Trigger is failing to execute. What might be the cause? a) Incorrect CRON expression in configuration b) Unsupported runtime version c) Function not linked to an output binding d) Missing storage account
A Blob Storage input binding fails to retrieve data. What should you check first? a) The size of the blob b) The storage account connection string c) The function runtime version d) The Azure portal logs
You need to write a stateful workflow with retries. Which Azure Function type should you use? a) Durable Function b) Queue Trigger Function c) Timer Trigger Function d) HTTP Trigger Function
You are developing an Azure Function locally. Which command ensures dependencies are installed? a) func init b) func install c) npm install or dotnet restore d) az function dependencies install
How can you reduce the cold start time for Azure Functions? a) Use a premium plan or enable Always On b) Configure smaller function timeouts c) Minimize input bindings d) Increase the app service plan size
Answers
QNo
Answer
1
b) A trigger that responds to HTTP requests
2
b) Timer Trigger
3
b) Queue name and storage account connection
4
b) By specifying a CRON expression
5
c) Both GET and POST
6
b) To fetch data from external sources
7
d) Redis Cache
8
b) Using a connection string in the bindings configuration
9
c) Event Hubs
10
d) function.json
11
b) To provide long-running stateful workflows
12
c) Chaining
13
b) Through Azure Storage
14
a) Orchestrator Function
15
d) All supported Azure Functions languages
16
b) Simplifies unit testing and promotes reusability
17
b) ConfigureServices()
18
b) Version 2.x and above
19
d) Per-function instance
20
b) Microsoft.Extensions.DependencyInjection
21
b) Azure Functions Core Tools
22
b) local.settings.json
23
b) func start
24
b) By running the function and sending HTTP requests via Postman