Skip to content

AI-200 · Domain 3: Connect to and consume Azure services · 22% of the exam

Task 3.2: Develop and implement Azure Functions

Triggers and bindings in the Python programming model, serverless HTTP APIs, hosting plans including Flex Consumption, app settings and identity-based connections, and deployment.

Study it

  • Azure Functions triggers and bindings in Python, and serverless HTTP APIs

    Partly covered by: Lambda & Event-Driven Design

  • Function app hosting plans, settings, identity-based connections and deployment

    Lesson coming

Sample questions

Try each one before opening the answer. Every option is explained, with the Microsoft documentation page that proves it.

Question 1 · choose 1

A new Python function app must reach a database through a virtual network, scale to zero when idle, bill only for execution when there's no traffic, and scale out quickly under bursts. Which hosting plan meets every requirement?

  1. AConsumption
  2. BPremium
  3. CFlex Consumption
  4. DDedicated (App Service plan)
Show the answer and why
  • AConsumption

    Incorrect

    The legacy Consumption plan doesn't support virtual networks, and Linux Consumption is retiring.

  • BPremium

    Incorrect

    A Premium plan always has at least one active, billed instance, so it never scales to zero.

  • CFlex Consumption

    Correct

    Flex Consumption is Linux-based, scales to zero, bills per execution, and adds virtual network integration and fast scale-out.

  • DDedicated (App Service plan)

    Incorrect

    Dedicated plans run on instances you pay for continuously, with no scale to zero.

Flex Consumption is the recommended serverless plan: scale to zero, execution-based billing, optional always ready instances, virtual network integration and up to 1,000 instances. Premium and Dedicated keep instances running.

Question 2 · choose 1

Your team deploys a function app by publishing to a staging slot and swapping it into production. You're moving the app to the Flex Consumption plan. How do you keep zero-downtime deployments?

  1. ACreate a staging slot on the Flex Consumption app and keep swapping
  2. BMigrate the existing app in place to Flex Consumption so its slots carry over
  3. CSet WEBSITE_RUN_FROM_PACKAGE to a package URL to switch versions atomically
  4. DUse the rolling updates site update strategy instead of slots
Show the answer and why
  • ACreate a staging slot on the Flex Consumption app and keep swapping

    Incorrect

    Deployment slots aren't currently supported on Flex Consumption.

  • BMigrate the existing app in place to Flex Consumption so its slots carry over

    Incorrect

    In-place migration to Flex Consumption isn't supported; you create a new app and redeploy.

  • CSet WEBSITE_RUN_FROM_PACKAGE to a package URL to switch versions atomically

    Incorrect

    Flex Consumption deploys from a package in a blob container and no longer uses app settings to drive deployment behavior.

  • DUse the rolling updates site update strategy instead of slots

    Correct

    Flex Consumption applies code and configuration changes gradually across instances through rolling updates (currently in preview).

Flex Consumption deploys a zipped package to a blob storage container and has no deployment slots. Its zero-downtime option is the rolling update site update strategy, which other plans replace with slots.

Question 3 · choose 1

A Python v2 function app keeps all its HTTP and queue functions in function_app.py, and the file has become hard to maintain. You want to move related functions into separate modules while keeping a single function app. What do you use?

  1. ACreate a folder per function with its own function.json file
  2. BDefine them on func.Blueprint objects and register each with app.register_functions
  3. CCreate a separate FunctionApp object in each module and import those modules into function_app.py
  4. DPut the modules in a shared folder and list them in host.json
Show the answer and why
  • ACreate a folder per function with its own function.json file

    Incorrect

    function.json folders belong to the v1 programming model, not the decorator-based v2 model.

  • BDefine them on func.Blueprint objects and register each with app.register_functions

    Correct

    Blueprints let you define functions in other files and register them with the main FunctionApp object.

  • CCreate a separate FunctionApp object in each module and import those modules into function_app.py

    Incorrect

    A function app uses one FunctionApp object in function_app.py; the documented way to add modules is blueprints.

  • DPut the modules in a shared folder and list them in host.json

    Incorrect

    host.json holds global settings for the app; it doesn't register functions.

In the v2 model, functions are decorated methods on the FunctionApp in function_app.py. Larger apps define functions on Blueprint objects in other files and call app.register_functions for each one.

Question 4 · choose 1

A Service Bus–triggered function sets connection="SbConn" and must authenticate with the function app's managed identity instead of a connection string. Which app setting configures the connection?

  1. ASbConn set to <namespace>.servicebus.windows.net
  2. BSbConn__serviceUri set to https://<namespace>.servicebus.windows.net
  3. CAzureWebJobsServiceBus set to the namespace's primary key
  4. DSbConn__fullyQualifiedNamespace set to <namespace>.servicebus.windows.net
Show the answer and why
  • ASbConn set to <namespace>.servicebus.windows.net

    Incorrect

    A bare value under the connection name is read as a connection string, not as an identity-based connection.

  • BSbConn__serviceUri set to https://<namespace>.servicebus.windows.net

    Incorrect

    serviceUri is the property used for services such as SignalR, not for Service Bus.

  • CAzureWebJobsServiceBus set to the namespace's primary key

    Incorrect

    That's a key-based setting, which the managed identity requirement rules out.

  • DSbConn__fullyQualifiedNamespace set to <namespace>.servicebus.windows.net

    Correct

    Identity-based Service Bus connections use the __fullyQualifiedNamespace suffix on the connection name.

Each identity-based connection is a group of settings that share the connection name as a prefix. For Service Bus the required one is <CONNECTION_NAME_PREFIX>__fullyQualifiedNamespace; the identity also needs a Service Bus data role.

Question 5 · choose 2

A Python function app on Flex Consumption must run a function whenever a file lands in the uploads container. Which two steps are needed? (Choose TWO.)

  1. AKeep the default LogsAndContainerScan source
  2. BAdd a timer trigger that lists new blobs every minute
  3. CSet source to EventGrid on the blob_trigger decorator
  4. DCreate an Event Grid event subscription on the storage account that delivers to the function's blob extension endpoint
  5. ESet WEBSITE_RUN_FROM_PACKAGE to 1
Show the answer and why
  • AKeep the default LogsAndContainerScan source

    Incorrect

    The default polling source isn't supported for blob triggers on Flex Consumption.

  • BAdd a timer trigger that lists new blobs every minute

    Incorrect

    Polling with a timer isn't a blob trigger and adds latency and cost.

  • CSet source to EventGrid on the blob_trigger decorator

    Correct

    On Flex Consumption the Blob Storage trigger supports only the Event Grid source.

  • DCreate an Event Grid event subscription on the storage account that delivers to the function's blob extension endpoint

    Correct

    The Event Grid source relies on an event subscription to the container instead of polling it.

  • ESet WEBSITE_RUN_FROM_PACKAGE to 1

    Incorrect

    That's a deployment setting, and Flex Consumption doesn't use app settings to control deployment.

The Event Grid-based blob trigger reacts to an event subscription on the container, which lowers latency compared with polling. In Flex Consumption it's the only supported source, so set source="EventGrid" and create the subscription.

Question 6 · choose 1

An HTTP-triggered function is declared with auth_level=func.AuthLevel.FUNCTION. A partner system calls it without any key and gets 401 Unauthorized. How must the caller send the function key?

  1. AIn an Authorization header as a bearer token
  2. BIn the code query string parameter or in the x-functions-key request header
  3. CIn the request body under a key property
  4. DAs the master key in the x-functions-key header for every call
Show the answer and why
  • AIn an Authorization header as a bearer token

    Incorrect

    A function key isn't a bearer token; the runtime reads it from the code parameter or the x-functions-key header.

  • BIn the code query string parameter or in the x-functions-key request header

    Correct

    Non-anonymous HTTP functions require an access key in either of these places.

  • CIn the request body under a key property

    Incorrect

    The runtime doesn't look for access keys in the request body.

  • DAs the master key in the x-functions-key header for every call

    Incorrect

    The master key is for the runtime admin APIs; a function key or host key is enough for a function-level endpoint.

With a function or admin authorization level, callers include an access key: ?code=<key> in the URL or the x-functions-key header. The value can be a function key for that function or a host key.

Question 7 · choose 1

A Python timer-triggered function must run every five minutes, on the minute. Which schedule expression do you pass to the timer trigger?

  1. A*/5 * * * * *
  2. B0 0 */5 * * *
  3. C5 * * * * *
  4. D0 */5 * * * *
Show the answer and why
  • A*/5 * * * * *

    Incorrect

    In the six-field format the first field is seconds, so this fires every five seconds.

  • B0 0 */5 * * *

    Incorrect

    The third field is hours, so this runs every five hours.

  • C5 * * * * *

    Incorrect

    This fires at second 5 of every minute, which is once a minute.

  • D0 */5 * * * *

    Correct

    NCRONTAB adds a seconds field at the start; this fires at second 0 of every fifth minute.

Functions uses NCRONTAB expressions, {second} {minute} {hour} {day} {month} {day-of-week}, evaluated in UTC by default.

Question 8 · choose 1

You create a Python function app on Flex Consumption and must choose an instance memory size. The app has no unusual memory or concurrency needs. Which size does Microsoft recommend as the default?

  1. A512 MB
  2. B4,096 MB
  3. C1,536 MB, the fixed size of every Flex Consumption instance
  4. D2,048 MB
Show the answer and why
  • A512 MB

    Incorrect

    512 MB suits specific low-concurrency needs; it isn't the general default.

  • B4,096 MB

    Incorrect

    4,096 MB is for higher concurrency or heavier CPU and memory work.

  • C1,536 MB, the fixed size of every Flex Consumption instance

    Incorrect

    Flex Consumption offers selectable sizes of 512, 2,048 and 4,096 MB.

  • D2,048 MB

    Correct

    Microsoft suggests 2,048 MB as the default for most scenarios.

Flex Consumption lets you choose the instance memory size, and CPU and network bandwidth scale with it. You can change the size at any time, and the default HTTP concurrency depends on it.

Question 9 · choose 1

A function works locally, where it reads a CosmosConnection__accountEndpoint value from local.settings.json. After publishing to Azure, the trigger fails because the setting is missing. Why?

  1. Ahost.json overrides local.settings.json in Azure
  2. Blocal.settings.json isn't published; add the setting to the app in Azure
  3. CThe .funcignore file always excludes requirements.txt, which breaks the setting
  4. DSettings with a double underscore are only read on Windows
Show the answer and why
  • Ahost.json overrides local.settings.json in Azure

    Incorrect

    host.json holds runtime configuration; it doesn't replace app settings.

  • Blocal.settings.json isn't published; add the setting to the app in Azure

    Correct

    The file holds local-only settings and secrets and is never deployed with the app.

  • CThe .funcignore file always excludes requirements.txt, which breaks the setting

    Incorrect

    requirements.txt lists dependencies; it has nothing to do with app settings.

  • DSettings with a double underscore are only read on Windows

    Incorrect

    The double underscore separates the parts of identity-based connection settings on every platform.

Locally, Core Tools reads app settings from local.settings.json. In Azure, the same names must be set as application settings on the function app, for example through the portal, the CLI or deployment templates.

Question 10 · choose 1

A Service Bus–triggered function uses an identity-based connection whose identity has the Azure Service Bus Data Receiver role. Messages are processed, but the app scales out late during bursts and no errors are logged. What's the likely cause?

  1. AThe identity can't read queue runtime properties, so scaling uses peek estimates
  2. BThe Data Receiver role can't complete messages, so they're redelivered
  3. CIdentity-based connections turn off target-based scaling for Service Bus triggers
  4. DService Bus triggers scale only on CPU, not on queue length
Show the answer and why
  • AThe identity can't read queue runtime properties, so scaling uses peek estimates

    Correct

    Accurate counts come from the administration API, which needs the Data Owner role or a custom role with namespace read rights.

  • BThe Data Receiver role can't complete messages, so they're redelivered

    Incorrect

    Data Receiver allows receiving and settling; the messages are being processed.

  • CIdentity-based connections turn off target-based scaling for Service Bus triggers

    Incorrect

    Identity-based connections work with scaling; the missing piece is a permission.

  • DService Bus triggers scale only on CPU, not on queue length

    Incorrect

    The Service Bus extension scales on message counts.

The Service Bus extension reads queue or subscription runtime properties to make scale decisions. Without Manage rights or Azure Service Bus Data Owner, it silently uses less accurate peek-based estimates, which can delay scaling.

Practise domain 3 →Practise all domains →