← All guides

GUIDE · MICROSOFT FOUNDRY · FINE-TUNING

How to fine-tune a model on Microsoft Foundry for text classification

A step-by-step Azure OpenAI fine-tuning tutorial for classification on Microsoft Foundry: JSONL, training types, deployment and hosting cost, or from a spreadsheet.

By Manoj Mohandas ·

Fine-tuning and the StayCharted workflow

  • Part 1: fine-tune a model such as GPT-4.1-mini yourself in Microsoft Foundry (formerly Azure AI Foundry, home of Azure OpenAI).
  • Part 2: the same in your own Foundry from a spreadsheet, with StayCharted doing every step.

Before you start

  • A Foundry resource and project in an Azure subscription, in a region where the model you want supports fine-tuning.
  • Roles: you can train with a Foundry User role, but deploying needs Foundry Owner or a role that can write deployments.
  • Labeled examples: past records with the category your team gave each one. Microsoft's minimum is 10; start with at least 50 good ones, and hundreds for many categories. Keep a test set apart.
  • A budget for hosting: a deployed fine-tuned model has an hourly fee whether it's used or not.

Which model? For short records and clear categories, start with GPT-4.1-mini or GPT-4.1-nano: cheaper to train and to ask.

Part 1: Fine-tune in Foundry

Step 1. Write the training file

Chat Completions format, one example per line, saved as UTF-8 with a byte-order mark, under 512 MB:

Show JSON example
{"messages": [{"role": "system", "content": "Categorize the support ticket. Answer with one of: Billing, Technical, Account, Sales."}, {"role": "user", "content": "I was charged twice for my subscription this month."}, {"role": "assistant", "content": "Billing"}]}

Use the same system message on every line, and keep it: you'll ask with it later.

Step 2. Start the job

In the Foundry portal (ai.azure.com), open your project, then Build → Fine-tune → Fine-tune:

  • Base model: for example GPT-4.1-mini.
  • Method: supervised fine-tuning.
  • Training type: Global when its processing locations and rates meet your requirements; Standard if the data must stay in your region; Developer for experiments on preemptible capacity.
  • Data: upload the training file and a validation file.
  • Hyperparameters: epochs, batch size and learning rate multiplier; the defaults are a fine start.

Submit, and watch training loss and validation loss in the job's metrics.

Step 3. Deploy

From the job, choose Deploy and give the deployment a name (for example ticket-router-ft). Hosting is billed by the hour from now on; a Developer-tier deployment has no hosting fee but is removed after 24 hours.

Step 4. Call it and test it

Call the deployment name in chat completions, with the same system message you trained with. Ask it about every example in your test set and work out accuracy per category. Decide which answers a person checks.

Step 5. Keep an eye on hosting

A deployment that's inactive for 15 days in a row is deleted (the model is kept, and can be redeployed). Delete deployments you no longer need so the hourly fee stops.

Part 2: Fine-tune in your Foundry from a spreadsheet, with StayCharted

StayCharted does every step of Part 1 in your own Foundry resource. You need a StayCharted workspace on Business, and an admin of your Microsoft tenant for the one-time sign-in.

Step 1. Connect your Foundry resource (once)

  1. In StayCharted, go to Settings → AI platforms → Microsoft Foundry.
  2. Paste the resource's endpoint (ending .azure.com) and its resource ID (the resource's Properties page in the Azure portal, starting /subscriptions/).
  3. Under Sign in with, keep Microsoft (StayCharted's app, recommended), and tick Also train models here.
  4. Choose Sign in with Microsoft. An admin of your tenant consents once to StayCharted's app; there's no secret to create or paste.
  5. Back in StayCharted, choose Deploy to Azure and deploy into your resource's resource group. It assigns StayCharted's app two roles on that one resource: Cognitive Services OpenAI Contributor, and a custom role that can only read, create and delete its deployments. Neither can read the resource's keys.
  6. Press Test. "Training is ready" means it can fine-tune and deploy.

This replaces Part 1's roles and permissions. Prefer your own Entra app registration? Choose it under Sign in with instead and give it the same roles. An API key can ask models but can't deploy a trained one, so it can't train.

Step 2. Upload your examples

A spreadsheet (CSV or Excel) of past records with the category your team gave each one. StayCharted checks the data before training: rows that look like they belong in another category, the same text under two categories, near-duplicates. From Google Sheets, the StayCharted add-on sends the rows straight from the sheet.

Step 3. Choose Foundry and a base model

Choose Train a model on your examples, then under where it trains, Your servers — Microsoft Foundry, and the AI to train: GPT-4.1 mini to start, or GPT-4.1 nano, GPT-4.1 or GPT-4o mini. Start training.

Step 4. Let it run

StayCharted does Part 1's steps 1 to 4:

  • holds back test rows, which never go into training;
  • writes the JSONL (UTF-8 with a byte-order mark) with the same system message it will ask with, and uploads it to your resource;
  • starts Global training (Standard if your resource or model doesn't offer Global; the report says which);
  • deletes the training file when the job ends;
  • deploys the result to a Developer deployment with no hourly hosting fee and tests it on the held-out rows.

You can close the browser; the model page shows where it's up to: checking the file, waiting in Foundry's queue, learning, testing.

How long it took for us: on a 48-row file with GPT-4.1 nano and Global training, the job waited about 18 minutes in Foundry's queue and file check before training started, Azure paused once to wait for GPUs, and it finished 1 hour 32 minutes after it was queued.

Step 5. Read the report, then publish

The report shows how often the model is right for each category and the examples it got wrong. When you publish, StayCharted makes a Global Standard deployment in your resource for answers; Azure bills it by the hour while it's deployed (see Who pays for what). While Azure makes it, the test deployment with no hourly hosting fee answers. Publishing another version, or deleting the model, removes that deployment, so nothing is left billing for a model nobody uses.

Step 6. Use it

The model answers from your Foundry, wherever StayCharted models are used: spreadsheet fills, the API, Zapier, Power Automate, Google Sheets, and Claude and ChatGPT. Foundry gives an answer, not a probability, so StayCharted estimates how sure each answer is from how your team labeled the most similar past records; unsure ones wait in the Review Queue.

Not ready to fine-tune? Use a Foundry deployment as it is

StayCharted can also use a deployment you already have without fine-tuning it: connect with a key or a sign-in, list the deployment names, and choose Use your own AI, without training. Each question goes with your categories, your labeling guide and the past examples most like the record. There's no hosting fee beyond your normal deployment, and you can compare it with a fine-tuned model on the same rows.

Who pays for what

Billed by
Fine-tuning (per training token) Azure, to your subscription
The test (Developer) deployment No hosting fee; Azure removes it after 24 hours
The published (Global Standard) deployment Azure, by the hour, while it's deployed
Answers (per token) Azure, to your subscription
Rows read and answered by StayCharted Your StayCharted plan, like any model

If something goes wrong

You see What to do
The endpoint isn't accepted Paste your resource's https address; it must end in .azure.com.
"Paste your Microsoft Entra tenant ID." / "Paste the app registration's client ID." For Entra sign-in, copy both from the app registration's Overview page.
The deployment can't be found List the deployment name exactly as Foundry shows it, not the model name.
"Training needs a Microsoft sign-in" An API key can't deploy a trained model. Choose Sign in with Microsoft.
"Give StayCharted's app the roles on the resource" Run Deploy to Azure again (it needs Owner or User Access Administrator on the resource group), or assign the roles by hand in the resource's Access control (IAM).
"This model is still being deployed in your Foundry" The published deployment takes a few minutes; fills wait for it by themselves.
In Part 1, the file is rejected Save it as UTF-8 with a byte-order mark, one JSON object per line.
In Part 1, you can train but not deploy Ask for Foundry Owner, or a role with permission to write deployments.

Provider documentation and pricing

Developer deployment costs

A Developer deployment has no hourly hosting fee during its temporary evaluation lifetime. Inference is still billable. Publishing creates the paid deployment; check current model, region and deployment rates. Global training may process data outside your resource’s region.

Common questions about Microsoft Foundry fine-tuning

How long does fine-tuning take on Foundry?

From under an hour to several hours, depending on the data, the model, the training type and Microsoft's queue: a 48-row file on Global training took us 1 hour 32 minutes, most of it waiting. Developer-tier jobs can be paused and resumed.

What does a fine-tuned model cost to keep?

An hourly hosting fee while it's deployed (check current model, region and deployment rates), plus per-token answers.

Can I use a model I fine-tuned myself in StayCharted?

Yes: list its deployment name. StayCharted asks it with its own instructions and examples, not the system message you trained with, so test it on your rows before publishing.

Can StayCharted fine-tune in my Foundry?

Yes, on Business: GPT-4.1 mini, GPT-4.1 nano, GPT-4.1 and GPT-4o mini, in your own resource. StayCharted tests on a Developer deployment with no hourly hosting fee; the paid one is made only when you publish.

Does StayCharted get my Foundry keys?

No. Signing in with Microsoft gives StayCharted's app two roles on the one resource, and neither can read its keys. Remove the role assignments, or the app from Enterprise applications, to cut it off.

Put it into practice

STAYCHARTED AI MODEL TRAINER

Train AI to categorize the way your team does.

Start with examples you already have, see how often it’s right on items it never saw, and use confidence to prioritize the ones a person should review.

Start free