Module 02 Implement Azure Functions 1
Module 02 Implement Azure Functions 1
Azure Functions
Module
Agenda Develop Azure Functions
Overview
• Azure Functions are a great solution for processing data, integrating systems, working with the
internet-of-things (IoT), and building simple APIs and microservices.
• Consider Functions for tasks like image or order processing, file maintenance, or for any tasks that you
want to run on a schedule.
• Azure Functions supports triggers, which are ways to start execution of your code, and bindings, which
are ways to simplify coding for input and output data.
About a dozen built-in binding types, write Large collection of connectors, Enterprise Integration
Connectivity
code for custom bindings Pack for B2B scenarios, build custom connectors
Each activity is an Azure function; write
Actions Large collection of ready-made actions
code for activity functions
Management REST API, Visual Studio Azure portal, REST API, PowerShell, Visual Studio
Execution context Can run locally or in the cloud Runs only in the cloud
When you create a function app in Azure, The hosting plan you choose dictates the
you must choose a hosting plan for your following behaviors:
app. • How your function app is scaled.
There are three basic hosting plans available for • The resources available to each function app
Azure Functions: instance.
• Consumption plan. • Support for advanced functionality, such as
• Functions Premium plan. Azure Virtual Network connectivity.
The following is a summary of the benefits of the three main hosting plans for Functions:
There are two other hosting options which provide the highest amount of control and isolation in which
to run your function apps: ASE and Kubernetes.
Overview
In the Consumption and Premium plans, Azure
Functions scales CPU and memory resources by
adding additional instances of the Functions host.
Runtime scaling
Azure Functions uses a component called the
scale controller to monitor the rate of events and
determine whether to scale out or scale in. The
scale controller uses heuristics for each trigger
type.
Scaling behaviors
Scaling can vary on a number of factors, and scale differently based on the trigger and language
selected. There are a few intricacies of scaling behaviors to be aware of:
• Maximum instances: A single function app only scales out to a maximum of 200 instances. A
single instance may process more than one message or request at a time though, so there isn't a
set limit on number of concurrent executions.
• New instance rate: For HTTP triggers, new instances are allocated, at most, once per second. For
non-HTTP triggers, new instances are allocated, at most, once every 30 seconds. Scaling is faster
when running in a Premium plan.
Overview
A function contains two important pieces: {
"disabled":false,
• Your code, which can be written in a variety of "bindings":[
languages // ... bindings here
• Some config, the function.json file. {
"type": "bindingType",
The function.json file defines the function's trigger, "direction": "in",
bindings, and other configuration settings. Every "name": "myParamName",
function has one and only one trigger. The runtime // ... more depending on binding
uses this config file to determine the events to }
monitor and how to pass data into and return data ]
}
from a function execution.
Function app
A function app provides an execution context in Azure in which your functions run.
• It is the unit of deployment and management for your functions.
• A function app is comprised of one or more individual functions that are managed, deployed, and
scaled together.
• All of the functions in a function app share the same pricing plan, deployment method, and runtime
version.
• Think of a function app as a way to organize and collectively manage your functions.
Overview
• Triggers are what cause a function to run. A trigger defines how a function is invoked and a function
must have exactly one trigger.
• Binding to a function is a way of declaratively connecting another resource to the function; bindings
may be connected as input bindings, output bindings, or both.
• You can mix and match different bindings to suit your needs.
• Triggers and bindings let you avoid hardcoding access to other services.
Binding direction
All triggers and bindings have a direction property in the function.json file:
• For triggers, the direction is always in
• Input and output bindings use in and out
• Some bindings support a special direction inout. If you use inout, only the Advanced editor is
available via the Integrate tab in the portal.
When you use attributes in a class library to configure triggers and bindings, the direction is provided in an
attribute constructor or inferred from the parameter type.
context.done(null, order);
};
function generateRandomId() {
return Math.random().toString(36).substring(2, 15) +
Math.random().toString(36).substring(2, 15);
}
Task1 : Create your local Task 2: Run the function Task 3: Sign in to Azure
project locally
Task 4 : Publish the project to Task 5: Run the function in Task 6: Clean up resources
Azure Azure
http://aka.ms/az204labs