0
0
Azurecloud~10 mins

Trigger types (HTTP, Timer, Blob, Queue) 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 define an HTTP trigger function in Azure Functions.

Azure
def main(req: func.HttpRequest) -> func.HttpResponse:
    if req.method == '[1]':
        return func.HttpResponse('Hello HTTP!')
Drag options to blanks, or click blank then click option'
ADELETE
BPOST
CPUT
DGET
Attempts:
3 left
💡 Hint
Common Mistakes
Using POST instead of GET for simple retrieval.
2fill in blank
medium

Complete the code to set a Timer trigger schedule to run every 5 minutes.

Azure
timer = func.TimerRequest(schedule='[1]')
Drag options to blanks, or click blank then click option'
A0 */5 * * * *
B*/5 * * * *
C5 * * * *
D0 5 * * * *
Attempts:
3 left
💡 Hint
Common Mistakes
Using 5-field cron expressions missing the seconds field.
3fill in blank
hard

Fix the error in the Blob trigger binding path to listen to the container named 'images'.

Azure
blob_trigger = func.InputStream('[1]/{name}')
Drag options to blanks, or click blank then click option'
Aimages
Bimage
Cimage-container
Dimg
Attempts:
3 left
💡 Hint
Common Mistakes
Using singular or incorrect container names.
4fill in blank
hard

Fill both blanks to define a Queue trigger function that listens to the 'tasks' queue and uses the correct parameter type.

Azure
def main(msg: [1]):
    logging.info(f'Received message: {msg.[2]')
Drag options to blanks, or click blank then click option'
Afunc.QueueMessage
Bfunc.QueueTrigger
Cfunc.QueueItem
Dcontent
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect parameter types or accessing wrong attributes.
5fill in blank
hard

Fill all three blanks to define an HTTP triggered Azure Function that reads a query parameter 'name' and returns a greeting.

Azure
def main(req: func.HttpRequest) -> func.HttpResponse:
    name = req.params.get('[1]')
    if not name:
        try:
            req_body = req.get_json()
        except ValueError:
            pass
        else:
            name = req_body.get('[2]')
    if name:
        return func.HttpResponse(f'Hello, [3]!')
    else:
        return func.HttpResponse('Please pass a name on the query string or in the request body.', status_code=400)
Drag options to blanks, or click blank then click option'
Aname
Busername
Duser
Attempts:
3 left
💡 Hint
Common Mistakes
Using different keys for query and JSON, or wrong variable in greeting.