SlideShare ist ein Scribd-Unternehmen logo
1 von 35
#comdaybe




            Windows Azure Applications
                   Made API
                         AZUG
                    Kristof Rennen
Who Am I?
• Kristof Rennen

• Architect at Capgemini Belgium
• Microsoft Extended Experts Team Member
• Crew member of the Windows Azure User Group Azug

• http://www.kristofrennen.be
• @kristofrennen
Agenda
•   What is an API?
•   Do we need one?
•   ASP.NET Web API
•   It’s all about HTTP
•   API considerations
     –   Security
     –   Versioning
     –   Data formatting
     –   Design Guidelines
     –   Best practices
• Q&A
API’s
What is an API?
• Application Programming Interface
• Software-to-Software interface
• Contract between software and developers, a specification
   –   Offered functionalities
   –   Technical constraints (limits, ...)
   –   Constraints (legal, branding, ...)
   –   Use as offered by the vendor
• Programming instructions and standards
• Open services to other software developers (public or
  private)
Do we need one?
• Reach to scale
• Smartphone generation
• BYOD with 3 screens: phone, tablet and
  computer
• Self service
• Flexibility in providing content
• You have data to share
• Integration
Direct access
                Concerns
                • Caching
                • Less flexible & more error
                  prone
                • Tight coupling
                • Less transparent
                • Security (credentials and
                  connection string client
                  side)
Service based access
                  Answers
                  • Loose coupling, easy to
                    change
                  • Caching is easy
                  • Transparent
                  • Easily scalable
                  • Error handling
                  • Reusable
Build Richer Apps
Reach More Clients
API Growth




          + 100%   + 50% + 3400%   + 235% + 71%   + 86%   + 46%   + 63%


    Source: www.programmableweb.com – current APIs: 4535
ASP.NET Web API
• Part of ASP.NET MVC 4
• Framework to build HTTP Services (REST)
• Solid features
   –   Modern HTTP programming model
   –   Content negotiation (e.g. Xml, json, ...)
   –   Query composition (OData query support)
   –   Model binding and validation (conversion to .NET objects)
   –   Routes
   –   Filters (e.g. Validation, exception handling, ...)
   –   Testable
   –   IoC (service locator pattern)
   –   Flexible hosting (IIS, self hosting, ...)
It’s all about HTTP
It’s all about HTTP
•   HTTP = Web
•   Client / Server
•   Atomic
•   Cacheable
•   Uniform interface
•   Idempotence
•   Resources
HTTP Methods
•   GET: retrieval from server to client
•   HEAD: = GET but only headers
•   POST: append, annotate
•   PUT: storage from client to server
•   DELETE: remove identified resource
HTTP Codes
• Informational (1xx) (e.g. 100 - Continue)
• Successfull (2xx) (e.g. 200 - OK)
• Redirection (3xx) (e.g. 302 – Found)
• Client Error (4xx) (e.g. 401 –
  Unauthorized)
• Server Error (5xx) (e.g. 500 – Internal
  Server Error)
REST
• Representational State Transfer
• 6 constraints:
  –   Client / Server
  –   Stateless
  –   Cacheable
  –   Layered
  –   Code on demand
  –   Uniform interface
API Considerations
Security
•   Access protected resources
•   Identity, authentication and authorization
•   Content security
•   Use HTTPS if possible
•   Don’t transmit important content in plain text
•   Sanitize user inputs
Identity
• Who is making the API request?
• Usually a combination of a client id and a
  client secret
• Limit number of requests, data volume,
  ...
• Which application is making the request
• Stored within the app
Authentication
• OpenID
• Authentication
• Standard
• Identity providers and
  relying parties
• SAML, Certificates,
  Username / Password
Authorization
                • OAuth 2.0
                • Open Authorization
                • Standard
                • Share private
                  resources
                • Use of tokens:
                  specific resource,
                  specific right, specific
                  duration
Windows Azure?
                 Access Control Service
                 • Claim based
                 • Windows Identity
                   Foundation
                 • Identity providers:
                   facebook, google, yahoo,
                   live, adfs, openid
                 • OAuth 2.0 (draft)
Windows Azure?
Versioning
• Clients depent on a specific “version”
• Once public = never change
   – Don’t change resource URIs
   – Attribute / parameter position doesn’t matter
   – Accept and ignore unknown attributes / parameters
• Design the URL scheme properly
   – http://example.com/api/widgets.json (points to last version)
   – http://example.com/api/v1/widgets.json
   – http://example.com/api/v2/widgets.json
• Wait as long as possible to increase the version number
• Do your best to never, ever, break compatibility!
Windows Azure?
• Multi tenancy
• Web Api Routing
• Different version = different instance
Data Formatting
• Converts data between HTTP and Controller
  world
• Knows about media types (as value of the
  content-type header)
• Type of data sent in the body of the request and
  response
• Accept header to allow content negotiation
• Using MediaTypeFormatter implementations
  (custom implementation easy to add)
MediaTypeFormatter
• Knows about media types
• Tells API which content types are supported
• Can read and/or write
• Understands encoding and charset
• Has a stream to read (request) and to write
  (response)
• Uses serialization and deserialization
Windows Azure?
• Proper data formatting directly influences
  – Performance
  – Scalability
  – Throughput
  – Bandwidth
  – Cost
Design Guidelines
• Design your API for specific audiences
  (e.g. Developers, application users, ...)
• Differentiate your API (why would people
  use it)
• Easy to try, use and understand
• Less is more (start small)
• Documented
Best Practices
• API Health / Status page
  (https://dev.twitter.com/status)
• Monitoring and Metrics
• Documentation
  (https://dev.twitter.com/docs)
• Tryout console
  (https://dev.twitter.com/console)
• Throttling & Quotas
  (https://dev.twitter.com/docs/rate-limiting)
Takeaways
Keep in mind…
•   Make it secure (OpenID, OAuth, ACS, …)
•   Scale it separately
•   Document properly (methods, errors, codes, types, versions, …)
•   Grow piece by piece (start small)
•   Build a community (more developers = more apps)
•   Provision correct domains from the beginning
    – api.something.com
    – developer.something.com
    – something.com
• Version from the beginning (or don’t)
• Think about localization and globalization
Resources
• Books
   – API’s: A Strategy Guide
   – REST API Design Rulebook
   – Getting Started With OAuth 2.0
• Sites
   –   http://www.asp.net/web-api
   –   https://dev.twitter.com/
   –   https://developers.facebook.com/
   –   https://www.windowsazure.com/en-
       us/home/features/identity/
Q&A
Windows Azure Applications Made API

Thanks!                     @kristofrenne

Weitere ähnliche Inhalte

Kürzlich hochgeladen

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
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 DevelopmentsTrustArc
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
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?Antenna Manufacturer Coco
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
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 WorkerThousandEyes
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 

Kürzlich hochgeladen (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
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?
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

Empfohlen

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 

Empfohlen (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

Windows Azure Applications Made API

  • 1. #comdaybe Windows Azure Applications Made API AZUG Kristof Rennen
  • 2. Who Am I? • Kristof Rennen • Architect at Capgemini Belgium • Microsoft Extended Experts Team Member • Crew member of the Windows Azure User Group Azug • http://www.kristofrennen.be • @kristofrennen
  • 3. Agenda • What is an API? • Do we need one? • ASP.NET Web API • It’s all about HTTP • API considerations – Security – Versioning – Data formatting – Design Guidelines – Best practices • Q&A
  • 5. What is an API? • Application Programming Interface • Software-to-Software interface • Contract between software and developers, a specification – Offered functionalities – Technical constraints (limits, ...) – Constraints (legal, branding, ...) – Use as offered by the vendor • Programming instructions and standards • Open services to other software developers (public or private)
  • 6. Do we need one? • Reach to scale • Smartphone generation • BYOD with 3 screens: phone, tablet and computer • Self service • Flexibility in providing content • You have data to share • Integration
  • 7. Direct access Concerns • Caching • Less flexible & more error prone • Tight coupling • Less transparent • Security (credentials and connection string client side)
  • 8. Service based access Answers • Loose coupling, easy to change • Caching is easy • Transparent • Easily scalable • Error handling • Reusable
  • 9. Build Richer Apps Reach More Clients
  • 10. API Growth + 100% + 50% + 3400% + 235% + 71% + 86% + 46% + 63% Source: www.programmableweb.com – current APIs: 4535
  • 11. ASP.NET Web API • Part of ASP.NET MVC 4 • Framework to build HTTP Services (REST) • Solid features – Modern HTTP programming model – Content negotiation (e.g. Xml, json, ...) – Query composition (OData query support) – Model binding and validation (conversion to .NET objects) – Routes – Filters (e.g. Validation, exception handling, ...) – Testable – IoC (service locator pattern) – Flexible hosting (IIS, self hosting, ...)
  • 13. It’s all about HTTP • HTTP = Web • Client / Server • Atomic • Cacheable • Uniform interface • Idempotence • Resources
  • 14. HTTP Methods • GET: retrieval from server to client • HEAD: = GET but only headers • POST: append, annotate • PUT: storage from client to server • DELETE: remove identified resource
  • 15. HTTP Codes • Informational (1xx) (e.g. 100 - Continue) • Successfull (2xx) (e.g. 200 - OK) • Redirection (3xx) (e.g. 302 – Found) • Client Error (4xx) (e.g. 401 – Unauthorized) • Server Error (5xx) (e.g. 500 – Internal Server Error)
  • 16. REST • Representational State Transfer • 6 constraints: – Client / Server – Stateless – Cacheable – Layered – Code on demand – Uniform interface
  • 18. Security • Access protected resources • Identity, authentication and authorization • Content security • Use HTTPS if possible • Don’t transmit important content in plain text • Sanitize user inputs
  • 19. Identity • Who is making the API request? • Usually a combination of a client id and a client secret • Limit number of requests, data volume, ... • Which application is making the request • Stored within the app
  • 20. Authentication • OpenID • Authentication • Standard • Identity providers and relying parties • SAML, Certificates, Username / Password
  • 21. Authorization • OAuth 2.0 • Open Authorization • Standard • Share private resources • Use of tokens: specific resource, specific right, specific duration
  • 22. Windows Azure? Access Control Service • Claim based • Windows Identity Foundation • Identity providers: facebook, google, yahoo, live, adfs, openid • OAuth 2.0 (draft)
  • 24. Versioning • Clients depent on a specific “version” • Once public = never change – Don’t change resource URIs – Attribute / parameter position doesn’t matter – Accept and ignore unknown attributes / parameters • Design the URL scheme properly – http://example.com/api/widgets.json (points to last version) – http://example.com/api/v1/widgets.json – http://example.com/api/v2/widgets.json • Wait as long as possible to increase the version number • Do your best to never, ever, break compatibility!
  • 25. Windows Azure? • Multi tenancy • Web Api Routing • Different version = different instance
  • 26. Data Formatting • Converts data between HTTP and Controller world • Knows about media types (as value of the content-type header) • Type of data sent in the body of the request and response • Accept header to allow content negotiation • Using MediaTypeFormatter implementations (custom implementation easy to add)
  • 27. MediaTypeFormatter • Knows about media types • Tells API which content types are supported • Can read and/or write • Understands encoding and charset • Has a stream to read (request) and to write (response) • Uses serialization and deserialization
  • 28. Windows Azure? • Proper data formatting directly influences – Performance – Scalability – Throughput – Bandwidth – Cost
  • 29. Design Guidelines • Design your API for specific audiences (e.g. Developers, application users, ...) • Differentiate your API (why would people use it) • Easy to try, use and understand • Less is more (start small) • Documented
  • 30. Best Practices • API Health / Status page (https://dev.twitter.com/status) • Monitoring and Metrics • Documentation (https://dev.twitter.com/docs) • Tryout console (https://dev.twitter.com/console) • Throttling & Quotas (https://dev.twitter.com/docs/rate-limiting)
  • 32. Keep in mind… • Make it secure (OpenID, OAuth, ACS, …) • Scale it separately • Document properly (methods, errors, codes, types, versions, …) • Grow piece by piece (start small) • Build a community (more developers = more apps) • Provision correct domains from the beginning – api.something.com – developer.something.com – something.com • Version from the beginning (or don’t) • Think about localization and globalization
  • 33. Resources • Books – API’s: A Strategy Guide – REST API Design Rulebook – Getting Started With OAuth 2.0 • Sites – http://www.asp.net/web-api – https://dev.twitter.com/ – https://developers.facebook.com/ – https://www.windowsazure.com/en- us/home/features/identity/
  • 34. Q&A
  • 35. Windows Azure Applications Made API Thanks! @kristofrenne

Hinweis der Redaktion

  1. Maarten