開發 Azure Functions

Azure App Services

Florin Angelescu

Azure Cloud Architect

什麼是觸發程序?

$$

Function App Triggers

  • 定義函式如何被觸發
  • 函式可回應:
    • HTTP 請求
    • 佇列中的訊息
    • 檔案上傳
  • 每個函式必須有一個觸發程序
Azure App Services

常見觸發類型

Function HTTP Trigger

Function Timer Trigger

Function Queue Trigger

Function File Trigger

Azure App Services

什麼是繫結?

 

 

Function Bindings

  • 簡化連接外部資料與服務
  • 整合在幕後自動處理
  • 保持程式碼精簡,無需額外基礎架構管理
Azure App Services

輸入 vs. 輸出繫結

 

Function Input Binding

  • 自動接收 blob 檔或資料庫紀錄

 

Function Output Binding

  • Cosmos DB、Event Hubs,或電子郵件供應商
Azure App Services

輸入 vs. 輸出繫結

 

Function Bindings

Azure App Services

多重繫結

Function Multiple Bindings

Function Multiple Bindings

Azure App Services

實務範例

 

Function Bindings

  • 使用者上傳影像:
    • blob 觸發程序啟動函式
  • 輸入繫結將影像提供給函式
  • 函式可以:
    • 調整圖片大小
    • 新增標籤
  • 然後輸出繫結可以:
    • 儲存已更新影像
    • 在 Cosmos DB 紀錄中繼資料
    • 傳送通知
Azure App Services

一起來練習吧!

Azure App Services

Preparing Video For Download...