Create your first Azure Function
Azure Functions is an event-driven, compute-on-demand experience that extends the existing Azure application platform with capabilities to implement code triggered by events occurring in other Azure services, SaaS products, and on-premises systems. With Azure Functions, your applications scale based on demand and you pay only for the resources you consume. Azure Functions enables you to create scheduled or triggered units of code implemented in various programming languages. To learn more about Azure Functions, see the Azure Functions Overview.
Watch the video
The following video shows how to perform the basic steps in this tutorial.
Create a function from the quickstart
A function app hosts the execution of your functions in Azure. Follow these steps to create a function app with the new function. The function app is created with a default configuration. For an example of how to explicitly create your function app, see the other Azure Functions quickstart tutorial.
Before you can create your first function, you need to have an active Azure account. If you don't already have an Azure account, free accounts are available.
- Go to the Azure Functions portal and sign-in with your Azure account.
- Type a unique Name for your new function app or accept the autogenerated one, select your preferred Region, then click Create + get started. Note that you must enter a valid name, which can contain only letters, numbers, and hyphens. Underscore (_) is not an allowed character.
- (Optional) At this point in the quickstart, you can choose to take a quick tour of Azure Functions features in the portal. After you have completed or skipped the tour, you can test your new function by using the HTTP trigger.
Test the function
Since the Azure Functions quickstarts contain functional code, you can immediately test your new function.
In the Develop tab, review the Code window and notice that this Node.js code expects an HTTP request with a name value passed either in the message body or in a query string. When the function runs, this value is returned in the response message.
Click Test to display the built-in HTTP test request pane for the function.
In the Request body text box, change the value of the name property to your name, and click Run. You see that execution is triggered by a test HTTP request, information is written to the logs, and the "hello..." response is displayed in the Output.
To trigger execution of the same function from an HTTP testing tool or from another browser window, copy the Function URL value from the Develop tab and paste it into the tool or browser address bar. Append the query string value
&name=yournameto the URL and execute the request. Note that the same information is written to the logs and the same string is contained in the body of the response message.
This quickstart demonstrates a simple execution of a basic HTTP-triggered function. To learn more about using Azure Functions in your apps, see the following topics:
- Best Practices for Azure Functions
- Azure Functions developer reference
Programmer reference for coding functions and defining triggers and bindings.
- Testing Azure Functions
Describes various tools and techniques for testing your functions.
- How to scale Azure Functions
Discusses service plans available with Azure Functions, including the Consumption hosting plan, and how to choose the right plan.
- What is Azure App Service?
Azure Functions uses the Azure App Service platform for core functionality like deployments, environment variables, and diagnostics.
Need some help?
Post questions in the Azure forums. - Visit MSDN
Tag questions with the keyword
azure-functions. - Visit Stack Overflow