October 30, 2022

Serverless API Backend for xBrowserSync on Azure

I have been using xBrowserSync for two years now with my own API Backend. In this post we will look at deploying the xBrowserSync API backedn using the serverless technologies on Microsoft Azure

I used CosmosDB to persist the data, CosmosDB supports per item size of up to 2MB. Hence I set the size limit to 1.5MB and configured it to serverless mode as to pay only for the used read/write capacity units. One Azure functions have been used to handle create-bookmark, updat-bookmark, and get details from CosmosDB operations. Using Azure API Management consumption plan, I have configured APIs to invoke this Azure function.

Everything is implemented through Bicep template and it’s available in xBrowserSync Serverless API on Azure GitHub repository.

This template creates the following resources:

  • Azure Storage Account which is necessary to store the objects and artifacts needed for our resources.
  • Azure Log Analytics workspace to store the Application Insights logs.
  • Azure Cosmos DB account, container and database to store the encrypted bookmarks.
  • Azure App Service plan & Azure Functions which handle the API business logic.
  • Azure API Management which manages the front-end API.

xBrowserSync Resources list

In the earlier post on this topic, I used Amazon DynamoDB as a persistent store. DynamoDB supports maximum of 400KB per item, though I haven’t reached that limiit yet I was intending to modify the Lambda functions to handle single sync Id from multiple items to support larger size. With the 2MB item size limit in CosmosDB I can easily sail through without modifying the Functions.

Here is a quick summary of forecasted cost per month in Azure West Europe (Amsterdam) region for a single person use.

Service Price Dimension Cost
Stroage Account 5 Blobs (5KB), 5 System Tables (5MB), 1 File Share (50MB) 0.4
API Management 43200/month 0
Function 43200/month 0
CosmosDB 10K requests/month 0.05
Application Insights 0.2
Total 0.65

© Prakash P 2015 - 2023

Powered by Hugo & Kiss.