In the second part of the series, the focus is on persisting data in Azure Postgres SQL with best practices.
Azure Postgres SQL is used to record metadata of images, tracking aspects like upload dates, image URLs, OCR processing status, and image categorization.
The project architecture is updated to incorporate a lightweight Domain-Driven Design (DDD) approach with layered responsibilities.
Content Type Validator class is implemented to ensure that only specific image types are processed by the function.
The database table for storing image metadata is created using a script in Azure Data Studio or SSMS.
Packages like 'pg' are used to connect to Azure Postgres SQL from the Function App.
Connection to Azure Postgres SQL is established using Microsoft Managed Identity through the Azure portal.
Repository contracts are defined with the IImageRepository interface to ensure persistence capabilities irrespective of the database used.
Implementation of database interactions with Azure Postgres SQL is done in the OcrImageRepository class, focusing on insertions.
The Function structure has been updated to validate content types, check image size, store images in Azure Blob Storage, and save metadata in Azure Postgres SQL.