Azure Functions 簡介An introduction to Azure Functions

Azure Functions 是可在雲端輕鬆執行程式碼片段或「函數」的解決方案。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 可讓開發更有生產力,而且您可以使用您選擇的開發語言,例如 C#、Java、JavaScript、PowerShell 和 Python。Functions can make development even more productive, and you can use your development language of choice, such as C#, Java, JavaScript, PowerShell, and Python. 只需對您的程式碼執行的時間付費,並信任 Azure 視需要調整。Pay only for the time your code runs and trust Azure to scale as needed. Azure Functions 可讓您在 Microsoft Azure 上開發 無伺服器應用程式。Azure Functions lets you develop serverless applications on Microsoft Azure.

本主題提供 Azure Functions 的高階概觀。This topic provides a high-level overview of Azure Functions. 如果您想要直接進入正題並開始使用 Functions,請從 建立您的第一個 Azure Functions 著手。If you want to jump right in and get started with Functions, start with Create your first Azure Function. 如果您要尋找更多有關 Functions 的技術資訊,請參閱 開發人員參考If you are looking for more technical information about Functions, see the developer reference.


以下是 Functions 的一些主要功能︰Here are some key features of Functions:

  • 語言選擇 - 使用所選的 C#、Java、Javascript、Python 和其他語言撰寫函式。Choice of language - Write functions using your choice of C#, Java, Javascript, Python, and other languages. 如需完整清單,請參閱支援的語言See Supported languages for the complete list.
  • 使用即付費價格模式 - 只對執行您的程式碼所花的時間付費。Pay-per-use pricing model - Pay only for the time spent running your code. 請參閱價格區段中的使用情況主控方案選項。See the Consumption hosting plan option in the pricing section.
  • 自備相依性 - Functions 支援 NuGet 和 NPM,以便您使用您最愛的程式庫。Bring your own dependencies - Functions supports NuGet and NPM, so you can use your favorite libraries.
  • 整合式安全性 - 利用 OAuth 提供者 (如 Azure Active Directory、Facebook、Google、Twitter 和 Microsoft 帳戶) 保護 HTTP 觸發的函數。Integrated security - Protect HTTP-triggered functions with OAuth providers such as Azure Active Directory, Facebook, Google, Twitter, and Microsoft Account.
  • 簡化整合 - 輕鬆地利用 Azure 服務和軟體即服務 (SaaS) 供應項目。Simplified integration - Easily leverage Azure services and software-as-a-service (SaaS) offerings. 請參閱整合區段以取得相關範例。See the integrations section for some examples.
  • 彈性開發 - 直接在入口網站中撰寫函式的程式碼,或透過 GitHubAzure DevOps Services 與其他支援的開發工具設定連續整合並部署您的程式碼。Flexible development - Code your functions right in the portal or set up continuous integration and deploy your code through GitHub, Azure DevOps Services, and other supported development tools.
  • 開放原始碼 - Functions 執行階段是開放原始碼的平台並 可在 GitHub 上取得Open-source - The Functions runtime is open-source and available on GitHub.

我可以用 Functions 來做什麼?What can I do with Functions?

Functions 是處理資料、整合系統、使用物聯網 (IoT),以及建置簡單 API 和微服務的絕佳解決方案。Functions is a great solution for processing data, integrating systems, working with the internet-of-things (IoT), and building simple APIs and microservices. 考慮將 Functions 用於如下的工作:映像或訂單處理、檔案維護,或者您要排程執行的任何工作。Consider Functions for tasks like image or order processing, file maintenance, or for any tasks that you want to run on a schedule.

Functions 提供範本,可讓您開始使用重要的案例,包括下列案例︰Functions provides templates to get you started with key scenarios, including the following:

  • HTTPTrigger - 使用 HTTP 要求觸發程式碼的執行。HTTPTrigger - Trigger the execution of your code by using an HTTP request. 如需範例,請參閱建立您的第一個函式For an example, see Create your first function.
  • TimerTrigger - 在預先定義的排程執行清除或其他批次工作。TimerTrigger - Execute cleanup or other batch tasks on a predefined schedule. 如需範例,請參閱建立由計時器觸發的函式For an example, see Create a function triggered by a timer.
  • CosmosDBTrigger - 當 Azure Cosmos DB 文件在 NoSQL 資料庫的集合中新增或更新時進行處理。CosmosDBTrigger - Process Azure Cosmos DB documents when they are added or updated in collections in a NoSQL database. 如需詳細資訊,請參閱 Azure Cosmos DB 繫結For more information, see Azure Cosmos DB bindings.
  • BlobTrigger - 在新增至容器時,處理 Azure 儲存體 blob。BlobTrigger - Process Azure Storage blobs when they are added to containers. 您可以使用此函式調整映像大小。You might use this function for image resizing. 如需詳細資訊,請參閱 Blob 儲存體繫結For more information, see Blob storage bindings.
  • QueueTrigger - 在訊息送達 Azure 儲存體佇列中時回應。QueueTrigger - Respond to messages as they arrive in an Azure Storage queue. 如需詳細資訊,請參閱 Azure 佇列儲存體繫結For more information, see Azure Queue storage bindings.
  • EventGridTrigger - 回應傳遞到 Azure 事件方格中之訂用帳戶的事件。EventGridTrigger - Respond to events delivered to a subscription in Azure Event Grid. 支援可接收事件 (包含篩選) 的訂用帳戶型模型。Supports a subscription-based model for receiving events, which includes filtering. 適合建置事件型架構的解決方案。A good solution for building event-based architectures. 如需範例,請參閱使用事件方格自動調整已上傳映像的大小For an example, see Automate resizing uploaded images using Event Grid.
  • EventHubTrigger - 回應傳送到 Azure 事件中樞的事件。EventHubTrigger - Respond to events delivered to an Azure Event Hub. 特別適合用於應用程式檢測、使用者經驗或工作流程處理及物聯網 (IoT) 案例。Particularly useful in application instrumentation, user experience or workflow processing, and internet-of-things (IoT) scenarios. 如需詳細資訊,請參閱事件中樞繫結For more information, see Event Hubs bindings.
  • ServiceBusQueueTrigger - 將程式碼連接至其他 Azure 服務或內部部署服務,方法是接聽訊息佇列。ServiceBusQueueTrigger - Connect your code to other Azure services or on-premises services by listening to message queues. 如需詳細資訊,請參閱服務匯流排繫結For more information, see Service Bus bindings.
  • ServiceBusTopicTrigger - 將程式碼連接至其他 Azure 服務或內部部署服務,方法是訂閱主題。ServiceBusTopicTrigger - Connect your code to other Azure services or on-premises services by subscribing to topics. 如需詳細資訊,請參閱服務匯流排繫結For more information, see Service Bus bindings.

Azure Functions 支援「觸發」 ,這是開始執行您的程式碼的方式,以及「繫結」 ,這是針對輸入和輸出資料簡化編碼的方式。Azure Functions supports triggers, which are ways to start execution of your code, and bindings, which are ways to simplify coding for input and output data. 如需 Azure Functions 提供的觸發和繫結的詳細說明,請參閱 Azure Functions 觸發和繫結開發人員參考For a detailed description of the triggers and bindings that Azure Functions provides, see Azure Functions triggers and bindings developer reference.


Azure Functions 可以與各種 Azure 和協力廠商服務整合。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. Azure Functions 支援下列服務整合:The following service integrations are supported by Azure Functions:

  • Azure Cosmos DBAzure Cosmos DB
  • Azure 事件中心Azure Event Hubs
  • Azure Event GridAzure Event Grid
  • Azure 通知中心Azure Notification Hubs
  • Azure 服務匯流排 (佇列和主題)Azure Service Bus (queues and topics)
  • Azure 儲存體 (Blob、佇列和資料表)Azure Storage (blob, queues, and tables)
  • 內部部署 (使用服務匯流排)On-premises (using Service Bus)
  • Twilio (SMS 訊息)Twilio (SMS messages)

Functions 的計費方式How much does Functions cost?

Azure Functions 有兩種定價方案。Azure Functions has two kinds of pricing plans. 請選擇最符合您需求的方案:Choose the one that best fits your needs:

  • 使用情況方案:當您的函式執行時,Azure 會提供所有必要的運算資源。Consumption plan - When your function runs, Azure provides all of the necessary computational resources. 您不必擔心資源管理,您只需為您的程式碼執行時間支付費用。You don't have to worry about resource management, and you only pay for the time that your code runs.
  • App Service 方案 - 執行函式就像執行 Web 應用程式。App Service plan - Run your functions just like your web apps. 當您已準備對其他應用程式使用 App Service 時,您可以在相同方案上執行您的函數,不會產生額外的費用。When you are already using App Service for your other applications, you can run your functions on the same plan at no additional cost.

如需主控方案的詳細資訊,請參閱 Azure Functions 主控方案比較For more information about hosting plans, see Azure Functions hosting plan comparison. Functions 價格頁面上可取得完整的價格詳細資料。Full pricing details are available on the Functions Pricing page.

後續步驟Next Steps