Skip to main content Explore View all products (200+) Microsoft Foundry Azure Copilot GitHub Copilot Azure Kubernetes Service (AKS) Azure Cosmos DB Azure Database for PostgreSQL Azure Arc Microsoft Fabric Linux virtual machines in Azure Foundry Models Foundry Agent Service Foundry IQ Foundry Tools Foundry Control Plane Observability in Foundry Control Plane Azure OpenAI in Foundry Models Azure Speech in Foundry Tools Azure Machine Learning View all databases Azure Cosmos DB Azure DocumentDB Azure SQL Azure Database for PostgreSQL Azure Managed Redis Microsoft Fabric Azure Databricks Linux virtual machines in Azure Windows Server on Azure Azure Functions Azure Virtual Machine Scale Sets Azure API Management Azure Container Apps Azure Kubernetes Service (AKS) Azure Kubernetes Fleet Manager Azure Container Registry Azure Red Hat OpenShift Azure Container Instances Azure Container Storage Azure Arc Azure Local Microsoft Defender for Cloud Azure Monitor Microsoft Sentinel Azure Migrate View all solutions (40+) Cloud solutions for small and medium businesses Cloud migration and modernization center Data analytics for AI Azure Databases AI apps and agents Microsoft Marketplace Microsoft Sovereign Cloud AI apps and agents Responsible AI with Azure AI Infrastructure Data analytics for AI Machine learning operations (MLOps) Low-code application development on Azure Integration Services Serverless computing DevOps Migration and modernization center .NET apps migration Databases on Azure Linux on Azure Oracle on Azure SAP on the Microsoft Cloud Adaptive cloud High-performance computing (HPC) Infrastructure as a service (IaaS) Resiliency Azure Essentials Frontier Accelerate for Azure FinOps on Azure Microsoft Marketplace Azure pricing overview Create an Azure account Free Azure services Flexible purchase options Pricing calculator FinOps on Azure Maximize ROI from AI Azure savings plans Azure reservations Azure Hybrid Benefit Virtual Machines Azure SQL Microsoft Foundry Microsoft Fabric Azure Kubernetes Service (AKS) Microsoft Defender for Cloud View more Software Development Companies Microsoft Marketplace Find a partner Resources for Azure partners Get started with Azure Customer stories Analyst reports, white papers, and e-books Videos Learn more about cloud computing Documentation Explore Azure portal Developer resources Quickstart templates Resources for startups Developer community Students Azure for partners Blog Events and Webinars Learn Support Contact Sales Get started with Azure Sign in
chart, funnel chart

With Azure Search we try to help you build really great search applications over your data. Through capabilities like the Azure Search Indexer, we have tried to make it convenient to ingest data from common data sources to enable this full text search support.

Recently we released the Azure Search Indexer for Azure Blob Storage which allows extraction of text from common file types such as Office, PDF and HTML. One file type we have not yet added support for, but is a common ask, is of images. The idea being you have a file such as JPG, TIFF or PDF with embedded images, you might want to be able to extract the text from these images which can be used to enhance your search index. Imagine you have medical imagery, faxes or scanned documents and want to search over them. This technique is called Optical Character Recognition (OCR) and I want to show you how this can be used to help enhance the content in your Azure Search index.

In talking with customers, I found it is very common to have images embedded within PDF documents, so this is the main focus of the sample because I would not only need to run OCR against the image, but also extract the images from the PDF’s. You can see the sample of how this was accomplished in the following GitHub repository. Here is the general flow of what is done in the sample:

text, application, chat or text message

 The main technologies I used to accomplish this were:

  1. iTextSharp: This is a really convenient .NET port of iText that is a PDF library which allows you to manipulate content in PDF files. I would also like to point out a special thanks to Jerome Viveiros who wrote a great sample on how to use iTextSharp on his post which formed a basis of much of what I used in my sample that extracts the images from the PDF file.
  2. Project Oxford Vision API: There are many ways you can extract text from images (such as the Tesseract). I chose to use Project Oxford’s Vision API’s. I found the code really simple to use and the extracted text was of very high quality. The main downside was that it is currently limited to 5,000 API calls/month, which can be limiting if you have a lot of documents, but I also understand, from a Program Manager on this team, this limit can be increased if needed.
  3. Azure Search: This is the search service where the output from the OCR process is sent. The text, if formatted into a JSON document to be sent to Azure Search, then becomes full text searchable from your application.

A full outline of how to do this can be found in the following GitHub repository. If you would like to see OCR added to the Azure Search Indexer, please cast your vote.

Next steps

This sample is just a starting point. You will more than likely want to extend it further. Perhaps you will want to add the title of the file, or metadata relating to the file (file size, last updated, etc.) which can then be used for further faceting and filtering by your user. You might also want to add a URL reference to the actual image file so you can allow users to open it directly from your application.

Until we integrate OCR capabilities into the Azure Search Indexer, I hope you will find this helpful to help get your content from images into Azure Search. If you have any questions or feedback on this, please let me in the comments below.

WE ARE MICROSOFT

Explore Microsoft Foundry

The future of AI starts here. Envision your next great AI app with the latest technologies. Get started with Azure.