Automated Document Processing with Azure Document Intelligence

Introduction

Processing large volumes of documents manually is time-consuming and error-prone. Whether dealing with invoices, receipts, contracts, or business forms, extracting structured data efficiently is crucial for automation.

Azure Document Intelligence (formerly Azure Form Recognizer) is a cloud-based AI service that enables automated document processing using pre-trained and custom models. With just an API call, you can:
✅ Extract key-value pairs from structured forms.
✅ Process invoices, receipts, and business cards.
✅ Recognize handwritten text and printed text.
✅ Automate data extraction into databases or applications.

This guide walks through setting up Azure Document Intelligence, sending a document for analysis, and visualizing extracted data.


1️⃣ Setting Up Azure Document Intelligence

Before sending documents for processing, you need to set up Azure Document Intelligence in the Azure Portal.

Steps to Create a Document Intelligence Resource

1️⃣ Log in to Azure Portal.
2️⃣ Click “Create a resource” → Search for “Document Intelligence”.
3️⃣ Select “Cognitive Services → Document Intelligence”.
4️⃣ Configure the details:

  • Subscription – Select an active Azure subscription.
  • Resource Group – Create or use an existing one.
  • Region – Pick a region closest to your users.
  • Pricing Tier – Choose “Standard” or “Free (F0)” for limited usage.
    5️⃣ Click “Review + Create” → then “Create”.

Once deployed, navigate to “Keys and Endpoint” in the Document Intelligence resource to get:
✔ API Key (used for authentication)
✔ Endpoint URL (base URL for sending API requests)


2️⃣ Sending a Document to Azure Document Intelligence API

Now that the resource is set up, it’s time to upload a document (PDF, image, or scanned document) for analysis.

Here’s a Python script to send a document to Azure Document Intelligence API:


import requests

# Replace with your Azure API details

API_KEY = "<your_api_key>"

ENDPOINT = "<your_endpoint>/formrecognizer/documentModels/prebuilt-invoice/analyze?api-version=2023-07-31-preview"

headers = {

    "Ocp-Apim-Subscription-Key": API_KEY,

    "Content-Type": "application/pdf"

}

# Open a sample PDF file

with open("sample_invoice.pdf", "rb") as file_data:

    response = requests.post(ENDPOINT, headers=headers, data=file_data)

# Get operation location (needed to retrieve results)

operation_url = response.headers["Operation-Location"]

print(f"Processing started: {operation_url}")

📌 What’s Happening?

  • The script uploads a document (PDF) to the API.
  • The response returns an Operation-Location URL, which is needed to retrieve results later.

3️⃣ Retrieving & Parsing Extracted Data

After submitting a document, the API takes a few seconds to process it. The next step is retrieving the extracted data.


import time

# Wait for processing to complete

time.sleep(5)

# Retrieve results from Operation-Location

response = requests.get(operation_url, headers={"Ocp-Apim-Subscription-Key": API_KEY})

result = response.json()

print("Extracted Document Data:")

print(result)

📌 What’s Happening?

  • The script waits for processing to complete.
  • It retrieves the extracted text in JSON format.

🔗 Azure Docs: Document Intelligence API Reference


4️⃣ Extracting Key Fields from Documents

The API returns structured data, which can be filtered for important key-value pairs such as invoice numbers, dates, and totals.

📌 Example Output:


5️⃣ Visualizing Extracted Data

To better understand extracted document data, you can visualize it in a table or chart.

Using Pandas to Display Data in a Table


import pandas as pd

# Create a DataFrame

df = pd.DataFrame([

    {"Invoice Number": invoice_number, "Total Amount": total_amount, "Invoice Date": invoice_date}

])

print(df)

6️⃣ Automating Document Processing Workflows

Once the extracted data is available, you can:
✅ Save it to a database for future reference.
✅ Integrate with Power Automate for real-time invoice processing.
✅ Use Azure Logic Apps to send automated email alerts.

For example, integrating Azure Logic Apps can send an email when an invoice total exceeds a threshold:

1️⃣ Go to Azure Logic Apps in Azure Portal.
2️⃣ Create a new Logic App → Choose a Trigger (e.g., “When a file is added to OneDrive”).
3️⃣ Add an Action → Select “Send Email” (via Outlook, SendGrid, etc.).
4️⃣ Configure the email body with extracted invoice details.
5️⃣ Save and test the workflow.


🚀 Conclusion

Azure Document Intelligence simplifies automated document processing by extracting structured data from invoices, receipts, and contracts. With just an API call, you can:
✅ Convert scanned documents into structured data.
✅ Automate invoice processing and financial workflows.
✅ Integrate with databases, CRMs, and automation tools.

🔗 Further Learning:

Natural Language Processing with Azure Text Analytics

Introduction

Natural Language Processing (NLP) is essential for extracting meaningful insights from text data. Whether analyzing customer feedback, processing documents, or detecting sentiments in user reviews, NLP enables smarter decision-making.

Azure Text Analytics provides a powerful cloud-based API for NLP tasks, eliminating the need to build and train machine learning models from scratch. With just an API request, you can:
✅ Extract key phrases from text
✅ Detect language automatically
✅ Perform sentiment analysis

This guide walks through setting up Azure Text Analytics, sending text data for processing, and visualizing the results.


1️⃣ Setting Up Azure Text Analytics

Before making API calls, an Azure Text Analytics resource needs to be set up.

Steps to Create a Text Analytics Resource

  1. Log in to Azure Portal.
  2. Click Create a resource → Search for “Text Analytics”.
  3. Select Cognitive Services → Text Analytics.
  4. Fill in the required details:
    • Subscription: Choose an active Azure subscription.
    • Resource Group: Create or use an existing one.
    • Region: Pick the nearest Azure region.
    • Pricing Tier: Start with the free F0 tier (if available).
  5. Click Review + Create → then Create.

Once the deployment completes, go to “Keys and Endpoint” in the Text Analytics resource to get:
✔ API Key
✔ Endpoint URL


2️⃣ Sending Text Data to Azure Text Analytics API

With the API Key and Endpoint ready, it’s time to send text data for NLP processing.

Here’s a Python script to extract key phrases, detect language, and analyze sentiment:

This dataset consists of three sample texts in different languages. Each document is assigned an ID, a language code, and the text to be analyzed.


3️⃣ Extracting Key Phrases

Key phrase extraction helps identify the most relevant words from a block of text. This feature is useful for:

  • Summarizing text in a document.
  • Extracting key topics from customer reviews.
  • Identifying frequently mentioned terms in a dataset.

API Call for Key Phrases

To extract key phrases, send a POST request to the API:


response = requests.post(f"{ENDPOINT}/keyPhrases", headers=headers, json=documents)

result = response.json()

print("Key Phrases Extraction Results:")

for doc in result["documents"]:

    print(f"Document {doc['id']}: {doc['keyPhrases']}")


📌 Example Output:

Key Phrases Extraction Results:


Document 1: ['Azure Text Analytics', 'NLP']

Document 2: ['travailler', 'Azure AI']

Document 3: ['inteligencia artificial', 'Azure']

4️⃣ Detecting Language

For multilingual text, Azure’s Language Detection API automatically detects the language and confidence score.

API Call for Language Detection


response = requests.post(f"{ENDPOINT}/languages", headers=headers, json=documents)

result = response.json()

print("Language Detection Results:")

for doc in result["documents"]:

    print(f"Document {doc['id']}: {doc['detectedLanguage']['name']} (Confidence: {doc['detectedLanguage']['confidenceScore']:.2f})")

📌 Example Output:

Language Detection Results:


Document 1: English (Confidence: 0.99)

Document 2: French (Confidence: 0.97)

Document 3: Spanish (Confidence: 0.98)

5️⃣ Performing Sentiment Analysis

Sentiment Analysis determines whether a sentence is positive, negative, or neutral.

API Call for Sentiment Analysis


response = requests.post(f"{ENDPOINT}/sentiment", headers=headers, json=documents)

result = response.json()

print("Sentiment Analysis Results:")

for doc in result["documents"]:

    print(f"Document {doc['id']}: Sentiment - {doc['sentiment']} (Confidence: {doc['confidenceScores']})")

📌 Example Output:

Sentiment Analysis Results:


Document 1: Sentiment - positive (Confidence: {'positive': 0.98, 'neutral': 0.01, 'negative': 0.01})

Document 2: Sentiment - positive (Confidence: {'positive': 0.95, 'neutral': 0.04, 'negative': 0.01})

Document 3: Sentiment - neutral (Confidence: {'positive': 0.33, 'neutral': 0.62, 'negative': 0.05})

6️⃣ Visualizing NLP Results

To better interpret sentiment scores, results can be plotted using Matplotlib:


import matplotlib.pyplot as plt

labels = ["Positive", "Neutral", "Negative"]

scores = [0.98, 0.01, 0.01]  # Replace with actual confidence scores

plt.bar(labels, scores, color=["green", "gray", "red"])

plt.xlabel("Sentiment")

plt.ylabel("Confidence Score")

plt.title("Sentiment Analysis Results")

plt.show()

🚀 Conclusion

Azure Text Analytics simplifies Natural Language Processing by providing pre-built NLP models for key phrase extraction, language detection, and sentiment analysis.

🔗 Further Learning:

Real-Time Anomaly Detection with Azure Cognitive Services Anomaly Detector

Introduction

Anomaly detection is crucial for identifying outliers in real-time data streams, such as:
✔️ IoT telemetry
✔️ Financial transactions
✔️ System logs

Anomalies can indicate security threats, system failures, fraud, or operational inefficiencies. Without an automated detection mechanism, businesses may struggle to catch critical issues in real time.

Azure Cognitive Services Anomaly Detector enables developers to easily integrate anomaly detection capabilities into applications without requiring deep expertise in machine learning. The service handles various types of time-series data, using advanced statistical techniques to differentiate normal and anomalous patterns.

In this guide, we will walk through:

✅ Setting up the Anomaly Detector API in Azure
✅ Using the API to analyze real-time data streams
✅ Processing API responses to detect anomalies
✅ Integrating alerts for detected anomalies
✅ Use cases for IoT, finance, and operational monitoring


Step 1: Setting Up the Anomaly Detector API

Prerequisites

Before you begin, ensure you have:
✔️ An Azure subscription
✔️ An Anomaly Detector resource created in the Azure Portal
✔️ Python or another programming language that supports HTTP requests

Creating an Anomaly Detector Resource

1️⃣ Sign in to the Azure Portal
2️⃣ Search for “Anomaly Detector” in the marketplace
3️⃣ Click “Create”, then select:

  • Subscription
  • Resource Group
  • Pricing Tier
    4️⃣ Choose the appropriate pricing tier based on expected API usage
    5️⃣ After deployment, navigate to the “Keys and Endpoint” section and copy your API key and endpoint

For detailed steps, refer to the Azure Anomaly Detector documentation


Step 2: Sending Data to the API

To detect anomalies, send time-series data to the API. The data must:
✔️ Contain at least 12 data points
✔️ Be structured as a list of timestamps with numerical values
✔️ Maintain a consistent interval between data points to improve accuracy

For instance, in IoT monitoring, sensor data collected at fixed intervals can be sent to the API for anomaly detection. Similarly, in financial transactions, recorded amounts over time can be analyzed for fraud detection.

Sample Code: Sending Data to Anomaly Detector


import requests

import json

# Replace with your Anomaly Detector resource details

API_KEY = "<your_api_key>"

ENDPOINT = "<your_endpoint>/anomalydetector/v1.0/timeseries/entire"

headers = {

    "Ocp-Apim-Subscription-Key": API_KEY,

    "Content-Type": "application/json"

}

data = {

    "series": [

        {"timestamp": "2024-01-01T00:00:00Z", "value": 10.0},

        {"timestamp": "2024-01-02T00:00:00Z", "value": 15.0},

        {"timestamp": "2024-01-03T00:00:00Z", "value": 30.0},

        {"timestamp": "2024-01-04T00:00:00Z", "value": 500.0},  # Anomaly

        {"timestamp": "2024-01-05T00:00:00Z", "value": 20.0}

    ],

    "granularity": "daily"

}

response = requests.post(ENDPOINT, headers=headers, json=data)

print(response.json())


For full API details, refer to the Anomaly Detector API Reference


Step 3: Processing API Responses

The API returns a response indicating whether each data point is an anomaly. It also provides expected values and confidence scores, which help users understand the anomaly’s significance.

Example Response:

📌 This response suggests an anomaly occurred at the fourth data point, where the observed value deviated significantly from the expected trend.

Extracting Anomalies in Python

The expectedValues, upperMargins, and lowerMargins provide further insights into detected anomalies. Developers can use these threshold-based alerting systems to automate responses.


Step 4: Integrating Alerts for Anomalies

Once anomalies are detected, trigger alerts using Azure services like:
✔️ Azure Logic Apps
✔️ Power Automate
✔️ Azure Functions

Use Case: Industrial IoT Monitoring

  • Scenario: A manufacturing company uses IoT sensors to monitor machine performance.
  • Implementation: Anomaly detection alerts engineers about unexpected vibration levels, preventing machine failures.
  • Outcome: Reducing unplanned downtime and increasing production efficiency.

Sending an Alert via Email (Using Azure Logic Apps)

1️⃣ Navigate to Azure Logic Apps in the Azure Portal
2️⃣ Create a new Logic App and select a trigger (e.g., HTTP request)
3️⃣ Add an action “Send Email” using Office 365, SendGrid, or SMTP
4️⃣ Configure the email body to include anomaly details
5️⃣ Deploy and test with API output

For more on automation, visit Azure Logic Apps Documentation


Conclusion

In this guide, we covered:
✅ Setting up the Anomaly Detector API
✅ Sending real-time time-series data to the API
✅ Processing API responses to detect anomalies
✅ Integrating alerts using Azure services
✅ Real-world applications of anomaly detection

Azure Cognitive Services Anomaly Detector simplifies real-time anomaly detection, making it ideal for:
✔️ IoT monitoring
✔️ Financial fraud detection
✔️ Predictive maintenance

By leveraging automated alerts and response mechanisms, businesses can improve operational efficiency and reduce risk.

For further learning, visit Azure Anomaly Detector Documentation.

Breaking the Barrier to Entry: How AI is Redefining Competitive Moats

yea the AI generated it....


Businesses that historically built competitive moats around expertise that took decades to cultivate are in trouble. Why? … because AI has now commoditised that advantage and collapsed the previous barriers to entry. This is not only in IT, it is in pretty most every industry … medicine, legal, industrial, services. Think hard – there are very few that remain, or will remain untouched in the next 3..5 years tops.

Traditionally, complex products and high engineering costs prevented newcomers from easily entering markets. Incumbents leveraged large teams of specialized talent, complex infrastructure, and considerable financial resources to maintain dominance. These barriers ensured only well-established and well funded companies could offer high-quality, innovative products at scale. However, AI significantly lowers these historical barriers, allowing start-ups to compete effectively. For example, Y Combinator highlights that its recent cohorts feature significantly smaller teams that are more productive and profitable early than in previous years, leveraging AI tools to rapidly deliver innovative products and scale efficiently.

The Shift from Scarcity to Abundance

Scarcity once defined competitive advantage. Specialized (read highly paid) engineers and rare expertise meant power. However, AI has democratized access to these skills. Machine learning models, generative AI tools, and (now emerging) self-tweaking autonomous systems mean businesses no longer need vast in-house expertise. Instead, companies can rapidly acquire capabilities previously unattainable without massive investment. Tasks requiring hundreds of human engineers now take just a handful of developers leveraging AI-driven tools. Businesses must recognize that the scarcity advantage they relied upon has been largely erased. This does of course bring with it its own share of problems, as now more junior engineers (and other specialisations) are prompt-generating code/solutions that in many cases they simply do not understand and would be unable to maintain on a deep level should (not if, when!) things start to unravel. The short-term gain of value growth and productivity may yet come and bite us hard when we have to maintain and build on the code currently being developed. Prompt generated reliance often results in a superficial understanding of the generated code, and this is a real deep problem for the industry. Namanyay Goel captures it perfectly in this graph which shows the more engineers use GPTs for code, the less knowledge they acquire.

      (credit: Namanyay Goel website)

Democratization of Innovation

AI enables small (and single person) teams to innovate rapidly, experiment at minimal cost, and scale quickly. As a result, market dominance that was built on years of hard-won thousands of hours of painful engineering R&D is gone, vanished overnight, bye-bye golden goose. Subsequently, AI-driven software prototypes can be developed, tested, and deployed within hours and days rather than months or years. Executives need to understand that the pace of innovation has changed dramatically – smaller competitors and bedroom coders can now rapidly iterate products using generative AI platforms. They don’t need (and indeed some I’ve talked to outright reject) the training and hard-won experience previously required to carry out their work.

Have an idea? … iterate the code to build it in ten minutes – doesn’t work? .. iterate it for an hour – still not working? … plead with the GPT to fix it for you because you simply don’t understand the code (but if you rephrase your prompt in just another way it may work)… still not working?, ok, move to the next idea, rinse, repeat. To understand how this is literally changing the industry, look at some of these ‘code with me, I’ve never coded before’ videos on YouTube to get the idea #scary.

Leaving the newly hatched code-bros in their bedroom, look at what’s happening with the big-boys. For example, Microsoft uses AI agents extensively for autonomous research and development. Their collaboration with Swiss start-up inait created AI models emulating mammalian brain reasoning, designed to enhance functionalities ranging from finance to robotics by learning from real-world interactions. If you are an exec in any sized company, you need to recognise and embrace this AI change because its a veritable tsunami hurtling towards you and its only getting faster. The tiny innovators with the budget of a postage stamp recognise this, global sized organisations recognise this – do you? … what actions are you taking today to meet the challenge?

#Pivot #Pivot #Pivot

Incumbents face significant challenges due to the shift in the speed and democratisation of innovation just outlined – executives that don’t see this simply have their head buried in the sand. Long-term dominance created a culture resistant to rapid innovation, it was soft, comfy and lazy. Large companies often move slowly due to legacy processes, established hierarchies, and substantial infrastructure investments. The very real shakeups you see in the giants right now demonstrates clearly how serious a threat they see this as. AI-driven start-ups are agile, and can quickly pivot to exploit emerging market opportunities. Incumbent companies must rethink their approach, and re-imagine and re-structure their organisations to get back to basics and the original innovative spark that created them in the first place; but, do it using todays new  paradigms. Executives need to prioritize organizational agility, rapid experimentation, and a willingness to disrupt their own business models. Failure to adapt quickly allows nimble competitors to seize market share and then you’re dead – remember its far easier to be a hyper-growth new innovator with little legacy constraints than to maintain position as top dog in a market with all of the product and organisational baggage that entails.

Better get juggling….

The pace of innovation driven by AI demands continuous reassessment of competitive positioning. At SocialVoice.ai for example, we have been able to spin up completely new product offerings that were a subset of our overall foundation technology and offer this on a value based micro-consumption basis to customers. This didn’t take us weeks and months, it took us a few hours of conversation with clients, and then a few hours of very focused collaborative ideation and coding to make it happen. If you can’t do this kind of manoeuvre in at most a few weeks, you are in serious trouble and highly exposed to a hyper fast moving competitor. #Pivot #Pivot #Pivot.

Moving from SaaS to Micro-Use Value Models

Historically, SaaS models dominated software delivery. Companies sold subscriptions offering broad feature sets regardless of usage intensity. AI disrupts this model, allowing businesses to shift towards value-based micro-use. AI agents autonomously discover, connect, transact, and deliver precise functionalities exactly when and where needed. New AI agent systems can (and will) integrate seamlessly with legacy SaaS applications, extracting and delivering targeted functionalities precisely aligned with customer requirements. Customers rarely use 100% of traditional SaaS features, leading to inefficiencies. Future market preferences will favour vendors offering highly targeted, agentic solutions tailored specifically to business needs. While this targeted approach may be more expensive per transaction, it ultimately allows customers to pay only for the value they actually use, increasing overall satisfaction and efficiency, thus ultimately better overall value. Companies like Datastreamer illustrate this shift, offering no-code tools that drastically lower barriers for API integration. Previously, organizations faced months-long delays due to scarce engineering resources and competing internal priorities. Tools from providers like Datastreamer now enable rapid adoption and efficient use of valuable microservices on a per-transaction basis, dramatically accelerating business agility. Another example is Socialgist, who bring together oceans of data from different sources and allow customers to mix and match just what they want to make up their own customised datasets. The moats of tomorrow are different, and the highly efficient value delivery systems of these two examples show how it can be achieved.

So what the heck do we do now??

Executives worried about AI disruption should proactively adopt defensive strategies. They should become paranoid about falling behind in the market. They must prioritize flexibility, speed, and customer-centric innovation. Incumbents should rapidly integrate AI across their operations, reducing internal friction that inhibits innovation. Establishing agile innovation teams focused on experimenting with AI-driven tools can help incumbents stay competitive. Executives must encourage cultures of experimentation and continuous learning. Companies that succeed will embrace AI-driven experimentation, rapidly adapting product offerings based on real-time feedback and shifting market dynamics. If you decide to engage with consultants, challenge them to actually deliver value, rather than simply regurgitating what you already know – in many cases you will get a better ROI and build a stronger strategic partnership with a smaller hyper focused and nimble consultancy than with the usual suspects. Look for ROI value based engagements, look for short term tactics and longer term strategies that can be informed by measurable outcomes from the tactical initiatives. Ask one group to ideate, and ask another to implement. Pitch one group against another to foster competition (but play nice!). Play to strengths, recognise weaknesses and deploy your resources accordingly.

Good luck – we’re in for a rollercoaster (and I suspect for most, a somewhat bumpy) ride!

Building and Deploying a Custom Vision Model on Azure

Introduction

Azure Custom Vision is a cloud-based service that enables developers to build, train, and deploy custom image classification models without requiring deep machine learning expertise. It provides an easy-to-use interface and API, allowing users to:
✔️ Upload images
✔️ Label images
✔️ Train models that recognize specific objects or categories

In this guide, we will walk through:

✅ Creating and configuring a Custom Vision project
✅ Uploading and labeling custom training images
✅ Training a custom image classification model
✅ Deploying the trained model as an API endpoint
✅ Performing image inference using the deployed API

Step 1: Setting Up a Custom Vision Project

Prerequisites

Before starting, ensure you have:
✔️ An Azure account with an active subscription
✔️ Access to the Azure Custom Vision portal
✔️ The Azure Custom Vision SDK (if working with code)
✔️ A dataset of labeled images for training

Creating a Custom Vision Project

1️⃣ Navigate to the Azure Custom Vision portal
2️⃣ Sign in with your Azure credentials
3️⃣ Click “New Project” and configure the settings:

  • Project Name: Enter a unique project name
  • Resource Group: Choose or create a resource group
  • Project Type: Choose Classification (for object classification) or Object Detection (if detecting multiple objects in an image)
  • Domains: Select a domain that best suits your dataset (e.g., General, Food, Retail)
    4️⃣ Click “Create project” to proceed.

For more details, refer to the Azure Custom Vision Documentation


Step 2: Uploading and Labeling Training Data

Uploading Images

  1. Open the created project in the Custom Vision portal.
  2. Click “Add images” and select images from your local machine.
  3. Assign tags (labels) to classify images into categories.
  4. Click “Upload” to add images to the training dataset.

Best Practices for Image Labeling

✔️ Use at least 50 images per category for better accuracy.
✔️ Ensure images are varied in lighting, angles, and backgrounds.
✔️ Label images accurately to improve model performance.


Step 3: Training the Custom Vision Model

  1. In the Custom Vision portal, click “Train”.
  2. Choose between:
    • Quick Training (faster but less accurate for small datasets)
    • Advanced Training (recommended for higher accuracy and larger datasets)
  3. Wait for the training process to complete.
  4. After training, view performance metrics such as precision, recall, and overall accuracy.

Sample Code: Training a Custom Vision Model via SDK


from azure.cognitiveservices.vision.customvision.training import CustomVisionTrainingClient

from msrest.authentication import ApiKeyCredentials

# Azure Custom Vision credentials

ENDPOINT = "<your_custom_vision_endpoint>"

TRAINING_KEY = "<your_training_key>"

credentials = ApiKeyCredentials(in_headers={"Training-key": TRAINING_KEY})

trainer = CustomVisionTrainingClient(ENDPOINT, credentials)

# Create a new project

project = trainer.create_project("My Custom Vision Project")

Step 4: Deploying the Model as an API

Once training is complete, navigate to the Performance tab in Custom Vision.

  1. Click “Publish” and configure the API endpoint:
    • Prediction Resource: Choose an Azure resource for deployment.
    • Model Name: Provide a name for the deployed model.
  2. Click “Publish” to deploy the trained model as an API.

For more details, refer to the Custom Vision Deployment Guide

Sample Code: Accessing the Model via API


from azure.cognitiveservices.vision.customvision.prediction import CustomVisionPredictionClient

from msrest.authentication import ApiKeyCredentials

# Azure Custom Vision Prediction credentials

PREDICTION_KEY = "<your_prediction_key>"

predictor = CustomVisionPredictionClient(ENDPOINT, ApiKeyCredentials(in_headers={"Prediction-key": PREDICTION_KEY}))

# Perform image classification

image_path = "test_image.jpg"

with open(image_path, "rb") as image_data:

    results = predictor.classify_image("<project_id>", "<published_model_name>", image_data.read())

    for prediction in results.predictions:

        print(f"{prediction.tag_name}: {prediction.probability * 100:.2f}%")

Step 5: Performing Image Inference

After deployment, you can send images to the API to get classification results.

Example API Call

You can test the API using Python, Postman, or any HTTP client:


import requests

url = "https://<your_custom_vision_endpoint>/classify/iterations/<your_model>/image"

headers = {"Prediction-Key": "<your_prediction_key>", "Content-Type": "application/octet-stream"}

with open("image.jpg", "rb") as image_file:

    response = requests.post(url, headers=headers, data=image_file.read())

    print(response.json())

Conclusion

In this guide, we covered:
✅ Creating a Custom Vision project
✅ Uploading and labeling training images
✅ Training a custom image classification model
✅ Deploying the trained model as a REST API
✅ Performing image inference using the API

Azure Custom Vision makes it easy to build and deploy image classification models with minimal coding effort. You can further enhance your model by:
✔️ Adding more training images
✔️ Retraining with additional categories
✔️ Integrating it with Azure Functions and Power Automate for automated workflows

For further learning, visit the Azure Custom Vision Documentation.