SlideShare una empresa de Scribd logo
1 de 37
An A-Z of Azure Functions
(for Office 365 scenarios)
Chris O’Brien (MVP)
Independent/Content and Code
Simpler than a Web Job or Web API!
Simple code hosting
Scenarios
• Button click (e.g. web part)
• Scheduled process
• Respond to event (e.g. new file in Azure)
Develop in any language
• C#, JavaScript, PHP, PowerShell (maybe)
Functions – use cases
(Bold items
are demo
scenarios)
Use case
Scheduled job (timer function)
Utility code with PnP
Call from SPFx web part
Call from PowerApps
Call from Flow
Site provisioning – site designs
Site provisioning – other
Also perfect for hiding
implementation/
secrets from client
FUNDAMENTALS – CREATING
FUNCTIONS
Visual Studio, VS Code, or CLI?
Approach Best for Why
Visual
Studio
C# functions • Easiest C# local
debugging
• Good all-rounder for
functions
Visual
Studio Code
Other languages (e.g.
JavaScript)
• Good JS debugging
support
• Natural fit for JS
development
CLI CI/CD scripts
Hipsters
• Debugging still needs VS
Code
https://cob-sp.com/
Azure-Functions-3-ways
Triggers - what causes me to run?
Trigger type Data to process
Timer
Queue
Azure BLOB – e.g. new file
HTTP (e.g. from a web
part/PowerApps/Flow)
Graph – OneDrive file, Excel row,
Outlook e-mail etc.
Event Grid
Cosmos DB
--- PLUS LOTS MORE ---
Triggers - what causes me to run?
Trigger type Data to process
Timer Schedule, if delayed run
Queue Queue message contents +
metadata
Azure BLOB – e.g. new file File metadata and contents
HTTP (e.g. from a web
part/PowerApps/Flow)
Data in URL/body/headers +
parameters passed
Graph – OneDrive file, Excel row,
Outlook e-mail etc.
Appropriate data
Event Grid Event data
Cosmos DB New/changed data
--- PLUS LOTS MORE ---
DEMO –
creating Azure
Functions
Demo recap
Create function app in Azure
•(but can be done in Visual Studio/VS Code)
Switch function to v1 (for now) if using CSOM/PnP libraries
Code
Debug locally
Publish to DEV Azure subscription
Deployment options
Drag and drop in browser (Kudu)
Publish from Visual Studio
WebDeploy
Source control integration (GitHub, Git, VS Online)
FTP
AZURE FUNCTIONS AND
POWERAPPS/FLOW
Custom connectors
Azure Functions and PowerApps/Flow
• Break out of constraints!
• Integrate custom data sources (e.g.
write back to HR system)
• Avoid doing crazy code-like things in a
Flow
Azure Functions and PowerApps/Flow -
process
Use in PowerApps/Flow
Create connector from connection – define security, make usable
Export to PowerApps/Flow
Create Open API definition – methods/parameters
Create Function and deploy
DEMO – Azure
Functions and
Flow
THINGS YOU SHOULD KNOW
v1 vs. v2, pricing, service plans, gotchas, cold starts..
Runtime versions 1 and 2
https://azure.microsoft.com/en-us/blog/introducing-azure-functions-2-0/
Azure Functions v1
Built on full .NET Framework
Less performant
Bindings internalised
Some languages experimental (e.g. PowerShell)
Slower cold starts
Azure Functions v2
Built on .NET Core
More performant
Bindings externalised
Language support clarified (no PowerShell for now!)
Faster cold starts
Consumption plan vs. App Service plan
Free (per month):
• 1 million executions
• 400,000 GB-sec
• (average memory size [gigabytes] * execution time [milliseconds])
Consumption plan App service plan
Serverless Runs on dedicated VMs
Pay for what you use (executions) Pay for containing VM
Great for intermittent/quicker jobs Great if running at high scale
Scale up automatically Scale at VM level
CHEAPER MORE EXPENSIVE (usually)
Consumption plan - BE AWARE
Function timeout = 5 minutes (can be increased to 10)
Function app limited to 1.5GB memory
Cold start - process goes idle after 20 mins
Possible delays in some triggers (e.g. new files)
App Service plan is different, because you’re running
on your own dedicated VMs..
Cold start
mitigation
strategies
OPTION 1 – make
sure your function
runs every 20 mins!
OPTION 2 – use my
“endpoint keep-warm”
solution or similar
OPTION 3 – use App
Insights
https://cob-sp.com/Azure-
Function-Warmup
Top gotchas
with Azure
Functions
• v1 is locked to Newtonsoft.Json 9.0.1 – so need to use v1
and SharePointPnPCoreOnline 2.24.1803 for now (.NET
Core versions soon!)
Using PnP Core and CSOM?
• Only possible when Function App exists but has no
functions!
Need to switch between v1/v2?
• Always store client object (e.g. HttpClient) as static variable
Making HTTP requests (e.g. to Graph) or other
connections?
• More versioning issues for now – resolved soon
Using MSI and Key Vault with PnP/CSOM?
• Take care with cold starts and timeouts
Need fast perf immediately?
SPFx web part -> Azure Function
Output bindings – codeless magic!
Example:
[FunctionName("QueueTrigger")]
[return: Blob("output-container/{id}")]
public static string
Run([QueueTrigger("inputqueue")]WorkItem
input, TraceWriter log)
{
string json = string.Format("{{ "id": "{0}"
}}", input.Id);
log.Info($"C# script processed queue
message. Item={json}");
return json;
}
Output bindings - your Function can
automatically:
• Add a queue item
• Create a file
• Add an item to a table in Azure Storage
• Make a HTTP call
• Create a OneDrive file
• Etc.
No code is required!
SITE DESIGNS AND AZURE
FUNCTIONS
Modern site provisioning
Site designs = modern site provisioning
Key benefits:
• Template sites for Microsoft
Teams and Office 365 Groups
and:
• Team sites
• Communication sites
• Hub sites
• Integrated into Office 365 UI
Site design capabilities
• Site settings – theme, logo, regional settings, permissions, external sharing
• Create lists and libraries (with columns, content types, views etc.)
• Install SPFx solution (e.g. web part)
• Register an SPFx extension (e.g. header, footer)
• Trigger a Flow
• Join a hub site (when site created from this template)
• Limited to 50 actions currently
But what happens when I need more?
• Answer – you plug in an Azure Function to apply a PnP template!
See https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/site-design-trigger-flow-tutorial
But what happens when I need more?
A simplified view:
See https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/site-design-trigger-flow-tutorial
Site design Flow
Adds item to
queue
Azure
Function
runs (queue
trigger)
Runs
code/applies
PnP
template
Add a Site Design/Site Script:
Integration – Site Design and Function
See https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/site-design-trigger-flow-tutorial
DEMO – Site
Designs and
Azure
Functions/PnP
Pimp your function! Enterprise use:
https://docs.microsoft.com/en-us/azure/app-
service/app-service-managed-service-identity
https://www.vrdmn.com/2018/07/using-managed-
service-identity-with-key.html
NuGet = Microsoft.ApplicationInsights
DURABLE FUNCTIONS
Durable Functions
See https://docs.microsoft.com/en-us/azure/azure-
functions/durable-functions-overview
• Pattern 1 - chaining:
• Beat the 5/10 minute timeout!
• Create site collection > apply partial PnP template
1 > apply partial PnP template 2 > finish
Orchestrator
function calls child
functions
Persist variables
across executions
Durable Functions
See https://docs.microsoft.com/en-us/azure/azure-
functions/durable-functions-overview
Orchestrator
function calls child
functions
Persist variables
across executions
• Pattern 2 – fan-out:
• Do lots of SharePoint updates at once! (but watch
for throttling/429s!)
Some things from me
https://cob-
sp.com/AzureFunctionsVideos
https://cob-sp.com/Azure-Functions-3-
ways
https://cob-sp.com/Azure-Function-
Warmup
Thank you!! 
Any questions?
www.sharepointnutsandbolts.com
@ChrisO_Brien
Summary
HTTP/timer functions
SPFx web partsSecurely calling a web API
PowerApps/Flow
Site Designs/provisioning
(inc. Teams)
Don’t wait for v2 CSOM/PnP
Current challenges are small
compared to benefits
Azure Functions are great for…

Más contenido relacionado

La actualidad más candente

Practical management of development & QA environments for SharePoint 2013
Practical management of development & QA environments for SharePoint 2013Practical management of development & QA environments for SharePoint 2013
Practical management of development & QA environments for SharePoint 2013
SharePointRadi
 

La actualidad más candente (20)

Chris O'Brien - Modern SharePoint sites and the SharePoint Framework - reference
Chris O'Brien - Modern SharePoint sites and the SharePoint Framework - referenceChris O'Brien - Modern SharePoint sites and the SharePoint Framework - reference
Chris O'Brien - Modern SharePoint sites and the SharePoint Framework - reference
 
Chris O'Brien - Ignite 2019 announcements and selected roadmaps
Chris O'Brien - Ignite 2019 announcements and selected roadmapsChris O'Brien - Ignite 2019 announcements and selected roadmaps
Chris O'Brien - Ignite 2019 announcements and selected roadmaps
 
Application Lifecycle Management for Office 365 development
Application Lifecycle Management for Office 365 developmentApplication Lifecycle Management for Office 365 development
Application Lifecycle Management for Office 365 development
 
Chris O'Brien - Modern SharePoint development: techniques for moving code off...
Chris O'Brien - Modern SharePoint development: techniques for moving code off...Chris O'Brien - Modern SharePoint development: techniques for moving code off...
Chris O'Brien - Modern SharePoint development: techniques for moving code off...
 
Practical management of development & QA environments for SharePoint 2013
Practical management of development & QA environments for SharePoint 2013Practical management of development & QA environments for SharePoint 2013
Practical management of development & QA environments for SharePoint 2013
 
ECS 19 - Chris O'Brien - The hit list - Office 365 dev techniques you should ...
ECS 19 - Chris O'Brien - The hit list - Office 365 dev techniques you should ...ECS 19 - Chris O'Brien - The hit list - Office 365 dev techniques you should ...
ECS 19 - Chris O'Brien - The hit list - Office 365 dev techniques you should ...
 
ECS19 - Nik Charlebois - Automate the Deployment & Monitoring of SharePoint w...
ECS19 - Nik Charlebois - Automate the Deployment & Monitoring of SharePoint w...ECS19 - Nik Charlebois - Automate the Deployment & Monitoring of SharePoint w...
ECS19 - Nik Charlebois - Automate the Deployment & Monitoring of SharePoint w...
 
ECS19 - Bill Ayers - UNLOCK YOUR BUSINESS KNOWLEDGE WITH THE MICROSOFT GRAPH,...
ECS19 - Bill Ayers - UNLOCK YOUR BUSINESS KNOWLEDGE WITH THE MICROSOFT GRAPH,...ECS19 - Bill Ayers - UNLOCK YOUR BUSINESS KNOWLEDGE WITH THE MICROSOFT GRAPH,...
ECS19 - Bill Ayers - UNLOCK YOUR BUSINESS KNOWLEDGE WITH THE MICROSOFT GRAPH,...
 
COB - PowerApps - the good, the bad and the ugly - early 2018
COB - PowerApps - the good, the bad and the ugly - early 2018COB - PowerApps - the good, the bad and the ugly - early 2018
COB - PowerApps - the good, the bad and the ugly - early 2018
 
Create SASSy web parts in SPFx
Create SASSy web parts in SPFxCreate SASSy web parts in SPFx
Create SASSy web parts in SPFx
 
Learn from my Mistakes - Building Better Solutions in SPFx
Learn from my  Mistakes - Building Better Solutions in SPFxLearn from my  Mistakes - Building Better Solutions in SPFx
Learn from my Mistakes - Building Better Solutions in SPFx
 
SPUnite17 Timer Jobs Event Handlers
SPUnite17 Timer Jobs Event HandlersSPUnite17 Timer Jobs Event Handlers
SPUnite17 Timer Jobs Event Handlers
 
SharePoint Development with the SharePoint Framework
SharePoint Development with the SharePoint FrameworkSharePoint Development with the SharePoint Framework
SharePoint Development with the SharePoint Framework
 
O365Con18 - Site Templates, Site Life Cycle Management and Modern SharePoint ...
O365Con18 - Site Templates, Site Life Cycle Management and Modern SharePoint ...O365Con18 - Site Templates, Site Life Cycle Management and Modern SharePoint ...
O365Con18 - Site Templates, Site Life Cycle Management and Modern SharePoint ...
 
[Pinto] Is my SharePoint Development team properly enlighted?
[Pinto] Is my SharePoint Development team properly enlighted?[Pinto] Is my SharePoint Development team properly enlighted?
[Pinto] Is my SharePoint Development team properly enlighted?
 
Modern SharePoint Development using Visual Studio Code
Modern SharePoint Development using Visual Studio CodeModern SharePoint Development using Visual Studio Code
Modern SharePoint Development using Visual Studio Code
 
[Struyf] Automate Your Tasks With Azure Functions
[Struyf] Automate Your Tasks With Azure Functions[Struyf] Automate Your Tasks With Azure Functions
[Struyf] Automate Your Tasks With Azure Functions
 
ECS19 - Damir Dobric - Designing and Operating modern applications with Micro...
ECS19 - Damir Dobric - Designing and Operating modern applications with Micro...ECS19 - Damir Dobric - Designing and Operating modern applications with Micro...
ECS19 - Damir Dobric - Designing and Operating modern applications with Micro...
 
Build a SharePoint website in 60 minutes
Build a SharePoint website in 60 minutesBuild a SharePoint website in 60 minutes
Build a SharePoint website in 60 minutes
 
ecs19 - Bill Ayers - RE-USE YOUR SHAREPOINT FRAMEWORK SKILLZ TO BUILD OFFICE ...
ecs19 - Bill Ayers - RE-USE YOUR SHAREPOINT FRAMEWORK SKILLZ TO BUILD OFFICE ...ecs19 - Bill Ayers - RE-USE YOUR SHAREPOINT FRAMEWORK SKILLZ TO BUILD OFFICE ...
ecs19 - Bill Ayers - RE-USE YOUR SHAREPOINT FRAMEWORK SKILLZ TO BUILD OFFICE ...
 

Similar a COB - Azure Functions for Office 365 developers

Spca2014 chris o brien modern share-point development - techniques for off-...
Spca2014 chris o brien   modern share-point development - techniques for off-...Spca2014 chris o brien   modern share-point development - techniques for off-...
Spca2014 chris o brien modern share-point development - techniques for off-...
NCCOMMS
 
Windows Azure & How to Deploy Wordress
Windows Azure & How to Deploy WordressWindows Azure & How to Deploy Wordress
Windows Azure & How to Deploy Wordress
George Kanellopoulos
 
Yo Office! Use your SPFx Skills to Build Add-Ins for Word, Excel, Outlook and...
Yo Office! Use your SPFx Skills to Build Add-Ins for Word, Excel, Outlook and...Yo Office! Use your SPFx Skills to Build Add-Ins for Word, Excel, Outlook and...
Yo Office! Use your SPFx Skills to Build Add-Ins for Word, Excel, Outlook and...
BIWUG
 

Similar a COB - Azure Functions for Office 365 developers (20)

Spca2014 chris o brien modern share-point development - techniques for off-...
Spca2014 chris o brien   modern share-point development - techniques for off-...Spca2014 chris o brien   modern share-point development - techniques for off-...
Spca2014 chris o brien modern share-point development - techniques for off-...
 
Windows Azure & How to Deploy Wordress
Windows Azure & How to Deploy WordressWindows Azure & How to Deploy Wordress
Windows Azure & How to Deploy Wordress
 
Updating Legacy SharePoint Customizations to the Add-in Model
Updating Legacy SharePoint Customizations to the Add-in ModelUpdating Legacy SharePoint Customizations to the Add-in Model
Updating Legacy SharePoint Customizations to the Add-in Model
 
Yo Office! Use your SPFx Skills to Build Add-Ins for Word, Excel, Outlook and...
Yo Office! Use your SPFx Skills to Build Add-Ins for Word, Excel, Outlook and...Yo Office! Use your SPFx Skills to Build Add-Ins for Word, Excel, Outlook and...
Yo Office! Use your SPFx Skills to Build Add-Ins for Word, Excel, Outlook and...
 
Vincent biret azure functions and flow (ottawa)
Vincent biret azure functions and flow (ottawa)Vincent biret azure functions and flow (ottawa)
Vincent biret azure functions and flow (ottawa)
 
Vincent biret azure functions and flow (toronto)
Vincent biret azure functions and flow (toronto)Vincent biret azure functions and flow (toronto)
Vincent biret azure functions and flow (toronto)
 
Cloudy in Indonesia: Java and Cloud
Cloudy in Indonesia: Java and CloudCloudy in Indonesia: Java and Cloud
Cloudy in Indonesia: Java and Cloud
 
SPUnite17 Building Great Client Side Web Parts with SPFx
SPUnite17 Building Great Client Side Web Parts with SPFxSPUnite17 Building Great Client Side Web Parts with SPFx
SPUnite17 Building Great Client Side Web Parts with SPFx
 
SharePoint Framework -The future of SharePoint/ Office 365 developer ecosystem.
SharePoint Framework -The future of SharePoint/ Office 365 developer ecosystem. SharePoint Framework -The future of SharePoint/ Office 365 developer ecosystem.
SharePoint Framework -The future of SharePoint/ Office 365 developer ecosystem.
 
Azure DevOps for JavaScript Developers
Azure DevOps for JavaScript DevelopersAzure DevOps for JavaScript Developers
Azure DevOps for JavaScript Developers
 
Real World SharePoint Framework and Azure Services
Real World SharePoint Framework and Azure ServicesReal World SharePoint Framework and Azure Services
Real World SharePoint Framework and Azure Services
 
Azure Functions @ global azure day 2017
Azure Functions  @ global azure day 2017Azure Functions  @ global azure day 2017
Azure Functions @ global azure day 2017
 
Azure Serverless Toolbox
Azure Serverless ToolboxAzure Serverless Toolbox
Azure Serverless Toolbox
 
Azure Functions Real World Examples
Azure Functions Real World Examples Azure Functions Real World Examples
Azure Functions Real World Examples
 
Web jobs, Azure Functions and Serverless Computing
Web jobs, Azure Functions and Serverless ComputingWeb jobs, Azure Functions and Serverless Computing
Web jobs, Azure Functions and Serverless Computing
 
How to convert your Full Trust Solutions to the SharePoint Framework (SPFx)
How to convert your Full Trust Solutions to the SharePoint Framework (SPFx)How to convert your Full Trust Solutions to the SharePoint Framework (SPFx)
How to convert your Full Trust Solutions to the SharePoint Framework (SPFx)
 
SPS calgary 2017 introduction to azure functions microsoft flow
SPS calgary 2017 introduction to azure functions microsoft flowSPS calgary 2017 introduction to azure functions microsoft flow
SPS calgary 2017 introduction to azure functions microsoft flow
 
Introduction to Office Development Topics
Introduction to Office Development TopicsIntroduction to Office Development Topics
Introduction to Office Development Topics
 
SPUnite17 Become a Developer Hero by Building Office Add ins
SPUnite17 Become a Developer Hero by Building Office Add insSPUnite17 Become a Developer Hero by Building Office Add ins
SPUnite17 Become a Developer Hero by Building Office Add ins
 
Real World SharePoint Framework and Azure Services
Real World SharePoint Framework and Azure ServicesReal World SharePoint Framework and Azure Services
Real World SharePoint Framework and Azure Services
 

Más de Chris O'Brien

Más de Chris O'Brien (16)

Chris OBrien - Azure DevOps for managing work
Chris OBrien - Azure DevOps for managing workChris OBrien - Azure DevOps for managing work
Chris OBrien - Azure DevOps for managing work
 
Chris O'Brien - Intro to Power BI for Office 365 devs (March 2017)
Chris O'Brien - Intro to Power BI for Office 365 devs (March 2017)Chris O'Brien - Intro to Power BI for Office 365 devs (March 2017)
Chris O'Brien - Intro to Power BI for Office 365 devs (March 2017)
 
Chris O'Brien - Introduction to the SharePoint Framework for developers
Chris O'Brien - Introduction to the SharePoint Framework for developersChris O'Brien - Introduction to the SharePoint Framework for developers
Chris O'Brien - Introduction to the SharePoint Framework for developers
 
Do's and don'ts for Office 365 development
Do's and don'ts for Office 365 developmentDo's and don'ts for Office 365 development
Do's and don'ts for Office 365 development
 
Chris O'Brien - Customizing the SharePoint/Office 365 UI with JavaScript (ESP...
Chris O'Brien - Customizing the SharePoint/Office 365 UI with JavaScript (ESP...Chris O'Brien - Customizing the SharePoint/Office 365 UI with JavaScript (ESP...
Chris O'Brien - Customizing the SharePoint/Office 365 UI with JavaScript (ESP...
 
Deep dive into SharePoint 2013 hosted apps - Chris OBrien
Deep dive into SharePoint 2013 hosted apps - Chris OBrienDeep dive into SharePoint 2013 hosted apps - Chris OBrien
Deep dive into SharePoint 2013 hosted apps - Chris OBrien
 
Customizing the SharePoint 2013 user interface with JavaScript - Chris OBrien
Customizing the SharePoint 2013 user interface with JavaScript - Chris OBrienCustomizing the SharePoint 2013 user interface with JavaScript - Chris OBrien
Customizing the SharePoint 2013 user interface with JavaScript - Chris OBrien
 
SP2013 for Developers - Chris O'Brien
SP2013 for Developers - Chris O'BrienSP2013 for Developers - Chris O'Brien
SP2013 for Developers - Chris O'Brien
 
Getting to grips with SharePoint 2013 apps - Chris O'Brien
Getting to grips with SharePoint 2013 apps - Chris O'BrienGetting to grips with SharePoint 2013 apps - Chris O'Brien
Getting to grips with SharePoint 2013 apps - Chris O'Brien
 
SharePoint Ribbon Deep Dive
SharePoint Ribbon Deep DiveSharePoint Ribbon Deep Dive
SharePoint Ribbon Deep Dive
 
Automated Builds And UI Testing in SharePoint 2010 Development
Automated Builds And UI Testing in SharePoint 2010 DevelopmentAutomated Builds And UI Testing in SharePoint 2010 Development
Automated Builds And UI Testing in SharePoint 2010 Development
 
Optimizing SharePoint 2010 Internet Sites
Optimizing SharePoint 2010 Internet SitesOptimizing SharePoint 2010 Internet Sites
Optimizing SharePoint 2010 Internet Sites
 
Managing the SharePoint 2010 Application Lifecycle - Part 2
Managing the SharePoint 2010 Application Lifecycle - Part 2Managing the SharePoint 2010 Application Lifecycle - Part 2
Managing the SharePoint 2010 Application Lifecycle - Part 2
 
Managing the SharePoint 2010 Application Lifecycle - Part 1
Managing the SharePoint 2010 Application Lifecycle - Part 1Managing the SharePoint 2010 Application Lifecycle - Part 1
Managing the SharePoint 2010 Application Lifecycle - Part 1
 
SharePoint workflow deep-dive
SharePoint workflow deep-dive SharePoint workflow deep-dive
SharePoint workflow deep-dive
 
SharePoint Web Content Management - Lessons Learnt/top 5 tips
SharePoint Web Content Management - Lessons Learnt/top 5 tipsSharePoint Web Content Management - Lessons Learnt/top 5 tips
SharePoint Web Content Management - Lessons Learnt/top 5 tips
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

COB - Azure Functions for Office 365 developers

  • 1. An A-Z of Azure Functions (for Office 365 scenarios) Chris O’Brien (MVP) Independent/Content and Code
  • 2. Simpler than a Web Job or Web API! Simple code hosting Scenarios • Button click (e.g. web part) • Scheduled process • Respond to event (e.g. new file in Azure) Develop in any language • C#, JavaScript, PHP, PowerShell (maybe)
  • 3. Functions – use cases (Bold items are demo scenarios) Use case Scheduled job (timer function) Utility code with PnP Call from SPFx web part Call from PowerApps Call from Flow Site provisioning – site designs Site provisioning – other Also perfect for hiding implementation/ secrets from client
  • 5. Visual Studio, VS Code, or CLI? Approach Best for Why Visual Studio C# functions • Easiest C# local debugging • Good all-rounder for functions Visual Studio Code Other languages (e.g. JavaScript) • Good JS debugging support • Natural fit for JS development CLI CI/CD scripts Hipsters • Debugging still needs VS Code https://cob-sp.com/ Azure-Functions-3-ways
  • 6. Triggers - what causes me to run? Trigger type Data to process Timer Queue Azure BLOB – e.g. new file HTTP (e.g. from a web part/PowerApps/Flow) Graph – OneDrive file, Excel row, Outlook e-mail etc. Event Grid Cosmos DB --- PLUS LOTS MORE ---
  • 7. Triggers - what causes me to run? Trigger type Data to process Timer Schedule, if delayed run Queue Queue message contents + metadata Azure BLOB – e.g. new file File metadata and contents HTTP (e.g. from a web part/PowerApps/Flow) Data in URL/body/headers + parameters passed Graph – OneDrive file, Excel row, Outlook e-mail etc. Appropriate data Event Grid Event data Cosmos DB New/changed data --- PLUS LOTS MORE ---
  • 9. Demo recap Create function app in Azure •(but can be done in Visual Studio/VS Code) Switch function to v1 (for now) if using CSOM/PnP libraries Code Debug locally Publish to DEV Azure subscription
  • 10. Deployment options Drag and drop in browser (Kudu) Publish from Visual Studio WebDeploy Source control integration (GitHub, Git, VS Online) FTP
  • 12. Azure Functions and PowerApps/Flow • Break out of constraints! • Integrate custom data sources (e.g. write back to HR system) • Avoid doing crazy code-like things in a Flow
  • 13. Azure Functions and PowerApps/Flow - process Use in PowerApps/Flow Create connector from connection – define security, make usable Export to PowerApps/Flow Create Open API definition – methods/parameters Create Function and deploy
  • 15. THINGS YOU SHOULD KNOW v1 vs. v2, pricing, service plans, gotchas, cold starts..
  • 16. Runtime versions 1 and 2 https://azure.microsoft.com/en-us/blog/introducing-azure-functions-2-0/ Azure Functions v1 Built on full .NET Framework Less performant Bindings internalised Some languages experimental (e.g. PowerShell) Slower cold starts Azure Functions v2 Built on .NET Core More performant Bindings externalised Language support clarified (no PowerShell for now!) Faster cold starts
  • 17. Consumption plan vs. App Service plan Free (per month): • 1 million executions • 400,000 GB-sec • (average memory size [gigabytes] * execution time [milliseconds]) Consumption plan App service plan Serverless Runs on dedicated VMs Pay for what you use (executions) Pay for containing VM Great for intermittent/quicker jobs Great if running at high scale Scale up automatically Scale at VM level CHEAPER MORE EXPENSIVE (usually)
  • 18. Consumption plan - BE AWARE Function timeout = 5 minutes (can be increased to 10) Function app limited to 1.5GB memory Cold start - process goes idle after 20 mins Possible delays in some triggers (e.g. new files) App Service plan is different, because you’re running on your own dedicated VMs..
  • 19.
  • 20. Cold start mitigation strategies OPTION 1 – make sure your function runs every 20 mins! OPTION 2 – use my “endpoint keep-warm” solution or similar OPTION 3 – use App Insights https://cob-sp.com/Azure- Function-Warmup
  • 21. Top gotchas with Azure Functions • v1 is locked to Newtonsoft.Json 9.0.1 – so need to use v1 and SharePointPnPCoreOnline 2.24.1803 for now (.NET Core versions soon!) Using PnP Core and CSOM? • Only possible when Function App exists but has no functions! Need to switch between v1/v2? • Always store client object (e.g. HttpClient) as static variable Making HTTP requests (e.g. to Graph) or other connections? • More versioning issues for now – resolved soon Using MSI and Key Vault with PnP/CSOM? • Take care with cold starts and timeouts Need fast perf immediately?
  • 22. SPFx web part -> Azure Function
  • 23. Output bindings – codeless magic! Example: [FunctionName("QueueTrigger")] [return: Blob("output-container/{id}")] public static string Run([QueueTrigger("inputqueue")]WorkItem input, TraceWriter log) { string json = string.Format("{{ "id": "{0}" }}", input.Id); log.Info($"C# script processed queue message. Item={json}"); return json; } Output bindings - your Function can automatically: • Add a queue item • Create a file • Add an item to a table in Azure Storage • Make a HTTP call • Create a OneDrive file • Etc. No code is required!
  • 24. SITE DESIGNS AND AZURE FUNCTIONS Modern site provisioning
  • 25. Site designs = modern site provisioning Key benefits: • Template sites for Microsoft Teams and Office 365 Groups and: • Team sites • Communication sites • Hub sites • Integrated into Office 365 UI
  • 26. Site design capabilities • Site settings – theme, logo, regional settings, permissions, external sharing • Create lists and libraries (with columns, content types, views etc.) • Install SPFx solution (e.g. web part) • Register an SPFx extension (e.g. header, footer) • Trigger a Flow • Join a hub site (when site created from this template) • Limited to 50 actions currently
  • 27. But what happens when I need more? • Answer – you plug in an Azure Function to apply a PnP template! See https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/site-design-trigger-flow-tutorial
  • 28. But what happens when I need more? A simplified view: See https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/site-design-trigger-flow-tutorial Site design Flow Adds item to queue Azure Function runs (queue trigger) Runs code/applies PnP template
  • 29. Add a Site Design/Site Script:
  • 30. Integration – Site Design and Function See https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/site-design-trigger-flow-tutorial
  • 31. DEMO – Site Designs and Azure Functions/PnP
  • 32. Pimp your function! Enterprise use: https://docs.microsoft.com/en-us/azure/app- service/app-service-managed-service-identity https://www.vrdmn.com/2018/07/using-managed- service-identity-with-key.html NuGet = Microsoft.ApplicationInsights
  • 34. Durable Functions See https://docs.microsoft.com/en-us/azure/azure- functions/durable-functions-overview • Pattern 1 - chaining: • Beat the 5/10 minute timeout! • Create site collection > apply partial PnP template 1 > apply partial PnP template 2 > finish Orchestrator function calls child functions Persist variables across executions
  • 35. Durable Functions See https://docs.microsoft.com/en-us/azure/azure- functions/durable-functions-overview Orchestrator function calls child functions Persist variables across executions • Pattern 2 – fan-out: • Do lots of SharePoint updates at once! (but watch for throttling/429s!)
  • 36. Some things from me https://cob- sp.com/AzureFunctionsVideos https://cob-sp.com/Azure-Functions-3- ways https://cob-sp.com/Azure-Function- Warmup Thank you!!  Any questions? www.sharepointnutsandbolts.com @ChrisO_Brien
  • 37. Summary HTTP/timer functions SPFx web partsSecurely calling a web API PowerApps/Flow Site Designs/provisioning (inc. Teams) Don’t wait for v2 CSOM/PnP Current challenges are small compared to benefits Azure Functions are great for…

Notas del editor

  1. To add your image, please insert your picture and scale it to be bigger than the size of the white box shown.