API 管理入門

Azure API Management

Fiodar Sazanavets

Senior Software Engineer at Microsoft

REST API 概觀

  • API = Application Programming Interface
    • 用於軟體應用之間的溝通
  • REST = Representational State Transfer

    • 透過網際網路擷取資料的架構風格
    • 例如:部署在行動裝置或 PC 的 app 如何從網路上的伺服器擷取資料。
  • REST API 依操作類型使用不同的 HTTP 方法,如 GET、POST、DELETE 等。

HTTP 請求

Azure API Management

REST 端點類型

  • GET 讀取資料
  • POST 建立新資料
  • PUT 更新既有資料
  • DELETE 刪除資料

API 端點

Azure API Management

端點類型:天氣 app 範例

天氣 app 範例.png

  • GET: App 向伺服器請求並取得天氣資料
  • POST: 使用者將 Paris 存為最愛
    • 使用者開啟 app 時自動送出 GET 請求
  • PUT: 將最愛城市由 Paris 更新為 London
  • DELETE: 刪除 London 作為最愛城市
Azure API Management

REST 原則

  • 無狀態:伺服器不儲存狀態資料
  • 使用 JSON 或 XML 傳輸資料
  • 遵循 RESTful 架構
  • 例:擷取天氣

天氣範例.png

Azure API Management

在 Azure 託管 REST API

  • Azure App Services
  • Azure Container Apps
  • Azure Function Apps
  • 其他 Azure Web 服務

Azure App Service

Azure Container App

Azure Function App

Azure API Management

Azure API Management(APIM)概觀

API Management 標誌

  • 大型應用含複雜 API,管理不易
  • APIM 旨在讓 API 管理更簡單
Azure API Management

APIM 如何運作

  • APIM 是 API 閘道
  • 位於 API 與用戶端之間
  • 集中管理 API 安全性
  • 監控效能
  • 強制執行原則與規則

API Management 功能

Azure API Management

設定 APIM

  • 建立 API Management 執行個體
  • 匯入 API
  • 設定原則

API Management 連線

Azure API Management

APIM 支援的 API

  • RestAPIs、WebSockets、gRPC 等

APIM 支援的 API

Azure API Management

一起來練習吧!

Azure API Management

Preparing Video For Download...