Implement IaaS, Azure Functions Flashcards
From a top level view, What are Azure Functions
Azure Functions allows you to run small pieces of code (functions) on scalable infrastructure.
A functions execution is triggered by an event.
Outputs of functions are streamlined by bindings.
What causes a Azure App Function to run
A trigger
True Or False? Azure Functions can have multiple triggers?
False, must have exactly one trigger
In Azure Functions, what is the purpose of bindings
Binding to a function is a way of declaratively connecting another resource to the function
True or False? Bindings can be connected as input, output, or both
True
How is data from bindings provided to a function
As function parameter
True or False? Bindings are optional for Azure App Functions
True
In the following scenario, what is the Input Trigger, Input Binding and Output Binding:
A new queue message arrives which runs a function to write to another queue.
Trigger:Queue
Input binding:
Output Binding:Queue
In the following scenario, what is the Input Trigger, Input Binding and Output Binding:
A scheduled job reads Blob Storage contents and creates a new Cosmos DB document.
Trigger: Timer
Input binding: Blob Storage
Output Binding: Cosmos DB
How are Azure Function triggers and binding definitions defined in C#
Decorating methods and parameters with C# attributes
How are Azure Function triggers and bindings defined in everything except C# and Java (including Azure Portal)
By updating the content of function.json
True or False: the binding direction for triggers is always ‘out’
False
What identifies a trigger in a function.json
Defined in the binding section. Binding type will have the word “trigger” in it. Example: queueTrigger
What identifies a binding in a function.json
Defined in the bindings array in function.json
{ "bindings":[ // ... bindings here { "type": "bindingType", "direction": "in", "name": "myParamName", // ... more depending on binding } ] }
What identifies the function in a functions.json
Property name
What are Durable Functions?
An extension of Azure Function, functions with state
What is meant by Orchestrator function
A function that calls multiple entity functions and/or action functions as a workflow. Entity/activity functions can be signaled or called.
True or false? The total lifespan of an orchestration instance can be seconds, days, months, or never-ending
True
What is a task hub?
A task hub is a logical container used for durable functions. Orchestrator and activity functions can only interact with each other when they belong to the same task hub.
How is an orchestration identified
Each instance of an orchestration has an instance identifier (also known as an instance ID). By default, each instance ID is an autogenerated GUID.
True or false? Orchestration ID can be user defined
True, but must be unique within a task hub
How to test Azure Functions locally?
Use Azure Storage Simulator, local.settings.json, and hosts.json
What is meant by “Consumption Plan” in Azure Functions context?
Billing is based on number of executions, execution time, and memory used. Usage is aggregated across all functions within a function app.
How does Pattern Function Chaining work?
sequence of functions in a particular order.
Often the output of one function needs to be applied to the input of another function.
How does Pattern Fan out / fan in work in durable functions?
Fan out: execute multiple functions parallel.
Fan In: wait for all functions to finish, and then performing some aggregation on the results
Task.WhenAll
Explain Async HTTP APIs Pattern
Sometimes referred to as the polling consumer pattern
Addresses the problem of coordinating the state of long-running operations with external clients.
Client issues an HTTP request to start a long-running process like an orchestrator function
The target HTTP trigger returns an HTTP 202 response with a Location header that has the value “statusQueryGetUri”.
The client polls the URL in the Location header. Receives 200 response when instance finishes or fails.
Explain the Monitor Pattern
A flexible recurring process in a workflow - for example, polling until certain conditions are met.
Monitors run on intervals, not schedules:
example: a timer trigger runs every hour, or, a monitor waits one hour between actions.
A monitor function could monitor a location’s current weather conditions and alerts a user by SMS when the skies are clear. You could use a regular timer-triggered function to check the weather and send alerts. However, one problem with this approach is lifetime management. If only one alert should be sent, the monitor needs to disable itself after clear weather is detected. The monitoring pattern can end its own execution, among other benefits:
How to wait for human interaction in durable functions?
Wait for an external response (human interaction). If the response does not come within a timeout period, escalate, otherwise proceed as intended.
context.WaitForExternalEvent
What is this doing?
using (await context.LockAsync(sourceEntity, destinationEntity))
{ .. }
The LockAsync method creates a critical section in an orchestration that prevents other orchestrations from making overlapping changes to a specified set of entities.
You work for a company that makes TV adverts. You want to formalize two business processes:
The advert review process. A completed advert is put through this editorial process to ensure that it meets the standards of taste, decency, grammar, style, and legal requirements in the jurisdiction where it will be broadcast.
The feedback collection process. A completed advert is also put through this process in which customers, the director, and members of the board of directors, can give feedback.
The advert review process should be managed by members of the creative team, because it will need to change regularly. The creative team would prefer not to have to wait for a developer to become available whenever a change is needed.
The feedback collection process calls an on-premises SharePoint server. Because this server is not as reliable as a cloud-based server would be, developers want to carefully control the way the workflow retries this connection, if there is a failure.
1) Which technology would you use for the advert review process?
- Microsoft Power Automate
- Azure Logic Apps
- Azure Functions
- Azure App Service WebJobs
2) Which technology would you use for the feedback collection process?
- Microsoft Power Automate
- Azure Logic Apps
- Azure Functions
- Azure App Service WebJobs
1) Implement the workflow using Microsoft Power Automate because this allows the creative team, who are not developers, to manage the flow.
2) WebJobs are the only technology that permits developers to control retry policies.
You work for a company that makes digital cameras. The company has recently acquired a smaller company that makes lenses. You want to ensure that the same procedures are in use throughout the company for the following processes:
Lens quality control. The company you acquired has a good reputation for lens reliability because of its quality control procedure. You want to implement this procedure across the merged company and integrate it with your parts ordering system, which includes a REST API.
Ordering and dispatch. The company you acquired had no formal order and dispatch procedure, so you want to ensure its employees use your original business procedure. The ordering system has a user interface that is built as an Azure App service web app but you want to manage the order and dispatch workflow as a separate project.
You have hired a small team of developers to do the work and you prefer a design-first approach.
1) Which technology would you use for the lens quality control procedure?
- Microsoft Power Automate
- Azure Logic Apps
- Azure Functions
- Azure App Service WebJobs
2) In the merged camera company, which technology would you use for the ordering and dispatch procedure?
- Microsoft Power Automate
- Azure Logic Apps
- Azure Functions
- Azure App Service WebJobs
1) Azure Logic Apps is the only one of the four technologies that provides a design-first approach intended for developers.
2) Azure Logic Apps is the only one of the four technologies that provides a design-first approach intended for developers. (no copy paste issue here)
Which of the following best defines serverless logic?
Code you write that doesn’t run on servers.
Code you write that runs on servers you manage.
Code you write that runs on servers a cloud provider manages.
Code you write that runs on servers a cloud provider manages.
The container that groups functions into a logical unit for easier management, deployment, and sharing of resources is called?
Resource group
Function app
Function collection
Function app
We secured our function against unknown HTTP callers by requiring a function-specific API key be passed with each call. Which of the following fields is the name header in the HTTP requests that needs to contain this key?
x-functions-key
x-requested-with
x-csrf-token
x-functions-key
A CRON expression is a string that consists of six fields that represent a set of times. The order of the six fields in Azure is: {second} {minute} {hour} {day} {month} {day of the week}. Suppose you needed a CRON expression that meant “every day”, what special character would you put in the {day of the week} position?
/
*
,
‐
*
Suppose your Azure Function has a blob trigger that executes only when png images are uploaded. Which of the following blob trigger Path values should you use?
samples-workitems/{name}
samples-workitems/{name}/png
samples-workitems/{name}?png
samples-workitems/{name}.png
samples-workitems/{name}.png
You can specify a blob name pattern in the path property in function.json or in the BlobTrigger attribute constructor.
Which of the following is an advantage of using bindings in your Azure Functions to access data sources and data sinks?
They provide access to more data sources than are available using code.
They let you connect to Azure resources without authentication.
They simplify the connection process; you don’t need to code specific connection logic.
They simplify the connection process; you don’t need to code specific connection logic.
Bindings provide a declarative way to connect to data. They let you avoid the complexity of coding connection logic like making a database connection or invoking web API interfaces.
Store connection strings in the app settings (env. variables) of your function app.
What is the purpose of Azure API Management
Combine multiple Azure Functions into a web api
MS Definition: The Azure API Management (APIM) service enables you to construct an API from a set of disparate microservices
When using Azure API Management, how is a single microservice implemented / represented?
By using an Azure Function
True or False? API Management acts as an intermediary (mediator)?
True
It forwards requests to the right microservice, wherever it is located, and returns responses to users. Users never see the different URIs where microservices are hosted.
True or False? You can use API Management policies to enforce consistent rules on all microservices in the product.
True
For example, you can transform all XML responses into JSON, if that is your preferred format.
Why do you need storage in a durable function?
Durable Functions automatically persists function parameters, return values, and other state to durable storage to guarantee reliable execution.
Defaults to Azure Storage but you can select other storage providers.
Name the two parts to a function
Code Config (function.json) - describes trigger, bindings
What is an activity function?
Activity functions are the basic unit of work in a durable function orchestration. Activity functions are the functions and tasks that are orchestrated in the process.
The bindings property in function.json is where you configure both triggers and bindings. True or false
True. A trigger is a type of binding.
What are two alternative triggers that can be used in data operations?
- Event Grid Trigger also has built-in support for blob events
- Queue Storage Trigger can respond to queue messages that correspond to blobs being created or modified
What is a custom handler?
Custom handlers are lightweight web servers that receive events from the Functions host.
The functions host sends a request payload to the web server. The web server executes the individual function, and returns a response payload to the Functions host.
The Functions host passes data from the response to the function’s output bindings for processing.
Allow you to implement Azure functions using unsupported language or runtimes by making http request to a web server running your code
What are the steps for creating a custom handler?
- Create new Azure Function App (func init) - selecting “Custom” as the language. This adds section for Custom Handler in the host.json file.
- Create Azure function (func new) - with any trigger you like
- Create a web server using your custom language of choice and that has your .exe file
- Update host.json to tell the app how to communicate with custom handler (defaultexecutablepath and enableforwardinghttprequest)
- Custom handler function route that the web server should listen on is /api/functionname
- Test locally using func start