SlideShare a Scribd company logo
#GlobalAzureTO
May 5th – 7th,2022
Microsoft is a proud sponsor of Global Azure in
Toronto on May 7th. We’re passionate about
supporting the developer community and invite
you to access valuable documentation and
training resources by visiting docs.microsoft.com
and the Microsoft Reactor.
Adastra transforms businesses into digital leaders. Since 2000,
Adastra has been helping global organizations accelerate
innovation, improve operational excellence, and create
unforgettable customer experiences, all with the power of their
data. By providing industry-leading Artificial Intelligence, Cloud,
Digital, and Governance services and solutions, Adastra helps
enterprises leverage data that they can manage and trust,
connecting them to their customers – and their customers to
the world. We have a proven track record of delivering
enterprise-grade solutions to Fortune 1000 and SME
organizations across all industries. More information can be
found at www.adastracorp.com.
#GlobalAzure
#GlobalAzureTO
About me
• 4x Microsoft MVP in Azure
• Consultant with Adastra specializing in App Migration, Modernization and an
Azure Lead
• 20+ years in enterprise development with Microsoft technologies
• Passionate about serverless and cloud-native application development
• Speaker at community events and meetups
• Blogging at https://TheFlyingMaverick.com
• Organizer of “Canada’s Technology Triangle .NET User Group” in Kitchener,
Ontario
Callon Campbell
Consultant | Solution Architect | Developer
Microsoft MVP in Azure
Agenda
• What does “serverless” mean?
• Azure Functions for serverless APIs
• Azure API Management and hosting Functions Apps
• Demos
• What’s next
• Wrap-up
Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions and Azure API Management.pptx
Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions and Azure API Management.pptx
Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions and Azure API Management.pptx
Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions and Azure API Management.pptx
Serverless on Azure
Consistent app, tooling, and runtime
Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions and Azure API Management.pptx
Function App plans
#GlobalAzure
#GlobalAzureTO
Building serverless Azure Function API with
OpenAPI
Demo 1
Create a new Function App
Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions and Azure API Management.pptx
Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions and Azure API Management.pptx
Evolving to serverless
API business model
Adapt, evolve, and allow faster
innovation to turn opportunities
into strategic advantages
• Create API gateway and developer
portal in minutes and publish APIs
easily for internal or external use
• Handle any data schema and adapt
quickly to rapid changes
• Connect to back-end services
anywhere and manage, secure, and
optimize all APIs in one place
API
API
developers
API
users
Developer
portal
Gateway
APIs running in Azure
Azure
Cosmos DB
Azure SQL
Database
Azure
Storage
Azure
Functions
APIs running
anywhere
External
services
Management
portal
Azure
Functions
Azure
Key Vault
Why use Azure API Management?
• Consolidate your APIs
• Centralize authentication
• Monitor usage & performance
• Unified paths
• Throttling & caching
• Input and output transformations
• Documentation and API testing
• API governance, insights and analytics
• Function Proxies is no longer supported
18
Protecting your APIs, there is a policy for that
• Encapsulate common API management functions
• Access control, Protection, Transformation, Caching, …
• Mutate request context or change API behavior
• Add a header or throttle for example
• Set in the inbound and outbound directions
• Applied at a variety of scopes or on error
• Scope determines which APIs are affected
• Can define custom scopes in addition to four available b default
• Composed into a pipeline from effective scopes
• Degree of control over inheritance of scopes, i.e. <base/> element
• Don’t delete <base/> inadvertently
http://aka.ms/apimpolicyexamples
Some common policies
• Rate Limiting
• Quota enforcing
• Check HTTP headers
• Restrict caller IP
• Validate JWT tokens
• Retrying (QoS)
• Masking URLs
• Defining cache policies
• Throttling
• CORS
• URL Rewriting
• XML < > JSON
Policy scopes
global
product
api
operation
inbound
outbound
to backend
from backend
from caller
to caller
GET /foo/bar HTTP/1.1
Host: api.constoso.com
Key: 0123456789
0123456789
/foo
/bar
CORS LOG
RATE QUOTA
JWT
CACHE URL BODY
Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions and Azure API Management.pptx
API Versioning & Revisions
Consumers choose
when to adopt
Providers choose
when to deploy
No one true way
Version or not?
Semantic versioning?
What is a breaking change?
Where to place version information?
Path? Query? Header? Media type?
How to identify version?
Number? Date? Name?
Approach
Versioning is an opt-in
Natively understand versions at the system level
Offer versioning scheme options
Inform developers about the changes
Control when the changes get adopted
Developer portal
• Auto-generated API catalog,
documentation, and code
samples
• Choose between managed
instance or self-hosted
• Available in
the Premium, Standard, Basic
and Developer tiers of API
Management
https://azure.microsoft.com/en-ca/pricing/details/api-management/
#GlobalAzure
#GlobalAzureTO
Building serverless Azure Function API with .NET
and Cosmos DB
Demo 2
Key Vault App Config
#GlobalAzure
#GlobalAzureTO
Hosting serverless APIs in APIM
Demo 3
Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions and Azure API Management.pptx
Scalability
• Functions – for the consumption and premium plans, HTTP requests
scale based on the traffic
• Cosmos DB – Throughput capacity for Cosmos DB is measured
in Request Units (RU). A 1-RU throughput corresponds to the
throughput need to GET a 1KB document
• API Management – API Management can scale out and supports rule-
based autoscaling. The scaling process takes at least 20 minutes
Disaster recovery and high availability
• API Management supports multi-region deployment
• Traffic Manager or Front Door can be used to route HTTP requests to
primary region, then fail over to the secondary region
• Cosmos DB supports multiple write regions. Enable multi-master and
have your Function App access the local instance
Security
• Don’t store application secrets like database credentials in your code
or configuration files
• Instead use App settings and/or more appropriate services like Key Vault
and/or App Configuration
• Lock down the Function App to only allow access from API
Management
• If using the premium function hosting model, you have VNET
integration
In summary
• Serverless is the next big thing for enterprise. Pick what works for you
• Serverless is more than just compute, functions, and app
development
• Easily create an API façade for the existing backend services
• Quickly add new capabilities to the APIs, such as response caching
and cross domain access
• Reliably protect published APIs from misuse and abuse
• Gain business and operational insights from analytics reports
Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions and Azure API Management.pptx
References
• Azure Functions
• API Management – Manage APIs | Microsoft Azure
• Azure Cosmos DB—Build Cloud-Native Applications | Microsoft Azure
• Serverless web application - Azure Reference Architectures |
Microsoft Docs
• https://github.com/Azure/azure-functions
• https://github.com/Azure/azure-functions-openapi-extension
• Azure API Management visually explained (maxivanov.io)
https://LinkedIn.com/in/CallonCampbell
@Flying_Maverick
Callon@CloudMavericks.ca
https://GitHub.com/CallonCampbell
Let’s connect
Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions and Azure API Management.pptx

More Related Content

Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions and Azure API Management.pptx

  • 2. Microsoft is a proud sponsor of Global Azure in Toronto on May 7th. We’re passionate about supporting the developer community and invite you to access valuable documentation and training resources by visiting docs.microsoft.com and the Microsoft Reactor. Adastra transforms businesses into digital leaders. Since 2000, Adastra has been helping global organizations accelerate innovation, improve operational excellence, and create unforgettable customer experiences, all with the power of their data. By providing industry-leading Artificial Intelligence, Cloud, Digital, and Governance services and solutions, Adastra helps enterprises leverage data that they can manage and trust, connecting them to their customers – and their customers to the world. We have a proven track record of delivering enterprise-grade solutions to Fortune 1000 and SME organizations across all industries. More information can be found at www.adastracorp.com.
  • 4. About me • 4x Microsoft MVP in Azure • Consultant with Adastra specializing in App Migration, Modernization and an Azure Lead • 20+ years in enterprise development with Microsoft technologies • Passionate about serverless and cloud-native application development • Speaker at community events and meetups • Blogging at https://TheFlyingMaverick.com • Organizer of “Canada’s Technology Triangle .NET User Group” in Kitchener, Ontario Callon Campbell Consultant | Solution Architect | Developer Microsoft MVP in Azure
  • 5. Agenda • What does “serverless” mean? • Azure Functions for serverless APIs • Azure API Management and hosting Functions Apps • Demos • What’s next • Wrap-up
  • 10. Serverless on Azure Consistent app, tooling, and runtime
  • 13. #GlobalAzure #GlobalAzureTO Building serverless Azure Function API with OpenAPI Demo 1
  • 14. Create a new Function App
  • 17. Evolving to serverless API business model Adapt, evolve, and allow faster innovation to turn opportunities into strategic advantages • Create API gateway and developer portal in minutes and publish APIs easily for internal or external use • Handle any data schema and adapt quickly to rapid changes • Connect to back-end services anywhere and manage, secure, and optimize all APIs in one place API API developers API users Developer portal Gateway APIs running in Azure Azure Cosmos DB Azure SQL Database Azure Storage Azure Functions APIs running anywhere External services Management portal Azure Functions Azure Key Vault
  • 18. Why use Azure API Management? • Consolidate your APIs • Centralize authentication • Monitor usage & performance • Unified paths • Throttling & caching • Input and output transformations • Documentation and API testing • API governance, insights and analytics • Function Proxies is no longer supported 18
  • 19. Protecting your APIs, there is a policy for that • Encapsulate common API management functions • Access control, Protection, Transformation, Caching, … • Mutate request context or change API behavior • Add a header or throttle for example • Set in the inbound and outbound directions • Applied at a variety of scopes or on error • Scope determines which APIs are affected • Can define custom scopes in addition to four available b default • Composed into a pipeline from effective scopes • Degree of control over inheritance of scopes, i.e. <base/> element • Don’t delete <base/> inadvertently http://aka.ms/apimpolicyexamples
  • 20. Some common policies • Rate Limiting • Quota enforcing • Check HTTP headers • Restrict caller IP • Validate JWT tokens • Retrying (QoS) • Masking URLs • Defining cache policies • Throttling • CORS • URL Rewriting • XML < > JSON
  • 21. Policy scopes global product api operation inbound outbound to backend from backend from caller to caller GET /foo/bar HTTP/1.1 Host: api.constoso.com Key: 0123456789 0123456789 /foo /bar CORS LOG RATE QUOTA JWT CACHE URL BODY
  • 23. API Versioning & Revisions Consumers choose when to adopt Providers choose when to deploy No one true way Version or not? Semantic versioning? What is a breaking change? Where to place version information? Path? Query? Header? Media type? How to identify version? Number? Date? Name? Approach Versioning is an opt-in Natively understand versions at the system level Offer versioning scheme options Inform developers about the changes Control when the changes get adopted
  • 24. Developer portal • Auto-generated API catalog, documentation, and code samples • Choose between managed instance or self-hosted • Available in the Premium, Standard, Basic and Developer tiers of API Management
  • 26. #GlobalAzure #GlobalAzureTO Building serverless Azure Function API with .NET and Cosmos DB Demo 2
  • 27. Key Vault App Config
  • 30. Scalability • Functions – for the consumption and premium plans, HTTP requests scale based on the traffic • Cosmos DB – Throughput capacity for Cosmos DB is measured in Request Units (RU). A 1-RU throughput corresponds to the throughput need to GET a 1KB document • API Management – API Management can scale out and supports rule- based autoscaling. The scaling process takes at least 20 minutes
  • 31. Disaster recovery and high availability • API Management supports multi-region deployment • Traffic Manager or Front Door can be used to route HTTP requests to primary region, then fail over to the secondary region • Cosmos DB supports multiple write regions. Enable multi-master and have your Function App access the local instance
  • 32. Security • Don’t store application secrets like database credentials in your code or configuration files • Instead use App settings and/or more appropriate services like Key Vault and/or App Configuration • Lock down the Function App to only allow access from API Management • If using the premium function hosting model, you have VNET integration
  • 33. In summary • Serverless is the next big thing for enterprise. Pick what works for you • Serverless is more than just compute, functions, and app development • Easily create an API façade for the existing backend services • Quickly add new capabilities to the APIs, such as response caching and cross domain access • Reliably protect published APIs from misuse and abuse • Gain business and operational insights from analytics reports
  • 35. References • Azure Functions • API Management – Manage APIs | Microsoft Azure • Azure Cosmos DB—Build Cloud-Native Applications | Microsoft Azure • Serverless web application - Azure Reference Architectures | Microsoft Docs • https://github.com/Azure/azure-functions • https://github.com/Azure/azure-functions-openapi-extension • Azure API Management visually explained (maxivanov.io)

Editor's Notes

  1. My name is Callon Campbell, I'm a 4 times Microsoft MVP in Azure. I’m also a consultant with Adastra specializing in App Migration, Modernization and an Azure Lead I have 20+ years in enterprise development with Microsoft technologies focused on Azure, .NET, and SQL I'm passionate about serverless and cloud-native application development and bringing those benefits to the enterprise. I'm a speaker at local community events, meetups and Global Azure.
  2. Serverless in 30sec. - It’s not like there are NO servers, you just don’t have to worry about infrastructure, that’s handled for you. - It will scale from not running to 1000s of instances and back down as needed. - As it scales you only pay for what you use.
  3. The tendency is to focus on event driven serverless offerings leveraging: API Management Event Grid Functions Logic Apps There are also data services like Cosmos DB But serverless in Azure is so much more… Cloud computing has opened new paradigms for enterprises to reach higher levels of productivity and scale. Serverless computing, is enabling developers, teams, and organizations to focus on business logic - leaving the hosting and scaling of resources to the cloud platform. By minimizing the time and resources you spend on infrastructure-related requirements, serverless allows you to deliver more value to the core of your business. This talk will center around leveraging Azure Functions for serverless APIs and hosting them in Azure API Management.
  4. Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. You can write just the code you need for the problem at hand, without worrying about a whole application or the infrastructure to run it. Functions can make development even more productive, using your development language of choice – such as C#, Java, JavaScript, PowerShell, and Python – and from any major platform (Windows, MacOS, Linux). Enjoy automated and flexible scaling based on your workload volume and pay just for what you use – keeping the focus on adding value instead of managing infrastructure. Functions is a great solution for building simple APIs and microservices, processing data, integrating systems, simplifying resources automation, and working with the internet-of-things (IoT). Consider Functions to extend existing applications through tasks like image or order processing, file maintenance, or for any tasks that you want to run on a schedule. Azure Functions integrates with various Azure and 3rd-party services. These services can trigger your function and start execution, or they can serve as input and output for your code. Orchestrate your serverless workflows programmatically (with Durable Functions, the Azure Functions runtime extension for stateful processes) and/or with a visual designer (using Functions with Logic Apps, thanks to the 200+ connectors with other Azure and 3rd party services). Use Functions extensions and templates on Visual Studio and Visual Studio Code for a faster and more efficient development on your local machine, fully integrated with the whole Azure platform. Develop using your favorite code editor and the Azure Functions Core Tools, with the exact same behavior you’ll have in the cloud service as you’ll be running its runtime locally – no similar or emulated experiences as seen in other platforms. Set up continuous integration and continuous delivery (CI/CD) with Azure Pipelines or GitHub, and get intelligent and proactive insights about the performance of applications in production from Azure Monitor. Pick the hosting plan that matches your business needs: Consumption plan (pay-per-execution), Premium plan (no cold start), App Service plan (including App Service Environment), Kubernetes (KEDA for event-driven containers), Azure Stack (on-premises), and IoT Edge (compute at the edge). Premium plan offering is now GA, and it allows you to run Functions without cold start by pre-warming instances, setting minimum and maximum scale values to ensure enough capacity on hand while retaining the network isolation, consistent performance and cost predictability of a dedicated hosting plan With PowerShell support in Azure Functions, you can set up serverless automation processes for infrastructure management and scripting tasks. Managing PowerShell modules is now easier than ever as the Azure Functions service will ensure the latest critical and security updates are automatically installed.
  5. There are 3 aspects to Azure Functions: 1. We have triggers, like HTTP requests but this could also be a timer or events from your favorite Azure services 2. Next we have your code which reacts to the trigger. Your code can be in many languages like C#, Java, NodeJS, Python, PowerShell and more. 3. Finally we have input and output bindings. This provides a means of pulling data or pushing data to other services.
  6. The new function is bootstrapped with the necessary implementation for OpenAPI support. When running the application, notice not only does the function emit the “Function1” endpoint as expected but also additional routes for a dynamic endpoint for OpenAPI document, Swagger document in JSON or YAML, Authentication redirects and the Swagger UI interactive app. The additional routes are encapsulated when the function app is deployed, meaning that they are there but not exposed as public viewable routes.
  7. Azure API Management is a managed service for publishing, securing, analyzing and managing your APIs. Azure API Management abstracts, protects and optimizes your APIs. Its cloud hosted, turnkey, and fully managed. Works with APIs running in the cloud or on-prem. Publish, secure and transform your APIs. Promotes and supports app developer engagement. Provides API governance, insights, and analytics.
  8. https://azure.microsoft.com/en-ca/pricing/details/api-management/
  9. Looking at this architecture we’ll be focusing on the API Management aspect which calls into an Azure Function app which is serving up a RESTful API that is connected to a Cosmos DB database. We’ll be using Application Insights for monitoring both our APIM Management instance and as well as our Function App. Finally we’ll be handling CI/CD with GitHub Actions to deploy our Function App and update the APIM as well.
  10. Functions. For the consumption plan, the HTTP trigger scales based on the traffic. There is a limit to the number of concurrent function instances, but each instance can process more than one request at a time. Cosmos DB. Throughput capacity for Cosmos DB is measured in Request Units (RU). A 1-RU throughput corresponds to the throughput need to GET a 1KB document. API Management. API Management can scale out and supports rule-based autoscaling. The scaling process takes at least 20 minutes. If your traffic is bursty, you should provision for the maximum burst traffic that you expect. However, autoscaling is useful for handling hourly or daily variations in traffic.
  11. The app of the future is cloud native and serverless is one of the key components of building cloud native applications which are designed to take full advantage of the latest innovation in public clou. Cloud native technology is how developers can achieve the agility, reliability, and security demanded by the next generation of applications. Thank you!