Skip to content

Collection of code examples demonstrating how to build serverless applications using TypeScript and Azure

License

Notifications You must be signed in to change notification settings

Azure-Samples/serverless-recipes-javascript

Repository files navigation

Serverless Recipes for JavaScript/TypeScript

Open project in GitHub Codespaces Build Status Node version TypeScript License

⭐ If you like this project, star it on GitHub — it helps a lot!

Get startedRun the samplesSamples listResourcesTroubleshooting

This repository is a collection of code examples demonstrating how to build serverless applications using TypeScript and Azure. Each recipe is a standalone sample that demonstrates how to build a specific feature or use a specific technology. You can use these samples as a starting point for your own projects or to learn more about serverless development with Azure.

Note

What's Serverless?
Serverless computing allows you to build and run applications without managing infrastructure. You can focus on your code and let the cloud provider handle the rest. Azure provides a wide range of serverless services, including Azure Functions, [Azure Static Web Apps](Azure Static Web Apps, Azure Cosmos DB, and more.

Why serverless?

Let's say you're a developer for the Contoso Solutions company, and you've been tasked to build new applications with a fast turnaround time, startup style. You need to build these apps quickly with a low initial budget, and you don't want to worry about managing servers, scaling, or infrastructure. You want to focus on writing code and delivering value to your users.

This is exactly where serverless is a great fit!

While walking through this collection of ready-to-use code examples, you'll learn how to solve common problems and build applications using many of the serverless technologies available on Azure. The best part? You only need to pay attention to the code and the business logic, all samples are ready to deploy and run in your Azure account.

Prerequisites

Getting started

There are multiple ways to get started with this project.

The quickest way is to use GitHub Codespaces that provides a preconfigured environment for you. Alternatively, you can set up your local environment following the instructions below.

Use GitHub Codespaces

You can run this project directly in your browser by using GitHub Codespaces, which will open a web-based VS Code:

Open in GitHub Codespaces

Use a VSCode dev container

A similar option to Codespaces is VS Code Dev Containers, that will open the project in your local VS Code instance using the Dev Containers extension.

You will also need to have Docker installed on your machine to run the container.

Open in Dev Containers

Use your local environment

You need to install following tools to work on your local machine:

  • Node.js LTS
  • Azure Developer CLI
  • Git
  • PowerShell 7+ (for Windows users only)
    • Important: Ensure you can run pwsh.exe from a PowerShell command. If this fails, you likely need to upgrade PowerShell.
    • Instead of Powershell, you can also use Git Bash or WSL to run the Azure Developer CLI commands.
  • Azure Functions Core Tools (should be installed automatically with NPM, only install manually if the API fails to start)

Then you can get the project code:

  1. Fork the project to create your own copy of this repository.

  2. On your forked repository, select the Code button, then the Local tab, and copy the URL of your forked repository.

    Screenshot showing how to copy the repository URL

  3. Open a terminal and run this command to clone the repo: git clone <your-repo-url>

Run the samples

After setting up your environment, you can deploy and run any of the samples. Each sample is a standalone project that you can run independently. Follows these steps to run a sample:

# Open the sample directory
cd samples/<sample-name>

# Install dependencies
npm install

# Deploy the sample to Azure
azd auth login
azd up

Once the initial deployment is completed, you can also run the sample locally with npm start. You can check the README.md file in each sample directory for more specific instructions.

Samples list

Sample Deployment Time Video Blog
Azure Functions OpenAI extension - embeddings 5min - -
Azure Functions OpenAI extension - text completion 5min - -

Resources

Here are some additional resources to learn more about the technologies used:

Troubleshooting

If you have any issue when running or deploying the samples, please check the troubleshooting guide. If you can't find a solution to your problem, please open an issue in this repository.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.