Microsoft Azure Developer Associate AZ-204 Practice Question
You are writing an in-process C# Azure Function that is triggered by messages arriving on a Service Bus queue. Depending on the message contents, the function may have to create anywhere from zero to ten new documents in an Azure Cosmos DB container. You want to rely only on Azure Functions bindings-no SDK client code. Which parameter declaration should you add to the function method to meet the requirement?
An IAsyncCollector<MyDocument> parameter decorated with [CosmosDB(databaseName:"db", containerName:"items", Connection="CosmosConn")]
An ILogger parameter decorated with the Cosmos DB attribute
A DocumentClient parameter obtained through dependency injection
An out MyDocument parameter decorated with the Cosmos DB attribute
The Cosmos DB output binding can create one document by using an out parameter, but when the function needs to add an arbitrary number of documents you must use IAsyncCollector (or ICollector). The collector lets you call AddAsync for each document and the runtime writes all items when the function completes, without any direct use of the Cosmos DB SDK. Declaring a single out parameter limits the function to exactly one document per invocation, while placing a DocumentClient parameter means you are bypassing bindings and writing code manually. Decorating an ILogger parameter with a Cosmos DB attribute would have no effect because ILogger is reserved for logging and cannot act as a binding target.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is an Azure Functions output binding?
Open an interactive chat with Bash
What is the difference between IAsyncCollector<T> and ICollector<T> in Azure Functions?
Open an interactive chat with Bash
What role does the Cosmos DB attribute play in Azure Functions?
Open an interactive chat with Bash
Microsoft Azure Developer Associate AZ-204
Develop Azure compute solutions
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99
$19.99/mo
Billed monthly, Cancel any time.
3 Month Pass
$44.99
$14.99/mo
One time purchase of $44.99, Does not auto-renew.
MOST POPULAR
Annual Pass
$119.99
$9.99/mo
One time purchase of $119.99, Does not auto-renew.
BEST DEAL
Lifetime Pass
$189.99
One time purchase, Good for life.
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .