Azure Functions Create Function in VS Code - microsoft-campus-community/workshop-shopping-list-bot GitHub Wiki
workshop
branch. You will also need Visual Studio Code with Azure Functions Extension installed.
Prerequisite: This page assumes that you have a fork of this repository and are on the On this page, you will create a new Azure Function with an HTTP trigger that should implement the REST endpoint to add an item to a shopping list.
Open the functions
folder of the workshop
branch in Visual Studio Code.
- In Visual Studio Code, open the Azure Extension in the left toolbar.
- Expand the 'Functions' tab and click on the 'lightning bolt with the little green +' icon to create a new Function. .
- As a template for the Azure Function, select
HTTP trigger
. - When prompted, type
AddItemFunction
into the name text box. - For 'Authorization Level', select
Anonymous
. This has nothing to do with individual users' authorization, which we do not touch in this workshop. The authorization level of an Azure Functions configures whether a client needs to present a key when calling the Function.
Now you have a basic template to write the Function to add an item to a shopping list.
Overview what gets generated
Now that you have a new Azure Function from the HTTP template, let's look at what got generated for you.
- Open the
functions/AddItemFunction
folder in your IDE. - The first file is
function.json
, which contains a specific configuration for this single Function. For example, that this Function is an HTTP trigger. Azure Functions can be triggered by many other events than just a simple HTTP request. index.ts
contains the actual code for your Function. By default, it generates a basic 'Hello World' example.- You can delete the
sample.dat
file. It only contains example data the 'Hello World' code can get as input in the HTTP request body.
In the next part, you will write the code for this Function.