|
2 | 2 | title: Create a Python function using Visual Studio Code - Azure Functions
|
3 | 3 | description: Learn how to create a Python function, then publish the local project to serverless hosting in Azure Functions using the Azure Functions extension in Visual Studio Code.
|
4 | 4 | ms.topic: quickstart
|
5 |
| -ms.date: 09/10/2024 |
| 5 | +ms.date: 06/26/2025 |
6 | 6 | ms.devlang: python
|
7 | 7 | ms.custom: devx-track-python, mode-api, devdivchpfy22, vscode-azure-extension-update-complete, ai-video-demo
|
8 | 8 | ai-usage: ai-assisted
|
| 9 | +ms.custom: copilot-scenario-highlight |
9 | 10 | ---
|
10 | 11 |
|
11 | 12 | # Quickstart: Create a function in Azure with Python using Visual Studio Code
|
@@ -80,6 +81,23 @@ In this section, you use Visual Studio Code to create a local Azure Functions pr
|
80 | 81 |
|
81 | 82 | After you verify that the function runs correctly on your local computer, it's time to use Visual Studio Code to publish the project directly to Azure.
|
82 | 83 |
|
| 84 | +## Use AI to validate user input in your function |
| 85 | + |
| 86 | +You can use AI tools, such as GitHub Copilot in Visual Studio Code, to generate Python code that updates the existing function to handle user data cleaning and validation. You can customize the prompt to add specifics per your requirements. |
| 87 | + |
| 88 | +The following text shows an example prompt for Copilot Chat: |
| 89 | + |
| 90 | +```copilot-prompt |
| 91 | +Generate Python code to modify current function to build an Azure Function API endpoint that: |
| 92 | +Accepts user data: {"name": " john doe ", "email": "[email protected]", "age": 25} |
| 93 | +Returns cleaned data: {"name": "John Doe", "email": "[email protected]", "age": 25, "category": "Adult"} |
| 94 | +Validates required fields and data formats |
| 95 | +Handles errors gracefully with clear messages |
| 96 | +Uses POST method and JSON content type |
| 97 | +``` |
| 98 | + |
| 99 | +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). |
| 100 | + |
83 | 101 | [!INCLUDE [functions-sign-in-vs-code](../../includes/functions-sign-in-vs-code.md)]
|
84 | 102 |
|
85 | 103 | [!INCLUDE [functions-publish-project-vscode](../../includes/functions-publish-project-vscode.md)]
|
|
0 commit comments