0
0
Azurecloud~10 mins

Functions with queue triggers in Azure - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the queue name for the Azure Function trigger.

Azure
public static void Run([QueueTrigger("[1]", Connection = "AzureWebJobsStorage")] string myQueueItem, ILogger log) {
    log.LogInformation($"C# Queue trigger function processed: {myQueueItem}");
}
Drag options to blanks, or click blank then click option'
Amyqueue-items
Bmyqueueitem
CqueueTrigger
Dstoragequeue
Attempts:
3 left
💡 Hint
Common Mistakes
Using camelCase or incorrect queue names that don't match the actual queue.
Forgetting to put the queue name as a string.
2fill in blank
medium

Complete the code to specify the connection string setting name for the Azure Storage account.

Azure
public static void Run([QueueTrigger("myqueue-items", Connection = "[1]")] string myQueueItem, ILogger log) {
    log.LogInformation($"Processed: {myQueueItem}");
}
Drag options to blanks, or click blank then click option'
AAzureWebJobsStorage
BStorageConnection
CQueueConnectionString
DStorageAccountKey
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect or custom connection string names without configuring them.
Confusing connection string names with storage account keys.
3fill in blank
hard

Fix the error in the function signature to correctly bind the queue message as a string.

Azure
public static void Run([QueueTrigger("myqueue-items", Connection = "AzureWebJobsStorage")] [1] myQueueItem, ILogger log) {
    log.LogInformation($"Message: {myQueueItem}");
}
Drag options to blanks, or click blank then click option'
AQueueMessage
BCloudQueueMessage
Cstring
Dbyte[]
Attempts:
3 left
💡 Hint
Common Mistakes
Using CloudQueueMessage which requires extra parsing.
Using byte[] which is for binary data.
4fill in blank
hard

Fill both blanks to correctly bind the queue trigger and log the message length.

Azure
public static void Run([[1]("myqueue-items", Connection = "AzureWebJobsStorage")] string myQueueItem, ILogger [2]) {
    log.LogInformation($"Message length: {myQueueItem.Length}");
}
Drag options to blanks, or click blank then click option'
AQueueTrigger
Blogger
Clog
DQueueListener
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect attribute names like QueueListener.
Naming the logger parameter incorrectly causing errors.
5fill in blank
hard

Fill all three blanks to create a function that triggers on a queue message, logs the message, and outputs a new message to another queue.

Azure
public static void Run(
    [[1]("input-queue", Connection = "AzureWebJobsStorage")] string inputMessage,
    [Queue("[2]", Connection = "AzureWebJobsStorage")] out string outputMessage,
    ILogger [3]) {
    log.LogInformation($"Received: {inputMessage}");
    outputMessage = inputMessage.ToUpper();
}
Drag options to blanks, or click blank then click option'
AQueueTrigger
Boutput-queue
Clog
DQueueOutput
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up input and output queue names.
Using wrong attribute names for output binding.
Incorrect logger parameter name.