Create Your First Azure Function
This tutorial guides you through creating your first Azure Function using the Azure portal. Azure Functions is a serverless compute service that enables you to run code on-demand without explicitly provisioning or managing infrastructure.
- An Azure account. If you don't have one, you can sign up for a free account.
- Basic understanding of programming concepts.

Step 1: Navigate to Azure Functions
Log in to the Azure portal. In the search bar at the top, type "Functions" and select Functions from the services list.
Step 2: Create a New Function App
A Function App is a logical container for your individual functions. To create one:
- On the Functions page, click + Create.
- Fill in the following details on the Basics tab:
- Subscription: Select your Azure subscription.
- Resource Group: Create a new one (e.g.,
MyFunctionResourceGroup
) or select an existing one. - Function App name: Enter a globally unique name (e.g.,
myfirstfunctionapp12345
). - Publish: Select Code.
- Runtime stack: Choose your preferred language (e.g., .NET, Node.js, Python). For this tutorial, let's assume you choose Node.js.
- Version: Select the appropriate version for your chosen runtime stack.
- Region: Choose a region close to you or your users.
- Click Review + create and then Create.
Step 3: Create Your First HTTP Trigger Function
Once your Function App is deployed, navigate to it. Then, follow these steps to create a simple HTTP-triggered function:
- In your Function App, select Functions from the left-hand menu.
- Click + Create.
- Under Development environment, select Develop in portal.
- Under Select a template, choose the HTTP trigger template.
- Give your function a name, such as
MyHttpTriggerFunction
. - Set the Authorization level to Anonymous for easy testing (you can change this later for more secure scenarios).
- Click Create.
Step 4: Test Your Function
Your new function is now deployed and ready to be tested.
- In your function's page, select Get Function URL from the top menu.
- Copy the generated URL.
- Paste the URL into your web browser's address bar and press Enter.
You should see a response similar to:
Hello, Azure Functions! This HTTP triggered function executed successfully.
You can also test by appending a name
query parameter to the URL:
[Your_Function_URL]?name=World
The response should be:
Hello, World! This HTTP triggered function executed successfully.
Step 5: Explore the Code
Click on Code + Test in the left-hand menu for your function. You'll see the code for your HTTP trigger function. For a Node.js function, it might look like this:
module.exports = async function (context, req) {
context.log('JavaScript HTTP trigger function processed a request.');
const name = (req.query.name || (req.body && req.body.name));
const responseMessage = name
? 'Hello, ' + name + '! This HTTP triggered function executed successfully.'
: 'This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.';
context.res = {
// status: 200, /* Defaults to 200 */
body: responseMessage
};
};
Next Steps
Congratulations! You've successfully created and tested your first Azure Function. Here are some ideas for what to do next:
- Explore different trigger types (e.g., Timer, Queue).
- Learn about input and output bindings to integrate with other Azure services.
- Deploy your functions from a local development environment using Azure CLI or Visual Studio Code.
- Implement more complex logic and handle errors gracefully.