You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Press <kbd>F1</kbd> to display the command palette, then search for and run the command `Azure Functions:Execute Function Now...`. If prompted, select your subscription.
335
+
336
+
2. Select your new function app resource and `HttpExample` as your function.
337
+
338
+
3. In **Enter request body** type `{ "name": "Azure" }`, then press Enter to send this request message to your function.
339
+
340
+
4. When the function executes in Azure, the response is displayed in the notification area. Expand the notification to review the full response.
In this article, you use local command-line tools to create a function that responds to HTTP requests. After verifying your code locally, you deploy it to a serverless Flex Consumption hosting plan in Azure Functions.
13
13
14
-
Completing this quickstart incurs a small cost of a few USD cents or less in your Azure account.
14
+
Completing this quickstart incurs a small cost of a few USD cents or less in your Azure account.
15
+
16
+
Make sure to select your preferred development language at the top of the article.
Copy file name to clipboardExpand all lines: articles/azure-functions/how-to-create-function-vs-code.md
+28-13Lines changed: 28 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,25 @@
1
1
---
2
-
title: Create a JavaScript function using Visual Studio Code - Azure Functions
3
-
description: Learn how to create a JavaScript function, then publish the local Node.js project to serverless hosting in Azure Functions using the Azure Functions extension in Visual Studio Code.
2
+
title: Create and deploy function code to Azure using Visual Studio Code
3
+
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.
# Quickstart: Create a function in Azure using Visual Studio Code
15
+
# Quickstart: Create and deploy function code to Azure using Visual Studio Code
11
16
12
-
Use Visual Studio Code to create a function that responds to HTTP requests. Test the codelocally, then deploy it to the serverless environment of Azure Functions.
17
+
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.
13
18
14
19
Completing this quickstart incurs a small cost of a few USD cents or less in your Azure account.
15
20
21
+
Make sure to select your preferred development language at the top of the article.
@@ -21,7 +28,7 @@ Completing this quickstart incurs a small cost of a few USD cents or less in you
21
28
22
29
## <aname="create-an-azure-functions-project"></a>Create your local project
23
30
24
-
In this section, you use Visual Studio Code to create a local Azure Functions project in JavaScript. Later in this article, you publish your function code to Azure.
31
+
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.
25
32
26
33
1. In Visual Studio Code, press <kbd>F1</kbd> to open the command palette and search for and run the command `Azure Functions: Create New Project...`.
27
34
@@ -135,19 +142,19 @@ After you verify that the function runs correctly on your local computer, you ca
135
142
This is an example prompt for Copilot Chat that updates the existing function code to retrieve parameters from either the query string or JSON body, apply formatting or type conversions, and return them as JSON in the response:
136
143
137
144
```copilot-prompt
138
-
Modify the function to accept name, email, and age from either the query parameters or the JSON body of the request, whichever is available. Return all three parameters in the JSON response, applying these rules:
145
+
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:
139
146
Title-case the name
140
147
Lowercase the email
141
-
Convert age to an integer, otherwise return "not provided"
148
+
Convert age to an integer if possible, otherwise return "not provided"
142
149
Use sensible defaults if any parameter is missing
143
150
```
144
151
145
-
You can customize your prompt to add specifics as needed.
146
-
147
152
> [!TIP]
148
-
> The rest of the article assumes that you can continue to use a GET command to call your endpoint. Should GitHub Copilot update your app to require data be sent in the message `body`, you must also have a [secure HTTP test tool](functions-develop-local.md#http-test-tools) to submit POST requests with data in the message body when calling the `httpexample` endpoint.
153
+
> GitHub Copilot is powered by AI, so surprises and mistakes are possible. For more information, see [Copilot FAQs](https://aka.ms/copilot-general-use-faqs).
149
154
150
-
GitHub Copilot is powered by AI, so surprises and mistakes are possible. For more information, see [Copilot FAQs](https://aka.ms/copilot-general-use-faqs). When you are satistfied with your app, you can use Visual Studio Code to publish the project directly to Azure.
155
+
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. Use a message body like `{ "name": "Contoso", "email": "[email protected]", "age": "34" }`.
156
+
157
+
When you are satistfied with your app, you can use Visual Studio Code to publish the project directly to Azure.
1. Press <kbd>F1</kbd> to display the command palette, then search for and run the command `Azure Functions:Execute Function Now...`. If prompted, select your subscription.
172
+
173
+
2. Select your new function app resource and `HttpExample` as your function.
174
+
175
+
3. In **Enter request body** type `{ "name": "Contoso", "email": "[email protected]", "age": "34" }`, then press Enter to send this request message to your function.
176
+
177
+
4. When the function executes in Azure, the response is displayed in the notification area. Expand the notification to review the full response.
0 commit comments