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
Copy file name to clipboardExpand all lines: articles/azure-functions/how-to-create-function-vs-code.md
+34-17Lines changed: 34 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,7 @@ In this section, you use Visual Studio Code to create a local Azure Functions pr
41
41
|--|--|
42
42
|**Select a language**|Choose `C#`.|
43
43
|**Select a .NET runtime**|Choose `.NET 8.0 LTS`.|
44
-
|**Select a template for your project's first function**|Choose `HTTP trigger`.<sup>*</sup>|
44
+
|**Select a template for your project's first function**|Choose `HTTP trigger`.|
45
45
|**Provide a function name**|Type `HttpExample`.|
46
46
|**Provide a namespace**| Type `My.Functions`. |
47
47
|**Authorization level**|Choose `Anonymous`, which enables anyone to call your function endpoint. For more information, see [Authorization level](functions-bindings-http-webhook-trigger.md#http-auth).|
@@ -59,10 +59,8 @@ In this section, you use Visual Studio Code to create a local Azure Functions pr
59
59
|**Provide a version**| Choose `1.0-SNAPSHOT`. |
60
60
|**Provide a package name**| Choose `com.function`. |
61
61
|**Provide an app name**| Choose `myFunction-12345`. |
62
-
|**Select a template for your project's first function**| Choose `HTTP trigger`.<sup>*</sup>|
62
+
|**Select a template for your project's first function**| Choose `HTTP trigger`.|
63
63
|**Select the build tool for Java project**| Choose `Maven`. |
64
-
|**Provide a function name**| Enter `HttpExample`.|
65
-
|**Authorization level**| Choose `Anonymous`, which lets anyone call your function endpoint. For more information, see [Authorization level](functions-bindings-http-webhook-trigger.md#http-auth).|
66
64
|**Select how you would like to open your project**| Choose `Open in current window`.|
67
65
68
66
::: zone-end
@@ -72,7 +70,7 @@ In this section, you use Visual Studio Code to create a local Azure Functions pr
72
70
|--|--|
73
71
|**Select a language**|Choose `JavaScript`.|
74
72
|**Select a JavaScript programming model**|Choose `Model V4`.|
75
-
|**Select a template for your project's first function**|Choose `HTTP trigger`.<sup>*</sup>|
73
+
|**Select a template for your project's first function**|Choose `HTTP trigger`.|
76
74
|**Provide a function name**|Type `HttpExample`.|
77
75
|**Authorization level**|Choose `Anonymous`, which enables anyone to call your function endpoint. For more information, see [Authorization level](functions-bindings-http-webhook-trigger.md#http-auth).|
78
76
|**Select how you would like to open your project**|Choose `Open in current window`.|
@@ -84,7 +82,7 @@ In this section, you use Visual Studio Code to create a local Azure Functions pr
84
82
|--|--|
85
83
|**Select a language**|Choose `TypeScript`.|
86
84
|**Select a JavaScript programming model**|Choose `Model V4`.|
87
-
|**Select a template for your project's first function**|Choose `HTTP trigger`.<sup>*</sup>|
85
+
|**Select a template for your project's first function**|Choose `HTTP trigger`.|
88
86
|**Provide a function name**|Type `HttpExample`.|
89
87
|**Authorization level**|Choose `Anonymous`, which enables anyone to call your function endpoint. For more information, see [Authorization level](functions-bindings-http-webhook-trigger.md#http-auth).|
90
88
|**Select how you would like to open your project**|Choose `Open in current window`.|
@@ -96,7 +94,7 @@ In this section, you use Visual Studio Code to create a local Azure Functions pr
96
94
|--|--|
97
95
|**Select a language**| Choose `Python`.|
98
96
|**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.|
99
-
|**Select a template for your project's first function**| Choose `HTTP trigger`.<sup>*</sup>|
97
+
|**Select a template for your project's first function**| Choose `HTTP trigger`. |
100
98
|**Name of the function you want to create**| Enter `HttpExample`.|
101
99
|**Authorization level**| Choose `ANONYMOUS`, which lets anyone call your function endpoint. For more information, see [Authorization level](functions-bindings-http-webhook-trigger.md#http-auth).|
102
100
|**Select how you would like to open your project**| Choose `Open in current window`.|
@@ -107,16 +105,14 @@ In this section, you use Visual Studio Code to create a local Azure Functions pr
107
105
|Prompt|Selection|
108
106
|--|--|
109
107
|**Select a language for your function project**|Choose `PowerShell`.|
110
-
|**Select a template for your project's first function**|Choose `HTTP trigger`.<sup>*</sup>|
108
+
|**Select a template for your project's first function**|Choose `HTTP trigger`.|
111
109
|**Provide a function name**|Type `HttpExample`.|
112
110
|**Authorization level**|Choose `Anonymous`, which enables anyone to call your function endpoint. For more information, see [Authorization level](functions-bindings-http-webhook-trigger.md#http-auth).|
113
111
|**Select how you would like to open your project**|Choose `Open in current window`.|
114
112
115
113
::: zone-end
116
114
117
-
<sup>*</sup> Depending on your VS Code settings, you may need to use the `Change template filter` option to see the full list of templates.
118
-
119
-
Using this information, Visual Studio Code generates an Azure Functions project with an HTTP trigger. You can view the local project files in the Explorer. To learn more about files that are created, see [Generated project files](functions-develop-vs-code.md?tabs=javascript#generated-project-files).
115
+
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](functions-develop-vs-code.md?tabs=javascript#generated-project-files).
120
116
121
117
::: zone pivot="programming-language-python"
122
118
4. In the local.settings.json file, update the `AzureWebJobsStorage` setting as in the following example:
@@ -140,21 +136,42 @@ After you verify that the function runs correctly on your local computer, you ca
140
136
## Use AI to normalize and validate input
141
137
142
138
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:
143
-
139
+
::: zone pivot="programming-language-csharp,programming-language-javascript,programming-language-typescript,programming-language-powershell,programming-language-python"
144
140
```copilot-prompt
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:
141
+
Modify the function to accept name, email, and age from the JSON body of the
142
+
request. If any of these parameters are missing from the query string, read
143
+
them from the JSON body. Return all three parameters in the JSON response,
144
+
applying these rules:
146
145
Title-case the name
147
146
Lowercase the email
148
147
Convert age to an integer if possible, otherwise return "not provided"
149
148
Use sensible defaults if any parameter is missing
150
149
```
150
+
::: zone-end
151
+
::: zone pivot="programming-language-java"
152
+
```copilot-prompt
153
+
Modify the function to accept name, email, and age from the JSON body of the
154
+
request. If any of these parameters are missing from the query string, read
155
+
them from the JSON body. Return all three parameters in the JSON response,
156
+
applying these rules:
157
+
Title-case the name
158
+
Lowercase the email
159
+
Convert age to an integer if possible, otherwise return "not provided"
160
+
Use sensible defaults if any parameter is missing
161
+
Update the FunctionTest.java file to test the new logic.
162
+
```
163
+
::: zone-end
151
164
152
-
> [!TIP]
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).
165
+
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:
154
166
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. This time, use a message body like `{ "name": "Contoso", "email": "[email protected]", "age": "34" }`.
If you encounter any errors during execution, paste the error message in the chat window and ask Copilot to help resolve the error. When you are satistfied with your app, you can use Visual Studio Code to publish the project directly to Azure.
171
+
> [!TIP]
172
+
> 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](https://aka.ms/copilot-general-use-faqs).
173
+
174
+
When you are satistfied with your app, you can use Visual Studio Code to publish the project directly to Azure.
0 commit comments