Tokyo Azure Meetup #14 - Azure Functions Proxies

Post on 05-Apr-2017

57 views 3 download

Transcript of Tokyo Azure Meetup #14 - Azure Functions Proxies

Azure Functions Proxies

Kanio Dimitrov

Process events with Serverless code architecture

An event-based Serverless compute experiences to accelerate your development. It can scale on demand and

you pay only for the resource you consume.

Main Characteristics• Serverless

• Accelerate development

• Bind to Services

• Rich Language Support

• Pay only for what you use

Scenarios• Time-based

Processing

• Azure Service Event Processing

Scenarios

• SaaS Event Processing

• Serverless web app

Scenarios

• Serverless Mobile Backend

• Real-time stream processing

Scenarios

• Real-time bot messaging

Azure Functions vs Web Jobs

Triggers Binging Outputs Dynamic Plan Serverless -> Azure Functions

Comparison

Monolith

Client app.js

GET /games

GET /users

Pros:• Speed of

development

Cons:• Tighter coupling• Complexity

Microservices

Client users.js

GET /users

POST /users

DELETE /users/:id

Client games.js

GET /games

POST /games

DELETE /games/:id

Pros:• Separation of

concerns• Less Complexity

Cons:• Slower deployments

NanoservicesClient get_users.js

GET /users Pros:• Greater separation

of concerns• Even Less

Complexity

Cons:• Event Slower

deployments

Client delete_users.jsDELETE /users/:id

Client get_games.jsGET /games

Client delete_game.jsDELETE /games/:id

Hybrid

Client users.jsGET /users

DELETE /users/:id

Client get_games.jsGET /games

Client delete_game.jsDELETE /games/:id

API Development with Azure Functions• Difficult to manage large solution in single function app

• Deployment isolation between individual components

• Works for triggers, but difficult for APIs

• Each app has a host name, difficult to track

• Difficult for clients, especially when switching for testing

Azure Functions Proxies (Preview)• Easier to develop APIs by using Azure Functions• Define API surface for multiple functions apps • Any endpoint can endpoint as reverse proxy to another

API:• Same function app• Another function app• API App• Any API

Demo – Create First Azure Functions Proxy

Modifying Backend Requests - Request Parameters

• Parmeters from route template as inputs for backend URL property

• User “{}”:• Proxy - /pets/{petId}• Backend – https://<app>.azurewebsites.net/api/pets/{petId}

• Wildcard• Proxy - /api/{*restOfPath}• restOfPath – string representation of the remaining path segments from

incoming request

Modifying backend requests - Using application settings

• Reference app settings by surrounding the setting name with ‘%’

• In https://%ORDER_PROCESSING_HOST%/api/orders, ORDER_PROCESSING_HOST is coming from app settings

• Use app settings for backend hosts when multiple deployments or test environments

Demo – Modifying Backend Requests

Demo – Versioning

Deployment • Configuration stored in proxies.json

Azure Functions Proxies vs API Management

Topic Azure Functions Proxies

API Management

Focus API Development Packaging and Selling APIs

Features Routing (for now) Advanced (throttling,

security, caching)Price Cheaper (pay per

use)Monthly Fee

Architecture

Mobile AppAPI

Management

Azure Functions

ProxyAPI APP

Function App

REST Endpoint