title | description | ms.topic | ms.date | ms.custom |
---|---|---|---|---|
Create your first function in the Azure portal |
Learn how to create your first Azure Function for serverless execution using the Azure portal. |
how-to |
03/26/2020 |
devx-track-csharp, mvc, devcenter, cc996988-fb4f-47 |
Azure Functions lets you run your code in a serverless environment without having to first create a virtual machine (VM) or publish a web application. In this article, you learn how to use Azure Functions to create a "hello world" HTTP trigger function in the Azure portal.
[!INCLUDE functions-in-portal-editing-note]
We instead recommend that you develop your functions locally and publish to a function app in Azure.
Use one of the following links to get started with your chosen local development environment and language:
Visual Studio Code | Terminal/command prompt | Visual Studio |
---|---|---|
• Get started with C# • Get started with Java • Get started with JavaScript • Get started with PowerShell • Get started with Python |
• Get started with C# • Get started with Java • Get started with JavaScript • Get started with PowerShell • Get started with Python |
Get started with C# |
[!INCLUDE quickstarts-free-trial-note]
Sign in to the Azure portal with your Azure account.
You must have a function app to host the execution of your functions. A function app lets you group functions as a logical unit for easier management, deployment, scaling, and sharing of resources.
[!INCLUDE Create function app Azure portal]
Next, create a function in the new function app.
-
From the left menu of the Functions window, select Functions, then select Add from the top menu.
-
From the Add Function window, select the Http trigger template.
-
Under Template details use
HttpExample
for New Function, choose Anonymous from the Authorization level drop-down list, and then select Add.Azure creates the HTTP trigger function. Now, you can run the new function by sending an HTTP request.
-
In your new HTTP trigger function, select Code + Test from the left menu, then select Get function URL from the top menu.
-
In the Get function URL dialog box, select default from the drop-down list, and then select the Copy to clipboard icon.
-
Paste the function URL into your browser's address bar. Add the query string value
?name=<your_name>
to the end of this URL and press Enter to run the request. The browser should display a response message that echoes back your query string value.If the request URL included an access key (
?code=...
), it means you choose Function instead of Anonymous access level when creating the function. In this case, you should instead append&name=<your_name>
. -
When your function runs, trace information is written to the logs. To see the trace output, return to the Code + Test page in the portal and expand the Logs arrow at the bottom of the page. Call your function again to see trace output written to the logs.
:::image type="content" source="media/functions-create-first-azure-function/function-view-logs.png" alt-text="Functions log viewer in the Azure portal":::
[!INCLUDE Clean-up resources]
[!INCLUDE Next steps note]