| title | Create and deploy function code to Azure using Visual Studio Code | |||
|---|---|---|---|---|
| description | Learn how to create a function, then publish the local code project to serverless hosting in Azure Functions using the Azure Functions extension in Visual Studio Code. | |||
| ms.topic | quickstart | |||
| ms.date | 11/25/2025 | |||
| ms.update-cycle | 180-days | |||
| ms.custom |
|
|||
| ms.collection |
|
|||
| zone_pivot_groups | programming-languages-set-functions-full |
::: zone pivot="programming-language-csharp,programming-language-java,programming-language-javascript,programming-language-python,programming-language-powershell,programming-language-typescript"
Use Visual Studio Code to create a function that responds to HTTP requests from a template. Use GitHub Copilot to improve the generated function code, verify code updates locally, and then deploy it to the serverless Flex Consumption hosting plan in Azure Functions.
::: zone-end
::: zone pivot="programming-language-other"
Use Visual Studio Code to create a custom handler function that responds to HTTP requests. After verifying the code locally, you deploy it to the serverless Flex Consumption hosting plan in Azure Functions.
Custom handlers can be used to create functions in any language or runtime by running an HTTP server process. This article supports both Go and Rust.
::: zone-end
Completing this quickstart incurs a small cost of a few USD cents or less in your Azure account.
Make sure to select your preferred development language at the top of the article.
-
An Azure account with an active subscription. Create an account for free.
-
Visual Studio Code on one of the supported platforms.
-
The Azure Functions extension for Visual Studio Code. ::: zone pivot="programming-language-csharp"
-
C# extension for Visual Studio Code.
::: zone-end
::: zone pivot="programming-language-java" -
The Java Development Kit, version 8, 11, 17, or 21 (Linux-only).
-
Apache Maven, version 3.0 or above.
-
The Java extension pack
::: zone-end
::: zone pivot="programming-language-javascript,programming-language-typescript" -
Node.js 18.x or above. Use the
node --versioncommand to check your version. ::: zone-end ::: zone pivot="programming-language-powershell" -
The PowerShell extension for Visual Studio Code.
::: zone-end ::: zone pivot="programming-language-python" -
Python versions that are supported by Azure Functions. For more information, see How to install Python.
-
The Python extension for Visual Studio Code. ::: zone-end ::: zone pivot="programming-language-other"
- Go, latest version recommended. Use the
go versioncommand to check your version.
- Rust toolchain using rustup. Use the
rustc --versioncommand to check your version.
::: zone-end
[!INCLUDE functions-install-core-tools-vs-code]
In this section, you use Visual Studio Code to create a local Azure Functions project in your preferred language. Later in the article, you update, run, and then publish your function code to Azure.
-
In Visual Studio Code, press F1 to open the command palette. Search for and run the command
Azure Functions: Create New Project.... -
Choose the directory location for your project workspace and choose Select. You should either create a new folder or choose an empty folder for the project workspace. Don't choose a project folder that is already part of a workspace.
-
Provide the following information at the prompts: ::: zone pivot="programming-language-csharp"
Prompt Selection Select a language Choose C#.Select a .NET runtime Choose .NET 8.0 LTS.Select a template for your project's first function Choose HTTP trigger.Provide a function name Type HttpExample.Provide a namespace Type My.Functions.Authorization level Choose Function, which requires an access key to call your function endpoint. For more information, see Authorization level.Select how you would like to open your project Choose Open in current window.::: zone-end ::: zone pivot="programming-language-java"
Prompt Selection Select a language Choose Java.Select a version of Java Choose Java 8,Java 11,Java 17orJava 21, the Java version on which your functions run in Azure. Choose a Java version that you've verified locally.Provide a group ID Choose com.function.Provide an artifact ID Choose myFunction.Provide a version Choose 1.0-SNAPSHOT.Provide a package name Choose com.function.Provide an app name Choose myFunction-12345.Select a template for your project's first function Choose HTTP trigger.Select the build tool for Java project Choose Maven.Select how you would like to open your project Choose Open in current window.::: zone-end ::: zone pivot="programming-language-javascript"
Prompt Selection Select a language Choose JavaScript.Select a JavaScript programming model Choose Model V4.Select a template for your project's first function Choose HTTP trigger.Provide a function name Type HttpExample.Authorization level Choose Function, which requires an access key to call your function endpoint. For more information, see Authorization level.Select how you would like to open your project Choose Open in current window.::: zone-end ::: zone pivot="programming-language-typescript"
Prompt Selection Select a language Choose TypeScript.Select a JavaScript programming model Choose Model V4.Select a template for your project's first function Choose HTTP trigger.Provide a function name Type HttpExample.Authorization level Choose Function, which requires an access key to call your function endpoint. For more information, see Authorization level.Select how you would like to open your project Choose Open in current window.::: zone-end ::: zone pivot="programming-language-python"
Prompt Selection Select a language Choose Python.Select a Python interpreter to create a virtual environment Choose your preferred Python interpreter. If an option isn't shown, type in the full path to your Python binary. Select a template for your project's first function Choose HTTP trigger.Name of the function you want to create Enter HttpExample.Authorization level Choose FUNCTION, which requires an access key to call your function endpoint. For more information, see Authorization level.Select how you would like to open your project Choose Open in current window.::: zone-end ::: zone pivot="programming-language-powershell"
Prompt Selection Select a language for your function project Choose PowerShell.Select a template for your project's first function Choose HTTP trigger.Provide a function name Type HttpExample.Authorization level Choose Function, which requires an access key to call your function endpoint. For more information, see Authorization level.Select how you would like to open your project Choose Open in current window.::: zone-end ::: zone pivot="programming-language-other"
Prompt Selection Select a language for your function project Choose Custom Handler.Select a template for your project's first function Choose HTTP trigger.Provide a function name Type HttpExample.Authorization level Choose Function, which requires an access key to call your function endpoint. For more information, see Authorization level.Select how you would like to open your project Choose Open in current window.::: zone-end
Using this information, Visual Studio Code generates a code project for Azure Functions with an HTTP trigger function endpoint. You can view the local project files in the Explorer. To learn more about files that are created, see Generated project files.
::: zone pivot="programming-language-python"
4. In the local.settings.json file, update the AzureWebJobsStorage setting as in the following example:
```json
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
```
This setting tells the local Functions host to use the storage emulator for the storage connection required by the Python v2 model. When you publish your project to Azure, this setting uses the default storage account instead. If you use an Azure Storage account during local development, set your storage account connection string here.
-
In Visual Studio Code, press F1 to open the command palette. In the command palette, search for and select
Azurite: Start. -
Check the bottom bar and verify that Azurite emulation services are running. If so, you can now run your function locally. ::: zone-end ::: zone pivot="programming-language-other" [!INCLUDE functions-custom-handler-create-function-code]
::: zone-end
[!INCLUDE functions-run-function-test-local-vs-code]
::: zone pivot="programming-language-csharp,programming-language-java,programming-language-javascript,programming-language-python,programming-language-powershell,programming-language-typescript" After you verify that the function runs correctly on your local computer, you can optionally use AI tools, such as GitHub Copilot in Visual Studio Code, to update template-generated function code.
This example prompt for Copilot Chat updates the existing function code to retrieve parameters from either the query string or JSON body. It applies formatting or type conversions and returns the parameters as JSON in the response:
::: zone-end
::: zone pivot="programming-language-csharp"
Modify the function to accept name, email, and age from the JSON body of the
request. If any of these parameters are missing from the query string, read
them from the JSON body. Return all three parameters in the JSON response,
applying these rules:
Title-case the name
Lowercase the email
Convert age to an integer if possible, otherwise return "not provided"
Use sensible defaults if any parameter is missing
Make sure that any added packages are compatible with the version of the packages already in the project
::: zone-end
::: zone pivot="programming-language-javascript,programming-language-typescript,programming-language-powershell,programming-language-python"
Modify the function to accept name, email, and age from the JSON body of the
request. If any of these parameters are missing from the query string, read
them from the JSON body. Return all three parameters in the JSON response,
applying these rules:
Title-case the name
Lowercase the email
Convert age to an integer if possible, otherwise return "not provided"
Use sensible defaults if any parameter is missing
::: zone-end
::: zone pivot="programming-language-java"
Modify the function to accept name, email, and age from the JSON body of the
request. If any of these parameters are missing from the query string, read
them from the JSON body. Return all three parameters in the JSON response,
applying these rules:
Title-case the name
Lowercase the email
Convert age to an integer if possible, otherwise return "not provided"
Use sensible defaults if any parameter is missing
Update the FunctionTest.java file to test the new logic.
::: zone-end
::: zone pivot="programming-language-csharp,programming-language-java,programming-language-javascript,programming-language-python,programming-language-powershell,programming-language-typescript"
You can customize your prompt to add specifics as needed. Then run the app again locally and verify that it works as expected after the code changes. This time, use a message body like:
{ "name": "devon torres", "email": "[email protected]", "age": "34" }Tip
GitHub Copilot is powered by AI, so surprises and mistakes are possible. If you encounter any errors during execution, paste the error message in the chat window, select Agent mode, and ask Copilot to help resolve the error. For more information, see Copilot FAQs.
When running in Agent mode, the results of this customization depend on the specific tools available to your agent.
When you're satisfied with your app, use Visual Studio Code to publish the project directly to Azure. ::: zone-end ::: zone pivot="programming-language-other" After you verify that the function runs correctly on your local computer, use Visual Studio Code to publish the project directly to Azure. ::: zone-end
[!INCLUDE functions-sign-in-vs-code]
[!INCLUDE functions-create-azure-resources-vs-code]
::: zone pivot="programming-language-other"
In this section, you compile your project for deployment to Azure in a function app running Linux. In most cases, you need to recompile your binary and adjust your configuration to match the target platform before publishing it to Azure.
-
In the integrated terminal, compile the handler to Linux/x64.
GOOS=linux GOARCH=amd64 go build handler.go
GOOS=linux GOARCH=amd64 go build handler.go
set GOOS=linux set GOARCH=amd64 go build handler.go
Change the
defaultExecutablePathin host.json fromhandler.exetohandler. This change instructs the function app to run the Linux binary.
A binary named handler is created in the function app root.
-
Create a file at .cargo/config. Add the following contents and save the file.
[target.x86_64-unknown-linux-musl] linker = "rust-lld" -
In the integrated terminal, compile the handler to Linux/x64. A binary named
handleris created. Copy it to the function app root.rustup target add x86_64-unknown-linux-musl cargo build --release --target=x86_64-unknown-linux-musl cp target/x86_64-unknown-linux-musl/release/handler . -
If you're using Windows, change the
defaultExecutablePathin host.json fromhandler.exetohandler. This change instructs the function app to run the Linux binary. -
Add the following line to the .funcignore file:
targetThis line prevents publishing the contents of the target folder.
::: zone-end
[!INCLUDE functions-deploy-project-vs-code]
-
Press F1 to display the command palette, then search for and run the command
Azure Functions:Execute Function Now.... If prompted, select your subscription. -
Select your new function app resource and
HttpExampleas your function. -
In Enter request body type
{ "name": "Contoso", "email": "[email protected]", "age": "34" }, then press Enter to send this request message to your function. -
When the function executes in Azure, the response is displayed in the notification area. Expand the notification to review the full response.
Use the following table to resolve the most common issues encountered when using this article.
| Problem | Solution |
|---|---|
| Can't create a local function project? | Make sure you have the Azure Functions extension installed. |
| Can't run the function locally? | Make sure you have the latest version of Azure Functions Core Tools installed. When running on Windows, make sure that the default terminal shell for Visual Studio Code isn't set to WSL Bash. |
| Can't deploy function to Azure? | Review the Output for error information. The bell icon in the lower right corner is another way to view the output. Did you publish to an existing function app? That action overwrites the content of that app in Azure. |
| Couldn't run the cloud-based Function app? | Remember to use the query string to send in parameters, or use the request body for custom handlers. |
[!INCLUDE functions-cleanup-resources-vs-code.md]
::: zone pivot="programming-language-csharp,programming-language-java,programming-language-javascript,programming-language-python,programming-language-powershell,programming-language-typescript" You used Visual Studio Code to create a function app with a simple HTTP-triggered function. In the next articles, you expand that function by connecting to either Azure Cosmos DB or Azure Storage. To learn more about connecting to other Azure services, see Add bindings to an existing function in Azure Functions. If you want to learn more about security, see Securing Azure Functions.
[!div class="nextstepaction"] Connect to Azure Cosmos DB [!div class="nextstepaction"] Connect to Azure Queue Storage ::: zone-end
::: zone pivot="programming-language-other"
[!div class="nextstepaction"] Azure Functions custom handlers ::: zone-end