Skip to main content

21 posts tagged with "azure-container-apps"

View All Tags

· 8 min read
It's 30DaysOfIA

In this article, explore the power of multi-model databases for Intelligent Apps and their integration with Azure Cosmos DB and Azure Kubernetes Service (AKS).

What We'll Cover:​

  • What is a multi-model database?
  • Concepts of Azure Cosmos DB
  • Creating a Multi-Model Database with Cosmos DB and AKS

image of a multi-model database

Powering Intelligent Apps with a Multi-Model Database Using Cosmos DB and Azure Kubernetes Service (1) ​

In the first topic of this week, we created an Intelligent App that helped us analyze images and extract valuable data. We constructed a Python web API to execute optical character recognition (OCR) on images uploaded to the application using Azure AI Vision and Azure Kubernetes Service (AKS) for hosting the application. 

In this second topic for the week, we’ll explore how Azure Cosmos DB’s support for multi-model databases provides flexibility in data modeling, scalability, and performance optimization—crucial for storing, indexing, and querying data in multiple formats. 

Unraveling Multi-Model Databases and Cosmos DB​

Multi-model databases let us store and work with data in multiple formats, including relational data, JSON documents, key-value pairs, spatial data, and graphs. They simplify development, reduce data integration issues, and support a more comprehensive data analysis, leading to valuable insights.

Below are some of the benefits of using a multi-model database:

  • Scalability and performance—Multi-model databases allow us to shape data to fit different formats. We can tailor these databases to our applications, spreading data across clusters to support efficient, smooth scaling. Additionally, they support intelligent indexing, caching, and query optimization to ensure fast and efficient data access, even when handling complex queries.
  • Versatility—Multi-model databases support versatility by accommodating diverse data types and structures within a unified platform. Unlike traditional databases, they seamlessly integrate storing and retrieving various data formats, enabling us to dynamically model and manage complex information.
  • Data handling and transformation advantages—Because a multi-model database supports different data structures, it can easily handle structured, semi-structured, and unstructured data. These databases offer a transformative advantage in applications dealing with diverse and unstructured data. Their ability to manage various data types ensures a holistic and agile data storage, retrieval, and analysis approach. As such, multi-model databases enable streamlined development, simplified integration, and flexible querying.
  • OCR analysis—Multi-model databases are invaluable assets for managing the complex needs of diverse data from OCR analysis. This flexibility in data handling means efficient storage and retrieval of OCR results, enabling complex queries that reveal deeper insights across various data types.

Azure Cosmos DB is Azure’s top-tier multi-model database service, compatible with various popular data models and APIs. It effortlessly handles numerous data types, providing developers a unified platform for various application purposes.

Supporting several APIs, including native NoSQL, and open-source APIs for MongoDB, Apache Cassandra, Gremlin, and Table, Cosmos DB enable smooth transition and integration of current apps and aids in building new ones. This adaptability in data modeling ensures quick adjustments to evolving needs, maintaining low latency, global distribution, and high availability.

Let’s explore the power of multi-model databases for Intelligent Apps.

Creating a Multi-Model Database with Cosmos DB and AKS​

In the following sections, we’ll walk through how Azure Cosmos DB can handle the unstructured data from the OCR analysis and provide multi-model databases for our Intelligent App while hosting it in AKS.

info

Watch the intelligent apps webinar on Driving Business Value by Modernizing with Cloud-Native & AI with Microsoft and Forrester.

Explore how modernization sets the stage for incorporating AI/ML into existing applications and how building new, intelligent applications can drive innovation and competitive advantage across a range of industries. Walkthrough a showcase of real-world use cases that demonstrate how AI can be seamlessly integrated into cloud-native environments driving tangible business value. 

Prerequisites​

To follow this tutorial, ensure you have: 

For a look at the final project from this tutorial, review the complete code.

Solution Architecture​

The image below shows the architecture of the solution we’re aiming for in this article.

Image of solution architecture

Creating an Azure Cosmos DB for NoSQL Account​

This section provides step-by-step instructions for setting up a multi-model database with Cosmos DB in your AKS environment. We’ll focus on the preparation, design, and configuration stages. 

Note that an Azure Cosmos DB for NoSQL account isn’t related to your Azure account. An Azure Cosmos DB for NoSQL account is a database service provided by Microsoft Azure for creating, managing, and scaling globally distributed, multi-model databases. 

An Azure Cosmos DB account provides a collection of Azure Cosmos DB assets, such as databases, containers, and items. It also offers an endpoint that facilitates connections for various tools and SDKs, enabling actions within Azure Cosmos DB. For deeper insight into the assets within Azure Cosmos DB, refer to the Azure Cosmos DB resource model. 

Let’s create an Azure Cosmos DB account using the API for NoSQL. First, sign in to the Azure portal. From the Azure portal menu or the homepage, select Create a resource. 

On the Create a resource page, search for Azure Cosmos DB.

image of a searching for Azure Cosmos DB in Azure

When the results appear, locate the Azure Cosmos DB service, then click Create.

image of creating an Azure Cosmos DB in Azure

Next, you’ll see the Azure Cosmos DB service page as follows:

image of Azure Cosmos DB service page

The API determines the type of account to create. Select Azure Cosmos DB API for NoSQL and click Create.

image of creating Azure Cosmos DB API for NoSQL

When you reach the Create Azure Cosmos DB Account page, enter the settings below for the new account, then click Review + create.

  • Resource Group: computer-vision
  • Account Name: This should be unique to you.
  • Capacity mode: Serverless

image of adding settings for the new account in Azure

Finally, review your settings and click the Create button.

image of reviewing settings for the new account in Azure

Next, wait a few minutes until Azure creates the account and click the Go to resource button. Wait for the portal to display your new Cosmos DB account’s overview.

image of the new Cosmos DB account's overview

We still need to create the NoSQL database. So, select Data Explorer on the sidebar. Then select the New Container dropdown menu and select New Database:

image of selecting a new database to create the NoSQL database

Next, provide “IntelligentAppDB” as the Database id and click OK:

image of adding the new Database id

Now, select the IntelligentAppDB database, click the ellipsis (...) icon, and click the New Container option:

image of adding a new container

Provide “ImageAnalysisContainer” as the Container id and “Partition1” as the partition key. Then, click OK to save the container.

image of entering container id and partition key

Repeat the previous step to create a new container. Provide “AggregateResultsContainer” as the Container id and “/id” as the Partition key. Then click OK to save the database.

image of saving the new database

Now, your database and container structure should appear like the image below:

image of database and container structure

Let’s review the elements of this Cosmos DB setup: 

  • IntelligentAppDB is a database within Cosmos DB, serving as a high-level container for grouping related data relevant to our Intelligent App. 
  • AggregateResultsContainer is a container within the IntelligentAppDB database. Containers are where data is stored in Cosmos DB, and this particular container holds data related to aggregate results generated from the Intelligent App. 
  • ImageAnalysisContainer is another container within the same IntelligentAppDB database. It’s dedicated to storing data pertaining to OCR analysis generated by Azure AI Vision. 

Exercise​

Next Steps​

Continue to the next part of this topic to further explore loading OCR data into the multi-model database with Azure Cosmos DB, testing the app locally and deploying new version of the intelligent app to Azure Kubernetes Service. Furthermore, learn more about the real-world use cases for multi-model databases.