SlideShare a Scribd company logo
Elio Struyf
Architect @ Valo – MVP
November 15th, 2018
Automate your tasks through
Azure Functions
O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
No hamsters are involved in the
process of running your functions
#SPSOslo - @eliostruyf
What is Serverless?
• Abstraction of servers
• AKA: FaaS (Function as a Service)
• Event-driven / instant scale
• Pay-per-use
• Micro-services → decouple monolithic applications
• No permanent storage, or it has to live somewhere else
O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
Azure Functions
• Running pieces of code / scripts in the cloud
• Use the language of your preference
• Runs on Azure App Services
Use cases
• Timer function
• Call from SPFx web part
• Call from site design / flow
• …
Azure Functions vs Web Jobs
Similarities
• Both can be scheduled or use a trigger (queue/blob/etc.)
• Both support C#, JavaScript, PS
Differences
• Pricing
• Development flexibility
• Easier to call Azure Functions (HTTP Trigger)
• It has its own UI in Azure
• Restrictions: 10 minutes timeout
Azure Functions – Pricing plans
Consumption plan
• € 0,17 per one million requests
• Scales up automatically
• Useful for smaller workloads
• Max. timeout of 10 minutes
App Service Plan
• Depends on the chosen plan
• You’re in control of scaling
• Faster / higher workload
• Timeout: 30 min. (can be unlimited)
Turn on: always on!host.json
{
"functionTimeout": "00:10:00"
}
What to know before you start creating them
• Functions should be stateless
• Function app can only use a single language
• Think about what triggers are required for your functions
• Need to call your functions from an application, try using ngrok
• Avoid long running operations / split them in multiple ones
#SPSOslo - @eliostruyf
Demo:
Checking out the portal
#SPSOslo - @eliostruyf
Security
Security options
Simple function authentication
• A code passed to the function
• On function level or app/admin level
https://<app-name>.azurewebsites.net/api/<function>?code=<code>
Azure AD Authentication
• Use OAuth token to call the function
• Great use in combination with SPFx solutions: AadHttpClient
Local development
Local development options
Any stack / editor / platform
• azure-functions-core-tools
• Node.js
Visual Studio
• True C# functions
• Azure development workload
Useful CLI commands
• func init → initialize a new project
• func new → create a new function
• func host start → start up the functions runtime
• func azure functionapp fetch-app-settings <function-name>
• func azure storage fetch-connection-string <storage-name>
Debugging your functions
• Run: func host start
• Press F5 in Visual Studio Code and execute your function
#SPSOslo - @eliostruyf
Demo:
Writing your first Azure Function
#SPSOslo - @eliostruyf
Dependencies
#SPSOslo - @eliostruyf
Importing dependencies
• Node.js → npm install
• Make sure you create a
package.json file (npm init)
• Best to be placed on the root level
• C#
• Use NuGet like you are used using it
Function A
function.json
index.ts
node_modules
Function B
function.json
index.ts
node_modules
package.json
node_modules
#SPSOslo - @eliostruyf
Working with environment
variables
#SPSOslo - @eliostruyf
Working with environment variables
• Local development: local.settings.json
• On Azure: Application settings
In code
• Node.js
• process.env.<setting-name>
• C#
• GetEnvironmentVariable("<setting-name>")
#SPSOslo - @eliostruyf
Bindings
#SPSOslo - @eliostruyf
Working with bindings
Blob storage
Cosmos DB
Storage queue
Service bus
HTTP
…
Input
Blob storage
Cosmos DB
Storage queue
SendGrid
Twilio
…
Output
Function
Queues are great for…
Anything that should be picked up by a longer running task
• SharePoint site provisioning
• SharePoint web hooks
• File processing (e.g. image size optimization)
QueueTrigger function
• Auto-runs your code when a message gets added
• If fails, it retries
Queues are great for…
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Queue triggeredHTTP Triggered
Item 1
#SPSOslo - @eliostruyf
func extensions install
Working with bindings
Add your bindings to the function.json file
{
"disabled": false,
"bindings": [{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req"
},
{
"type": "queue",
"name": "spfxversions",
"direction": "out",
"queueName": "versions",
"connection": "AzureWebJobsStorage"
}
}
#SPSOslo - @eliostruyf
Demo:
Creating settings and bindings
#SPSOslo - @eliostruyf
Deployment
Deployment options
• Publish from Visual Studio
• CLI: func azure functionapp publish <function-name>
• Use local GIT repository
• Continuous deployment via Azure DevOps
Do not forget to configure
your settings
#SPSOslo - @eliostruyf
Cold start
What happens during a cold start
Azure allocates
server
Worker
becomes
specialized
Function
runtime
resets
Function
loaded into
memory
code runs
When function is already warmed-up
Azure allocates
server
Worker
becomes
specialized
Function
runtime
resets
Function
loaded into
memory
code runs
Optimizing the cold start
• KISS
• Precompile C# created functions
• Not use the *.csx files
• Use Visual Studio + Azure development workload
• Use Azure Functions Pack for Node.js
• https://github.com/Azure/azure-functions-pack
• Uses Webpack
• Add your dependencies at root level of the host!
#SPSOslo - @eliostruyf
Demo:
Deployment via local GIT repo
#SPSOslo - @eliostruyf
Troubleshooting
#SPSOslo - @eliostruyf
Troubleshooting
Check the linked Application Insights
Check Kudu (advanced tools)
Push debug build (only in DEV - slots) & attach the VS remote debugger
Try to reproduce it in your local version
#SPSOslo - @eliostruyf
What’s next?
#SPSOslo - @eliostruyf
Durable functions
• Extension on top of Azure Functions and WebJobs
• Write stateful functions
• Waiting for human interaction
Questions?
Office Servers & Services MVP
Azure / Office 365 / SharePoint
@eliostruyf
www.eliostruyf.com
info@estruyf.be
Elio Struyf
Developer & Architect
#SPSOslo - @eliostruyf

More Related Content

PDF
O365Con18 - Implementing Automated UI Testing for SharePoint Solutions - Elio...
PDF
O365Con18 - Working with PowerShell, VS Code and GitHub - Thomas Vochten
PDF
SPUnite17 Timer Jobs Event Handlers
PDF
O365Con18 - PowerApps build custom forms for SharePoint with Azure Maps - Bra...
PPTX
Azure serverless architectures
PPTX
Serverless Application Development with Azure
PPTX
Azure Functions - Introduction
PDF
O365Con18 - Git and GitHub - Rick van Rousselt
O365Con18 - Implementing Automated UI Testing for SharePoint Solutions - Elio...
O365Con18 - Working with PowerShell, VS Code and GitHub - Thomas Vochten
SPUnite17 Timer Jobs Event Handlers
O365Con18 - PowerApps build custom forms for SharePoint with Azure Maps - Bra...
Azure serverless architectures
Serverless Application Development with Azure
Azure Functions - Introduction
O365Con18 - Git and GitHub - Rick van Rousselt

What's hot (20)

PPTX
Serverless in Azure with Functions
PDF
[Struyf] Automate Your Tasks With Azure Functions
PDF
O365Con18 - Site Templates, Site Life Cycle Management and Modern SharePoint ...
PPTX
Azure Functions @ global azure day 2017
PPTX
Serverless with Azure Functions
PPTX
[Pinto] Is my SharePoint Development team properly enlighted?
PPTX
[Roine] Serverless: Don't Take It Literally
PPTX
Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx)
PPTX
APIs, APIs Everywhere!
PPTX
[Patel] SPFx: An ISV Insight into latest Microsoft's customization model
PPTX
Azure Functions Real World Examples
PPTX
Chris O'Brien - Best bits of Azure for Office 365/SharePoint developers
PPTX
Azure functions
PPTX
Logic Apps – Deployments
PPTX
Introduction to Azure Functions - Tutorial
PPTX
Going Serverless with Azure Functions
PPTX
Ecs19 - Hans Brender - Is OneDrive Really Enterprise Ready
PPTX
Tokyo Azure Meetup #7 - Introduction to Serverless Architectures with Azure F...
PDF
O365Con18 - Hybrid SharePoint Deep Dive - Thomas Vochten
PDF
O365Con18 - Reach for the Cloud Build Solutions with the Power of Microsoft G...
Serverless in Azure with Functions
[Struyf] Automate Your Tasks With Azure Functions
O365Con18 - Site Templates, Site Life Cycle Management and Modern SharePoint ...
Azure Functions @ global azure day 2017
Serverless with Azure Functions
[Pinto] Is my SharePoint Development team properly enlighted?
[Roine] Serverless: Don't Take It Literally
Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx)
APIs, APIs Everywhere!
[Patel] SPFx: An ISV Insight into latest Microsoft's customization model
Azure Functions Real World Examples
Chris O'Brien - Best bits of Azure for Office 365/SharePoint developers
Azure functions
Logic Apps – Deployments
Introduction to Azure Functions - Tutorial
Going Serverless with Azure Functions
Ecs19 - Hans Brender - Is OneDrive Really Enterprise Ready
Tokyo Azure Meetup #7 - Introduction to Serverless Architectures with Azure F...
O365Con18 - Hybrid SharePoint Deep Dive - Thomas Vochten
O365Con18 - Reach for the Cloud Build Solutions with the Power of Microsoft G...
Ad

Similar to O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf (20)

PPTX
COB - Azure Functions for Office 365 developers
PPTX
Era of server less computing
PPTX
Play with azure functions
PPTX
Era of server less computing final
PPTX
Going Serverless with Azure Functions #1 - Introduction to Azure Functions
PPTX
Azure functions: from a function to a whole application in 60 minutes
PPTX
Azure Functions in Action #CodePaLOUsa
PPTX
Azure Functions in Action #OrlandoCC
PPTX
Scalable APIs with Azure Functions
PDF
Azure web functions little bites of services
PDF
Getting Started with Serverless Architectures using Azure Functions
PPTX
Azure Functions.pptx
PPTX
Building API in the cloud using Azure Functions
PDF
Azure Functions
PPTX
Serverless on Azure with Functions
PPTX
Alex Thissen "Server-less compute with .NET based Azure Functions"
PPTX
Introduction to Azure Functions
PPTX
Azure Functions & Serverless Computing
PPTX
#SpFestSea azr203 Azure functions lessons learned
PPTX
Deep Dive Azure Functions - Global Azure Bootcamp 2019
COB - Azure Functions for Office 365 developers
Era of server less computing
Play with azure functions
Era of server less computing final
Going Serverless with Azure Functions #1 - Introduction to Azure Functions
Azure functions: from a function to a whole application in 60 minutes
Azure Functions in Action #CodePaLOUsa
Azure Functions in Action #OrlandoCC
Scalable APIs with Azure Functions
Azure web functions little bites of services
Getting Started with Serverless Architectures using Azure Functions
Azure Functions.pptx
Building API in the cloud using Azure Functions
Azure Functions
Serverless on Azure with Functions
Alex Thissen "Server-less compute with .NET based Azure Functions"
Introduction to Azure Functions
Azure Functions & Serverless Computing
#SpFestSea azr203 Azure functions lessons learned
Deep Dive Azure Functions - Global Azure Bootcamp 2019
Ad

More from NCCOMMS (20)

PDF
O365Con19 - UI:UX 101 Learn How to Design Custom Experiences for SharePoint -...
PDF
O365Con19 - Model-driven Apps or Canvas Apps? - Rick Bakker
PDF
O365Con19 - Office 365 Groups Surviving the Real World - Jasper Oosterveld
PDF
O365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis Jugo
PDF
O365Con19 - Sharepoint with (Artificial) Intelligence - Adis Jugo
PDF
O365Con19 - What Do You Mean 90 days Isn't Enough - Paul Hunt
PDF
O365Con19 - Tips and Tricks for Complex Migrations to SharePoint Online - And...
PDF
O365Con19 - Start Developing Teams Tabs and SharePoint Webparts with SPFX - O...
PDF
O365Con19 - Start Your Journey from Skype for Business to Teams - Sasja Beere...
PDF
O365Con19 - Lets Get Started with Azure Container Instances - Jussi Roine
PDF
O365Con19 - Azure Blackbelt - Jussi Roine
PDF
O365Con19 - Customise the UI in Modern SharePoint Workspaces - Corinna Lins
PDF
O365Con19 - Be The Protagonist of Your Modern Workplace - Corinna Lins
PDF
O365Con19 - How to Really Manage all your Tasks Across Microsoft 365 - Luise ...
PDF
O365Con19 - Sharing Code Efficiently in your Organisation - Elio Struyf
PDF
O365Con19 - Things I've Learned While Building a Product on SharePoint Modern...
PDF
O365Con19 - Keep Control of Your Data with AIP and CA - Bram de Jager
PDF
O365Con19 - Kaizala a Dive Into the Unknown - Rick van Rousselt
PDF
O365Con19 - How to Inspire Users to Unstick from Email - Luise Freese
PDF
O365Con19 - O365 Identity Management and The Golden Config - Chris Goosen
O365Con19 - UI:UX 101 Learn How to Design Custom Experiences for SharePoint -...
O365Con19 - Model-driven Apps or Canvas Apps? - Rick Bakker
O365Con19 - Office 365 Groups Surviving the Real World - Jasper Oosterveld
O365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis Jugo
O365Con19 - Sharepoint with (Artificial) Intelligence - Adis Jugo
O365Con19 - What Do You Mean 90 days Isn't Enough - Paul Hunt
O365Con19 - Tips and Tricks for Complex Migrations to SharePoint Online - And...
O365Con19 - Start Developing Teams Tabs and SharePoint Webparts with SPFX - O...
O365Con19 - Start Your Journey from Skype for Business to Teams - Sasja Beere...
O365Con19 - Lets Get Started with Azure Container Instances - Jussi Roine
O365Con19 - Azure Blackbelt - Jussi Roine
O365Con19 - Customise the UI in Modern SharePoint Workspaces - Corinna Lins
O365Con19 - Be The Protagonist of Your Modern Workplace - Corinna Lins
O365Con19 - How to Really Manage all your Tasks Across Microsoft 365 - Luise ...
O365Con19 - Sharing Code Efficiently in your Organisation - Elio Struyf
O365Con19 - Things I've Learned While Building a Product on SharePoint Modern...
O365Con19 - Keep Control of Your Data with AIP and CA - Bram de Jager
O365Con19 - Kaizala a Dive Into the Unknown - Rick van Rousselt
O365Con19 - How to Inspire Users to Unstick from Email - Luise Freese
O365Con19 - O365 Identity Management and The Golden Config - Chris Goosen

Recently uploaded (20)

PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
Tartificialntelligence_presentation.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Getting Started with Data Integration: FME Form 101
PDF
Approach and Philosophy of On baking technology
PPTX
A Presentation on Artificial Intelligence
PPT
Teaching material agriculture food technology
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Machine learning based COVID-19 study performance prediction
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PPTX
Spectroscopy.pptx food analysis technology
PDF
Mushroom cultivation and it's methods.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Univ-Connecticut-ChatGPT-Presentaion.pdf
Group 1 Presentation -Planning and Decision Making .pptx
Empathic Computing: Creating Shared Understanding
NewMind AI Weekly Chronicles - August'25-Week II
Tartificialntelligence_presentation.pptx
Programs and apps: productivity, graphics, security and other tools
Getting Started with Data Integration: FME Form 101
Approach and Philosophy of On baking technology
A Presentation on Artificial Intelligence
Teaching material agriculture food technology
Assigned Numbers - 2025 - Bluetooth® Document
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Machine learning based COVID-19 study performance prediction
Per capita expenditure prediction using model stacking based on satellite ima...
SOPHOS-XG Firewall Administrator PPT.pptx
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Spectroscopy.pptx food analysis technology
Mushroom cultivation and it's methods.pdf

O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf

  • 1. Elio Struyf Architect @ Valo – MVP November 15th, 2018 Automate your tasks through Azure Functions
  • 4. No hamsters are involved in the process of running your functions
  • 5. #SPSOslo - @eliostruyf What is Serverless? • Abstraction of servers • AKA: FaaS (Function as a Service) • Event-driven / instant scale • Pay-per-use • Micro-services → decouple monolithic applications • No permanent storage, or it has to live somewhere else
  • 7. Azure Functions • Running pieces of code / scripts in the cloud • Use the language of your preference • Runs on Azure App Services Use cases • Timer function • Call from SPFx web part • Call from site design / flow • …
  • 8. Azure Functions vs Web Jobs Similarities • Both can be scheduled or use a trigger (queue/blob/etc.) • Both support C#, JavaScript, PS Differences • Pricing • Development flexibility • Easier to call Azure Functions (HTTP Trigger) • It has its own UI in Azure • Restrictions: 10 minutes timeout
  • 9. Azure Functions – Pricing plans Consumption plan • € 0,17 per one million requests • Scales up automatically • Useful for smaller workloads • Max. timeout of 10 minutes App Service Plan • Depends on the chosen plan • You’re in control of scaling • Faster / higher workload • Timeout: 30 min. (can be unlimited) Turn on: always on!host.json { "functionTimeout": "00:10:00" }
  • 10. What to know before you start creating them • Functions should be stateless • Function app can only use a single language • Think about what triggers are required for your functions • Need to call your functions from an application, try using ngrok • Avoid long running operations / split them in multiple ones
  • 13. Security options Simple function authentication • A code passed to the function • On function level or app/admin level https://<app-name>.azurewebsites.net/api/<function>?code=<code> Azure AD Authentication • Use OAuth token to call the function • Great use in combination with SPFx solutions: AadHttpClient
  • 15. Local development options Any stack / editor / platform • azure-functions-core-tools • Node.js Visual Studio • True C# functions • Azure development workload
  • 16. Useful CLI commands • func init → initialize a new project • func new → create a new function • func host start → start up the functions runtime • func azure functionapp fetch-app-settings <function-name> • func azure storage fetch-connection-string <storage-name>
  • 17. Debugging your functions • Run: func host start • Press F5 in Visual Studio Code and execute your function
  • 18. #SPSOslo - @eliostruyf Demo: Writing your first Azure Function
  • 20. #SPSOslo - @eliostruyf Importing dependencies • Node.js → npm install • Make sure you create a package.json file (npm init) • Best to be placed on the root level • C# • Use NuGet like you are used using it Function A function.json index.ts node_modules Function B function.json index.ts node_modules package.json node_modules
  • 21. #SPSOslo - @eliostruyf Working with environment variables
  • 22. #SPSOslo - @eliostruyf Working with environment variables • Local development: local.settings.json • On Azure: Application settings In code • Node.js • process.env.<setting-name> • C# • GetEnvironmentVariable("<setting-name>")
  • 24. #SPSOslo - @eliostruyf Working with bindings Blob storage Cosmos DB Storage queue Service bus HTTP … Input Blob storage Cosmos DB Storage queue SendGrid Twilio … Output Function
  • 25. Queues are great for… Anything that should be picked up by a longer running task • SharePoint site provisioning • SharePoint web hooks • File processing (e.g. image size optimization) QueueTrigger function • Auto-runs your code when a message gets added • If fails, it retries
  • 26. Queues are great for… Item 1 Item 2 Item 3 Item 4 Item 5 Item 6 Queue triggeredHTTP Triggered Item 1
  • 27. #SPSOslo - @eliostruyf func extensions install
  • 28. Working with bindings Add your bindings to the function.json file { "disabled": false, "bindings": [{ "authLevel": "function", "type": "httpTrigger", "direction": "in", "name": "req" }, { "type": "queue", "name": "spfxversions", "direction": "out", "queueName": "versions", "connection": "AzureWebJobsStorage" } }
  • 29. #SPSOslo - @eliostruyf Demo: Creating settings and bindings
  • 31. Deployment options • Publish from Visual Studio • CLI: func azure functionapp publish <function-name> • Use local GIT repository • Continuous deployment via Azure DevOps
  • 32. Do not forget to configure your settings
  • 34. What happens during a cold start Azure allocates server Worker becomes specialized Function runtime resets Function loaded into memory code runs
  • 35. When function is already warmed-up Azure allocates server Worker becomes specialized Function runtime resets Function loaded into memory code runs
  • 36. Optimizing the cold start • KISS • Precompile C# created functions • Not use the *.csx files • Use Visual Studio + Azure development workload • Use Azure Functions Pack for Node.js • https://github.com/Azure/azure-functions-pack • Uses Webpack • Add your dependencies at root level of the host!
  • 39. #SPSOslo - @eliostruyf Troubleshooting Check the linked Application Insights Check Kudu (advanced tools) Push debug build (only in DEV - slots) & attach the VS remote debugger Try to reproduce it in your local version
  • 41. #SPSOslo - @eliostruyf Durable functions • Extension on top of Azure Functions and WebJobs • Write stateful functions • Waiting for human interaction
  • 43. Office Servers & Services MVP Azure / Office 365 / SharePoint @eliostruyf www.eliostruyf.com [email protected] Elio Struyf Developer & Architect