Implement IaaS, Azure Functions Flashcards

1
Q

From a top level view, What are Azure Functions

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What causes a Azure App Function to run

A

A trigger

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

True Or False? Azure Functions can have multiple triggers?

A

False, must have exactly one trigger

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

In Azure Functions, what is the purpose of bindings

A

Binding to a function is a way of declaratively connecting another resource to the function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

True or False? Bindings can be connected as input, output, or both

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How is data from bindings provided to a function

A

As function parameter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

True or False? Bindings are optional for Azure App Functions

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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.

A

Trigger:Queue
Input binding:
Output Binding:Queue

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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.

A

Trigger: Timer
Input binding: Blob Storage
Output Binding: Cosmos DB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How are Azure Function triggers and binding definitions defined in C#

A

Decorating methods and parameters with C# attributes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How are Azure Function triggers and bindings defined in everything except C# and Java (including Azure Portal)

A

By updating the content of function.json

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

True or False: the binding direction for triggers is always ‘out’

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What identifies a trigger in a function.json

A

Defined in the binding section. Binding type will have the word “trigger” in it. Example: queueTrigger

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What identifies a binding in a function.json

A

Defined in the bindings array in function.json

{
    "bindings":[
        // ... bindings here
        {
            "type": "bindingType",
            "direction": "in",
            "name": "myParamName",
            // ... more depending on binding
        }
    ]
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What identifies the function in a functions.json

A

Property name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are Durable Functions?

A

An extension of Azure Function, functions with state

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is meant by Orchestrator function

A

A function that calls multiple entity functions and/or action functions as a workflow. Entity/activity functions can be signaled or called.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

True or false? The total lifespan of an orchestration instance can be seconds, days, months, or never-ending

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is a task hub?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

How is an orchestration identified

A

Each instance of an orchestration has an instance identifier (also known as an instance ID). By default, each instance ID is an autogenerated GUID.

21
Q

True or false? Orchestration ID can be user defined

A

True, but must be unique within a task hub

22
Q

How to test Azure Functions locally?

A

Use Azure Storage Simulator, local.settings.json, and hosts.json

23
Q

What is meant by “Consumption Plan” in Azure Functions context?

A

Billing is based on number of executions, execution time, and memory used. Usage is aggregated across all functions within a function app.

24
Q

How does Pattern Function Chaining work?

A

sequence of functions in a particular order.

Often the output of one function needs to be applied to the input of another function.

25
Q

How does Pattern Fan out / fan in work in durable functions?

A

Fan out: execute multiple functions parallel.

Fan In: wait for all functions to finish, and then performing some aggregation on the results

Task.WhenAll

26
Q

Explain Async HTTP APIs Pattern

A

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.

27
Q

Explain the Monitor Pattern

A

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:

28
Q

How to wait for human interaction in durable functions?

A

Wait for an external response (human interaction). If the response does not come within a timeout period, escalate, otherwise proceed as intended.

context.WaitForExternalEvent

29
Q

What is this doing?
using (await context.LockAsync(sourceEntity, destinationEntity))
{ .. }

A

The LockAsync method creates a critical section in an orchestration that prevents other orchestrations from making overlapping changes to a specified set of entities.

30
Q

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
A

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.

31
Q

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
A

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)

32
Q

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.

A

Code you write that runs on servers a cloud provider manages.

33
Q

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

A

Function app

34
Q

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

A

x-functions-key

35
Q

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?

/

*

,

A

*

36
Q

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

A

samples-workitems/{name}.png

You can specify a blob name pattern in the path property in function.json or in the BlobTrigger attribute constructor.

37
Q

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.

A

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.

38
Q

What is the purpose of Azure API Management

A

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

39
Q

When using Azure API Management, how is a single microservice implemented / represented?

A

By using an Azure Function

40
Q

True or False? API Management acts as an intermediary (mediator)?

A

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.

41
Q

True or False? You can use API Management policies to enforce consistent rules on all microservices in the product.

A

True

For example, you can transform all XML responses into JSON, if that is your preferred format.

42
Q

Why do you need storage in a durable function?

A

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.

43
Q

Name the two parts to a function

A
Code
Config (function.json) - describes trigger, bindings
44
Q

What is an activity function?

A

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.

45
Q

The bindings property in function.json is where you configure both triggers and bindings. True or false

A

True. A trigger is a type of binding.

46
Q

What are two alternative triggers that can be used in data operations?

A
  1. Event Grid Trigger also has built-in support for blob events
  2. Queue Storage Trigger can respond to queue messages that correspond to blobs being created or modified
47
Q

What is a custom handler?

A

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

48
Q

What are the steps for creating a custom handler?

A
  1. Create new Azure Function App (func init) - selecting “Custom” as the language. This adds section for Custom Handler in the host.json file.
  2. Create Azure function (func new) - with any trigger you like
  3. Create a web server using your custom language of choice and that has your .exe file
  4. Update host.json to tell the app how to communicate with custom handler (defaultexecutablepath and enableforwardinghttprequest)
  5. Custom handler function route that the web server should listen on is /api/functionname
  6. Test locally using func start