Microsoft joins AI cost-cutting trend by relying more on its own models
Back to Tutorials
techTutorialbeginner

Microsoft joins AI cost-cutting trend by relying more on its own models

July 7, 202611 views5 min read

Learn how to set up and use Microsoft Azure AI services to build your own AI models, demonstrating how companies like Microsoft are cutting AI costs by relying on their own models.

Introduction

In today's fast-paced tech world, companies are constantly looking for ways to reduce costs while maintaining innovation. Microsoft's recent move to rely more on its own AI models is part of a larger trend where companies are optimizing their AI spending. In this tutorial, you'll learn how to work with AI models using Microsoft's Azure AI services, which is a practical way to understand how companies like Microsoft are managing their AI resources more efficiently.

This tutorial will guide you through setting up an Azure AI project, creating a simple AI model, and understanding how to use your own models rather than relying on expensive third-party services.

Prerequisites

Before starting this tutorial, you'll need:

  • A Microsoft Azure account (you can get a free account with $200 credit)
  • Basic understanding of Python programming
  • Python 3.7 or higher installed on your computer
  • Visual Studio Code or any code editor

Step-by-Step Instructions

1. Create an Azure Account and Set Up Your Environment

The first step is to create a free Azure account if you don't already have one. Visit azure.microsoft.com and click on "Start free". Complete the registration process, and once you're logged in, navigate to the Azure portal.

Why this step? Azure provides the cloud infrastructure needed to run AI models efficiently. By using your own models, you can significantly reduce costs compared to using third-party AI services.

2. Install Required Python Packages

Open your terminal or command prompt and install the necessary Python packages:

pip install azure-ai-formrecognizer azure-ai-vision azure-ai-textanalytics

Why this step? These packages provide the client libraries needed to interact with Azure AI services. We'll be using them to demonstrate how to create and use your own models instead of relying on external services.

3. Create a New Python Project

Create a new folder for your project and initialize it:

mkdir azure-ai-project
 cd azure-ai-project
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

Then install the required packages in your virtual environment:

pip install azure-ai-formrecognizer azure-ai-vision azure-ai-textanalytics

Why this step? Using a virtual environment ensures that your project dependencies don't interfere with other Python projects on your computer.

4. Set Up Azure AI Services

In the Azure portal, create a new resource by searching for "AI services" and selecting "AI services" from the results. Click "Create" and fill in the details:

  • Subscription: Select your subscription
  • Resource group: Create a new one or use an existing one
  • Region: Choose a region near you
  • Name: Give your resource a unique name
  • SKU: Select "F0" for the free tier

After creating the resource, go to your resource and get the endpoint and key from the "Keys and Endpoint" section.

Why this step? Setting up your own AI services allows you to create and manage your models, which is more cost-effective than using external services.

5. Create Your First AI Model

Create a new file called ai_model.py and add the following code:

import os
from azure.ai.formrecognizer import FormRecognizerClient
from azure.core.credentials import AzureKeyCredential

# Set your Azure AI service credentials
endpoint = "YOUR_ENDPOINT_HERE"
key = "YOUR_KEY_HERE"

# Create the client
form_recognizer_client = FormRecognizerClient(endpoint, AzureKeyCredential(key))

# Analyze a sample document
with open("sample_document.jpg", "rb") as document:
    poller = form_recognizer_client.begin_recognize_content(document)
    results = poller.result()

for page in results:
    for cell in page.cells:
        print(f"Cell: {cell.content}")

Why this step? This demonstrates how to use your own Azure AI service to process documents, showing that you can build and use your own models rather than relying on external APIs.

6. Test Your Model

Create a sample document (you can use any image file) and save it as sample_document.jpg in your project folder. Then run your Python script:

python ai_model.py

Check the output to see how your model processes the document content.

Why this step? Testing your model helps you understand how it works and ensures that you're correctly using your own AI resources instead of external services.

7. Optimize Your AI Usage

Microsoft's approach to cost-cutting involves using their own models more efficiently. You can optimize your AI usage by:

  • Using custom models instead of pre-trained ones
  • Processing data in batches rather than individually
  • Implementing caching for frequently used results

For example, modify your code to process multiple documents in a loop:

documents = ["doc1.jpg", "doc2.jpg", "doc3.jpg"]
for doc in documents:
    with open(doc, "rb") as document:
        poller = form_recognizer_client.begin_recognize_content(document)
        results = poller.result()
        # Process results here

Why this step? Optimizing your AI usage is key to cost-cutting. By processing data more efficiently and using your own models, you reduce the need for expensive external services.

Summary

In this tutorial, you've learned how to set up Azure AI services, create a simple AI model, and understand how using your own models can help reduce AI costs. Microsoft's approach to relying more on their own AI models is a cost-cutting strategy that many companies are adopting. By following these steps, you've gained hands-on experience with Azure AI services and learned practical techniques for managing AI resources more efficiently.

This approach allows you to build and maintain your own AI capabilities, reducing dependency on expensive third-party services while still leveraging powerful AI technologies.

Related Articles