This project demonstrates how to build an Azure Functions-based API that interfaces with Couchbase's Data API to manage airport data from the travel-sample dataset.
Note: The FTS features require:
- A Full Text Search index with geo-spatial mapping on hotel documents
- The travel-sample dataset with hotel documents in the
inventory.hotelcollection - Hotels must have geo coordinates (
geo.latandgeo.lonfields) for proximity search
- Node.js (v18.x or later)
- Azure CLI configured with appropriate credentials
- Azure Functions Core Tools (v4.x)
- Azure subscription with Functions and API Management permissions
- Couchbase Capella cluster with Data API enabled
- Couchbase travel-sample bucket loaded
- Clone the repository
- Navigate to the azure-functions directory:
cd azure-functions- Install dependencies:
npm install- Configure your database (see Database Configuration in the main README)
- Configure your environment variables (see Deployment section for details)
Before using the hotel search functionality, you need to create a Full Text Search index. Use the Node.js script provided in the root of the repository.
See ../scripts/README.md for detailed instructions on creating the required hotel-geo-index for geo-spatial hotel searches.
For local development, you only need to configure Couchbase credentials in local.settings.json:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "node",
"DATA_API_ENDPOINT": "https://your-capella-data-api-endpoint",
"DATA_API_USERNAME": "your-capella-cluster-username",
"DATA_API_PASSWORD": "your-capella-cluster-password"
}
}Note: For local development, you only need the Couchbase credentials. Azure deployment settings are not required for local testing.
Start the development server:
npm start- Azure CLI installed and configured
- Azure subscription with Functions and API Management permissions
az loginFor Deployment Scripts (Azure settings):
Configure these in your local.settings.json for deployment automation:
{
"IsEncrypted": false,
"Values": {
"SUBSCRIPTION_ID": "your-azure-subscription-id",
"RESOURCE_GROUP": "your-resource-group-name",
"AZURE_LOCATION": "eastus",
"STORAGE_ACCOUNT": "your-storage-account-name",
"FUNCTION_APP": "your-function-app-name",
"APIM_NAME": "your-apim-name"
}
}Important: Azure resource names must be globally unique across the entire Azure platform. Use unique names or add timestamps to avoid conflicts.
Note: Couchbase credentials are automatically configured during deployment from your local.settings.json file.
npm run deployThis will:
- Create Azure resources (Resource Group, Storage Account, Function App)
- Deploy your functions to Azure
- Automatically configure Couchbase credentials from your
local.settings.json
For production deployment with API Management:
npm run deploy-apimThe API will be available at https://{apim-name}.azure-api.net/airports
This project includes comprehensive integration tests that validate all API operations through your APIM gateway.
Run integration tests:
# Set your APIM gateway URL
BASE_URL=https://your-apim-name.azure-api.net npm testsrc/
├── functions/ # Azure Functions handlers
│ ├── createAirport.ts
│ ├── getAirport.ts
│ ├── updateAirport.ts
│ ├── deleteAirport.ts
│ ├── getAirportRoutes.ts
│ ├── getAirportAirlines.ts
│ └── getHotelsNearAirport.ts
├── utils/ # Utility functions
│ ├── config.ts
│ └── errors.ts
tests/
└── integration.test.mjs # Integration tests
scripts/
├── deploy.mjs # Functions deployment script
└── deploy-apim.mjs # API Management deployment script