how can I store images in CosmosDB and referred to appropriate content

Larisa Dbritto 20 Reputation points
2023-02-23T19:02:27.3+00:00

Hi Team, I have content which refers to an images. My content is in CosmosDB while images are on local. I want to store the images on DB as well. I am building an internal search engine. I when search for a phrase a content and corresponding image needs to be displayed. what would be the best solution for this problem. How can i tag the image to the content in CosmosDB?

Azure AI Search
Azure AI Search
An Azure search service with built-in artificial intelligence capabilities that enrich information to help identify and explore relevant content at scale.
1,350 questions
Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,906 questions
0 comments No comments
{count} votes

Accepted answer
  1. Mark Brown - MSFT 2,771 Reputation points Microsoft Employee
    2023-02-23T19:42:00.72+00:00

    Azure Cosmos DB is not intended to be used to store images. To do so means encoding as base-64. This can be incredibly expensive compute-wise to do. Also, max doc size for Cosmos is 2MB. Anything larger would need to be shredded and reassembled client-side. Lastly, storage for Cosmos DB is more expensive than blob storage, 25c/GB versus 1c/GB for blob storage. Using Cosmos to store b64 encoded image data is expensive given you cannot index or query the image data itself.

    The right approach is to put the image in blob-storage, then include the URI to the image and all searchable metadata in Cosmos. If you're building a search engine you can roll your own or use Azure Cognitive Search which has very good integration with Cosmos DB, https://learn.microsoft.com/en-us/azure/search/search-howto-index-cosmosdb

    4 people found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.