Skip to content

Commit

Permalink
fix: typos for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
glaucia86 committed Apr 16, 2024
1 parent d40b17a commit 8cff76c
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions docs/tutorial/02-setting-up-azure-functions.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Setting Up the Serverless Environment using Azure Functions

This section explains how to configure the development environment to create the API for the Chat Application application. We'll use Azure Functions in its 4.x version and with the programming model version 4.
This section explains how to configure the development environment to create the API for the Chat Application. We'll use Azure Functions in its 4.x version and with the programming model version 4.

## Prerequisites for this section

At this point, don't forget to install **[Azure Functions Core Tools](https://docs.microsoft.com/azure/azure-functions/functions-run-local?tabs=windows%2Ccsharp%2Cbash)** if you're developing locally on your machine. If you're using **[Codespaces](https://github.com/features/codespaces)**, the environment will already be set up for you!
At this point, do not forget to install **[Azure Functions Core Tools](https://docs.microsoft.com/azure/azure-functions/functions-run-local?tabs=windows%2Ccsharp%2Cbash)** if you are developing locally on your machine. If you are using **[Codespaces](https://github.com/features/codespaces)**, the environment will already be set up for you!

To make it easier to create new functions and project configurations, we recommend installing the **[Azure Functions extension for Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurefunctions)**.

## What is Azure Functions?
## What are Azure Functions?

**[Azure Functions](https://learn.microsoft.com/azure/azure-functions/functions-overview?pivots=programming-language-javascript)** is a **[serverless computing service](https://azure.microsoft.com/resources/cloud-computing-dictionary/what-is-serverless-computing)**. It allows us to run code on demand without requiring a server infrastructure. You can execute your code in response to many events, including data changes, message trigger, HTTP calls, and even timers.
**[Azure Functions](https://learn.microsoft.com/azure/azure-functions/functions-overview?pivots=programming-language-javascript)** is a **[serverless computing service](https://azure.microsoft.com/resources/cloud-computing-dictionary/what-is-serverless-computing)**. It allows us to run code on demand without requiring a server infrastructure. You can execute your code in response to many events, including data changes, message triggers, HTTP calls, and even timers.

## What is Azure Functions v4 programming model for Node?
## What are Azure Functions v4 programming model for Node?

Azure Functions v4 is the latest version of the Node.js programming model for Azure Functions. It comes with a bunch of new features and improvements, such as:

Expand All @@ -25,11 +25,11 @@ Azure Functions v4 is the latest version of the Node.js programming model for Az

> **Note:** if you are using version 3.x of the Azure Functions programming model for Node.js, we recommend referring to the **[official documentation](https://learn.microsoft.com/en-us/azure/azure-functions/functions-node-upgrade-v4?tabs=v4&pivots=programming-language-typescript)** for guidance on the project structure and how to define functions in case if you want to migrate to version 4.x.
> **Tip:** to learn about the new version of the Azure Functions programming model v4 for Node.js, read the **[official blog post](https://techcommunity.microsoft.com/t5/apps-on-azure-blog/azure-functions-node-js-v4-programming-model-is-generally/ba-p/3929217)**
> **Tip:** to learn about the latest version of the Azure Functions programming model v4 for Node.js, read the **[official blog post](https://techcommunity.microsoft.com/t5/apps-on-azure-blog/azure-functions-node-js-v4-programming-model-is-generally/ba-p/3929217)**
## Creating a new Azure Functions project

After following the steps above and forking the repository in the `starter` branch, you should do the following steps:
After following the steps above and forking the repository in the `starter` branch, you should take the following steps:

| Step | Description |
| ---- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand All @@ -47,24 +47,24 @@ After creating the project, you will see a similar folder and file structure:

> **Note:** when we create a new project, it may take some time to install all the project dependencies and structure. Wait until the process is complete.
Note that the project structure differs significantly from the programming model 3.x versin. Let's take a moment to understand the structure of this new programming model version:
Note that the project structure differs significantly from the programming model 3.x version. Let's take a moment to understand the structure of this new programming model version:

- **src folder:** has all the project logic, including functions and configuration files.
- **functions folder:** contains the functions related to the project.
- **functions folder:** has the functions related to the project.

- `local.settings.json`: local configuration file to store environment settings.
- `host.json`: Azure Functions host configuration file.
- `tsconfig.json`: TypeScript configuration file.
- `package.json`: Node.js configuration file.
- `.funcignore`: file to ignore files and folders when publishing the project.

This new structure is more flexible and allows us to define functions directly in the code, without the need for a separate `function.json` file as was required in version 3.x. It is similar to Express.js, a web framework for Node.js.
This new structure is more flexible and allows us to define functions directly in the code, without the need for a separate `function.json` file as was needed in version 3.x. It is like Express.js, a web framework for Node.js.

In addition to the project structure created, note that another folder called `.vscode` was automatically created. This folder contains the Visual Studio Code configurations for the project, such as build and debug tasks. Next, we need to configure the project so that we can run the function created.
In addition to the project structure created, note that another folder called `.vscode` was automatically created. This folder has the Visual Studio Code configurations for the project, such as building and debug tasks. Next, we need to configure the project so that we can run the function created.

## Setting up the project to run the functions

The project is not fully configured to run yet. There are signs that TypeScript is telling us that something is wrong and we need to fix it.
The project is not fully configured to run yet. There are signs that TypeScript is telling us that something is wrong, and we need to fix it.

Open the `tsconfig.json` file and add the following configuration:

Expand All @@ -90,7 +90,7 @@ Open the `tsconfig.json` file and add the following configuration:
}
```

Before executing the function we've created, we need to make some important changes. Open the `.vscode` folder and the `settings.json` file, and add the following configuration:
Before executing the function, we've created, we need to make some important changes. Open the `.vscode` folder and the `settings.json` file, and add the following configuration:

- `.vscode/settings.json`

Expand All @@ -107,15 +107,15 @@ Before executing the function we've created, we need to make some important chan
}
```

This configuration is very important so that we can run the functions created in the project.
This configuration is important so that we can run the functions created in the project.

Now the last configuration we need to make is in the file `src/functions/chat-post`. Note that, when you open the file, there are some compilation errors.

![alt text](./images/function-chat-error.png)

Why? Because we cannot define a function in the same way as `chat-post` was created. We need to change it to `postChat` without the hyphen. Additionally, we need to modify the handler of the `chat-post` function to `postChat` and also, specify that this function will be a `POST` instead of a `GET` function.

So the `chat-post` function will look like this:
So, the `chat-post` function will look like this:

- `packages/src/functions/chat-post`

Expand Down Expand Up @@ -155,7 +155,7 @@ Open the browser and go to the URL `http://localhost:7071/api/chat-post`. You wi
Hello, world! POST Chat Function
```

If this happened, congratulations! We have successfully set up the environment correctly!
If this happens, congratulations! We have successfully set up the environment correctly!

## Creating the other functions for the project

Expand Down Expand Up @@ -243,9 +243,9 @@ If that happened, congratulations! The environment has been set up correctly!

This tutorial explains how to configure the development environment to create functions for the Chat Application project using Functions version 4.x and the programming model v4 for Node.js.

Additionally, we configured the project to run the functions we created. And finally we created the `chat-post`, `documents-post`, and `documents-get` functions for the project.
Additionally, we configured the project to run the functions we created. And finally, we created the `chat-post`, `documents-post`, and `documents-get` functions for the project.

Before we proceed with developing the functions, it's important to grasp a fundamental concept for those building Chat Application applications: Retrieval-Augmented Generation (RAG).
Before we continue with developing the functions, it's important to grasp a fundamental concept for those building Chat Application applications: Retrieval-Augmented Generation (RAG).

We will talk about RAG in the next section.

Expand Down

0 comments on commit 8cff76c

Please sign in to comment.