Complete the code to specify the trigger type for an Azure Function.
public static void Run([[1]Trigger] string myQueueItem, ILogger log) { log.LogInformation($"Processing: {myQueueItem}"); }
The Azure Function is triggered by a message in a queue, so the correct trigger attribute is QueueTrigger.
Complete the code to set the maximum number of function instances in host.json.
{
"version": "2.0",
"functionTimeout": "00:05:00",
"concurrency": {
"dynamicConcurrencyEnabled": true,
"[1]": 5
}
}The maxInstances setting controls the maximum number of function instances that can run concurrently.
Fix the error in the Azure Function scale controller setting.
{
"version": "2.0",
"extensions": {
"queues": {
"batchSize": 16,
"maxDequeueCount": [1]
}
}
}The maxDequeueCount must be a positive integer. Using 5 is correct. Strings or negative numbers cause errors.
Fill both blanks to configure the function app to scale based on CPU and memory thresholds.
{
"scaling": {
"rules": [
{
"metricTrigger": {
"metricName": "[1]",
"threshold": 70
},
"scaleAction": {
"direction": "Increase",
"type": "ChangeCount",
"value": "1"
}
},
{
"metricTrigger": {
"metricName": "[2]",
"threshold": 80
},
"scaleAction": {
"direction": "Increase",
"type": "ChangeCount",
"value": "1"
}
}
]
}
}The function app scales when CPU usage exceeds 70% and memory usage exceeds 80%, so the metric names are CpuPercentage and MemoryPercentage.
Fill all three blanks to define a scale rule that decreases instances when the queue length is low.
{
"rules": [
{
"metricTrigger": {
"metricName": "[1]",
"threshold": [2],
"timeAggregation": "Average"
},
"scaleAction": {
"direction": "[3]",
"type": "ChangeCount",
"value": "1",
"cooldown": "PT5M"
}
}
]
}The scale rule triggers when the QueueLength metric average is below 10, causing the function app to Decrease instances.