azure-serverless-openapi-boilerplatedeprecated

Boilerplate project for a serverless API with automated OpenAPI specification on Azure Functions

Usage no npm install needed!

<script type="module">
  import azureServerlessOpenapiBoilerplate from 'https://cdn.skypack.dev/azure-serverless-openapi-boilerplate';
</script>

README

OpenAPI Azure Function Typescript Boilerplate

License

Boilerplate project for a serverless API with automated OpenAPI specification on Azure Functions

This project is currently just me figuring out the best ways to do Serverless APIs in Azure with nice tooling.

Features

  • Local development with Azure Functions Core Tools
  • Azure infra deployment with Terraform
    • Azure Function App with Linux Node.js runtime
    • Azure Database for PostgreSQL
    • Azure Redis Cache
  • Continuous deployment using ZIP deployment on Azure
  • Automated OpenAPI specification

Deploy

Requirements:

In Azure Portal, gather or create the following items:

  • Subscription
    • ID
  • Resource Group
    • Name
  • Storage Account
    • Name
    • Access Key
  • Blob Storage Container
    • Name

In your .env file, fill the missing environment variables.

# .env
export PROJECT_NAME=<unique name for your project>

export ARM_SUBSCRIPTION_ID=<Subscription ID>
export ARM_RESOURCE_GROUP=<Resource Group Name>
export ARM_ACCESS_KEY=<Storage Account Access Key>

Then source the file to load the environment variables.

source .env

If you wish, you can configure the terraform remote backend to a blob storage container.

See terraform-backend.tf.sample:

terraform {
  backend "azurerm" {
    storage_account_name = "<Storage Account Name>"
    container_name = "<Blob Storage Container Name>"
    key = "terraform.tfstate"
  }
}

Init Terraform and deploy!

terraform init
terraform apply

Publish

To publish your function in the deployed Azure function app:

func azure functionapp publish $PROJECT_NAME-<stage> --zip