Back to blog
AzureAIMicrosoftTutorial

Getting Started with Azure AI Foundry

A practical guide to building your first AI application using Azure AI Foundry, the Microsoft AI platform for developers.

2 min read

Why Azure AI Foundry?

Azure AI Foundry (formerly Azure AI Studio) is Microsoft's unified platform for building generative AI applications. If you're building production AI apps on the Microsoft stack, this is your starting point.

What You'll Learn

In this guide, we'll cover:

  1. Setting up your Azure AI Foundry workspace
  2. Deploying your first model
  3. Building a simple chat application
  4. Best practices for production

Setting Up Your Workspace

First, head to Azure AI Foundry and create a new project. You'll need an Azure subscription - the free tier works fine for getting started.

import { AzureOpenAI } from "openai";
 
const client = new AzureOpenAI({
  endpoint: process.env.AZURE_OPENAI_ENDPOINT,
  apiKey: process.env.AZURE_OPENAI_KEY,
  apiVersion: "2024-10-21",
});
 
const response = await client.chat.completions.create({
  model: "gpt-4o",
  messages: [
    { role: "system", content: "You are a helpful assistant." },
    { role: "user", content: "Hello, world!" },
  ],
});
 
console.log(response.choices[0].message.content);

Deploying a Model

Navigate to the Deployments section and click Create deployment. Select gpt-4o as your base model.

Tip: Start with pay-as-you-go pricing. You can switch to provisioned throughput later when you need guaranteed capacity.

Configuration Options

SettingRecommended ValueNotes
Modelgpt-4oBest balance of capability and cost
VersionLatestAlways use the latest stable version
Rate Limit80K TPMAdjust based on your needs

Building Your First App

Here's a complete Next.js API route that calls Azure OpenAI:

// app/api/chat/route.ts
import { AzureOpenAI } from "openai";
import { NextResponse } from "next/server";
 
const client = new AzureOpenAI({
  endpoint: process.env.AZURE_OPENAI_ENDPOINT!,
  apiKey: process.env.AZURE_OPENAI_KEY!,
  apiVersion: "2024-10-21",
});
 
export async function POST(req: Request) {
  const { message } = await req.json();
 
  const completion = await client.chat.completions.create({
    model: "gpt-4o",
    messages: [
      {
        role: "system",
        content: "You are a helpful coding assistant.",
      },
      { role: "user", content: message },
    ],
  });
 
  return NextResponse.json({
    reply: completion.choices[0].message.content,
  });
}

What's Next

Now that you have the basics down:

  • Add streaming - Use the stream: true option for real-time responses
  • Add RAG - Connect Azure AI Search for retrieval-augmented generation
  • Add safety - Implement Azure AI Content Safety for production guardrails

Stay tuned for the next post where we'll build a full RAG pipeline with Supabase as the vector store.