Azure AI Studio: How to evaluate and upgrade your models, using the Prompt Flow SDK

On this page
Before you upgrade a model deployment in the Azure OpenAI Service, run the new model version and your current one against the same evaluation dataset and compare the scores. If the new version doesn't do at least as well on your data, you've found a regression before your users did.
This tutorial shows how to do that with the Microsoft Prompt Flow SDK and Azure AI Studio Evaluations. We deploy GPT-4o as a "judge" model, evaluate GPT-4o and GPT-35-turbo on a small question-answer dataset, and compare the two runs in the Azure AI Studio evaluation dashboard. In our example, GPT-4o came out ahead on almost every metric.
Why bother? New model versions keep arriving, often faster, cheaper or safer than the last one, and old versions get retired. You will have to upgrade at some point. The real question is whether the new model improves your application or introduces regressions.
We'll cover:
- Using Azure AI Studio Evaluations to assess new model versions
- Comparing models in code and in the Azure AI Studio UI
- Best practices for upgrading your deployments
Update (November 2026): Azure AI Studio was renamed Azure AI Foundry and is now
Microsoft Foundry. The
promptflow-evals package used below is deprecated
in favor of azure-ai-evaluation,
which imports evaluators from azure.ai.evaluation and expects query and response instead of
question and answer. GPT-35-turbo has been retired,
and GA models now follow an 18-month lifecycle
instead of the one-year rule quoted below, so pick a current model as your baseline.
What is Azure AI Studio?
Azure AI Studio is a platform in Microsoft Azure for building and deploying AI-powered applications. It has tools for building generative AI applications for developers with different levels of experience, and you can either use existing AI models or customize them with your own data.
That flexibility lets organizations start with pre-built models and tailor them with proprietary data later. Azure AI Studio also supports team collaboration and integrates with development tools like GitHub and Visual Studio.
The main selling point at the moment is the integration of OpenAI's models. Most OpenAI models can be managed and provisioned through Azure AI Studio. You can add content filters, deploy models, log metrics and, as this post shows, evaluate and upgrade models with the Prompt Flow SDK.
What is the Microsoft Prompt Flow SDK?
The Microsoft Prompt Flow SDK is a toolkit for developing applications based on large language models (LLMs). It covers the lifecycle of an LLM app, from the first prototype to production deployment and ongoing monitoring.
Prompt Flow SDK features
For prototyping, Prompt Flow lets you experiment with different prompt configurations to optimize model outputs. You can also put Python code directly into your workflows for custom logic and data manipulation next to your prompts.
For testing, it provides unit tests for LLM prompts, which catch regressions when prompts or the underlying models change. Its evaluation features measure how well different prompts and configurations perform. This testing and evaluation part is what we use in this tutorial.
For deployment, the SDK integrates with CI/CD pipelines and comes with monitoring and logging for deployed applications. It supports version control and shared environments for teams, and you can extend it with custom plugins and third-party integrations.
The benefit of all this is one toolkit for every stage of LLM app development. That shortens the path from prototype to production, and the built-in tests and evaluations help keep your application reliable, whether it's a small prototype or a large production system.
Why upgrade your Azure OpenAI models?
Before the hands-on part, let's step back. Why upgrade models at all, and why do you need an automated process to validate upgrades? There are two reasons.
First, models get better very quickly. The OpenAI model changelog shows the pace:
- GPT-3.5 was released in March 2022
- GPT-3.5-turbo was released in November 2022
- GPT-4 was released in March 2023
- GPT-4-turbo was released in November 2023
- GPT-4o was released in May 2024
That's a new model roughly every 6 months, and the list doesn't include minor versions like GPT-4o-mini, GPT-3.5-turbo-16k or GPT-3.5-turbo-0125. Each of these newer models offered much better performance or 10x lower cost and latency than the previous one, so not upgrading was almost negligent.
Second, Microsoft and other model providers retire older models aggressively as new ones arrive. Microsoft has fairly transparent model deprecation policies, and one of the main statements is: models can be retired 1 year after their initial release. So whatever you think about upgrading, a year after a model's release you have to.
What to evaluate when upgrading a model
The authors of the Prompt Flow SDK suggest three groups of evaluation criteria. Performance and quality metrics are groundedness, relevance, coherence, fluency, similarity and F1 score. Risk and safety metrics assess violence, sexual content, self-harm and hate/unfairness. Composite metrics combine evaluations for question-answer pairs or chat messages, and for content safety.
Here is what each metric measures:
- Groundedness: how well the model's output aligns with factual information.
- Relevance: how relevant the response is to the input prompt.
- Coherence: the logical flow of the response ("does the output make sense?").
- Fluency: the linguistic quality and naturalness of the response.
- Similarity: how similar the model output is to a reference text.
- F1 score: used for evaluations based on precision (the accuracy of the positive predictions) and recall (the ability to find all positive instances).
- Violence: content with violent or aggressive language.
- Sexual content: content with sexual references or inappropriate language.
- Self-harm: whether the content encourages or discusses self-harm.
- Hate/unfairness: the presence of hateful, biased or discriminatory language.
- Question-answer pairs: accuracy and completeness of the model's responses in a Q&A context.
- Content safety: a combination of the risk and safety metrics that rates overall content safety.
That's a lot to validate, and not every metric is relevant for every use case. Pick the ones that match what your application does.
Hands-on: evaluating models with Azure AI Studio and Prompt Flow
The rest of this post walks through a complete evaluation of two model versions with Azure AI Studio and the Prompt Flow SDK.
Prerequisites for the Prompt Flow evaluation
Prepare the following before you start:
-
Sign up for Microsoft Azure AI Studio and create a project, as outlined here.
Azure AI Studio "Create a project" dialog, review and finish step
Note: Pay attention to step 9 of that guide: "Select an existing Azure AI services resource (including Azure OpenAI) from the dropdown or create a new one." This tutorial needs an Azure OpenAI service connected to your project. Either select an existing one or create a new one.
You'll also need the Azure CLI installed on your computer. Run
az loginto authenticate your Azure account and select the subscription you want to use. -
Install the Prompt Flow evaluation and Azure packages:
-
Open the "Settings" page of your Azure AI Studio project and note down the following information:
- project name
- resource group name
- subscription id
Azure AI Studio project settings page
-
Next, deploy the AI models to evaluate, plus one model that acts as "judge" for the evaluation.
This is critical: Prompt Flow uses an LLM to judge the other LLMs. Use the model with the best reasoning quality you have as the judge. Otherwise, a weak judge model can distort the evaluation results.
Click on "Model catalog" in the Azure AI Studio left-hand menu, then select "GPT-4o".
Azure AI Studio model catalog with GPT-4o
On the next screen, click "Deploy" and a modal opens. Set the options as you see fit. For GPT-4o, the settings below worked well at the time of writing. In the "Connected Azure OpenAI resource" dropdown, select the service you connected or created in step 1 (during project creation).
Deploy model dialog for gpt-4o with Global Standard deployment
Hit "Deploy" to provision the model.
Note: This model acts as the judge for the evaluation. If you just want to follow along and don't have a "real" model to validate yet, repeat the steps above and deploy a second model, for example GPT-35-TURBO.
-
Click "Deployment" in the sidebar menu and select the model you just created. The next screen gives an overview of the deployed model. The important part for us is the "Endpoints" section: note down both the endpoint URL and the endpoint key.
-
Now create the model configurations in Python. Create an object for the Azure AI project as follows, using the values from step 3.
Then create a model configuration object for the judge model. It needs the azure_endpoint, api_key, api_version and azure_deployment, all of which come from the deployment screen in step 5.
The api_key is simply the endpoint key from the deployment screen.
For the other values, break down the endpoint URL, which is structured like this:
https://<deployment>.openai.azure.com/openai/deployments/<model_name>/<model_type>?api-version=<api_version>Example:https://openai-docusearch.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2024-02-01For the example above, the values are:
- azure_endpoint:
https://openai-docusearch.openai.azure.com - api_version:
2024-02-01 - azure_deployment:
gpt-4o
Finally, define the endpoints of the models you want to evaluate. For each model, you need two pieces of information:
- The model API endpoint
- The API key
If the models are deployed in Azure AI Studio, use the endpoint and API key from the deployment screen. For other API providers, check their documentation.
- azure_endpoint:
Azure permissions for Prompt Flow
This isn't in the official documentation: Prompt Flow uploads your code, the sample data and the evaluation results to an Azure blob storage account that is created automatically along with the project.
Provisioning the Azure AI Studio project also creates a service principal
with the same name as the project (blog in our example).
Prompt Flow uses this service principal to upload files to the blob storage. By default, it seems to lack a required permission/role, which results in the following error:
If you see this error, follow these steps:
-
Navigate to "Settings" in the Azure AI Studio project and select the "workspaceartifactstore" resource.
Azure AI Studio settings with the workspaceartifactstore resource
-
On the next screen, click "View in Azure Portal". There, click "Access control (IAM)", "Role Assignments" and then "Add".
Access control (IAM) role assignments in the Azure Portal
-
In the "Role" tab, select "Storage Blob Data Contributor", then click the "Members" tab.
Selecting the Storage Blob Data Contributor role
-
Select "Managed Identity" and click "Select members". In the sidebar that opens, select "Azure AI Project" in the managed identity dropdown. Then select the service principal with the same name as the project. Selecting the project's managed identity as a member
-
Click "Select" and then "Review + assign".
Your permissions are now set.
Creating the evaluation dataset for Prompt Flow
Next comes the evaluation dataset. As always when evaluating AI systems, the dataset is the most important part of the whole process.
For Prompt Flow, create a JSONL file with the following fields:
question: The reference question for the modelcontext: Context for the model to answer the question uponground_truth: The correct answer to the question
There is no real shortcut here. For a good evaluation, you need to invest the time to create good question/answer pairs first.
For this example, we use a simple evaluation dataset kindly provided by the Prompt Flow SDK
Create a file named data.jsonl and paste the content above into it.
Creating the model router (Prompt Flow target)
Prompt Flow lets you define a target: a callable Python class that takes
the evaluation questions and routes them to the respective model endpoints.
This is useful because it means you can evaluate not only different models
but also full RAG
pipelines.
The target class __call__ method needs to take a question and context
parameter and return a dictionary with question and answer keys.
Instead of a callable class, you can also write a Python function with the
question and context parameters that returns a dictionary with
question and answer keys. A class gives you more flexibility, though.
Add this class to a separate file named target.py:
A few things to note about the model router:
-
Note the
@tracedecorator. Traces in Prompt Flow record specific events or the state of an application during execution, such as function calls, variable values and system events. See here for more information about tracing. -
The call_gpt4o_endpoint and call_gpt35_turbo_endpoint methods are basically the same and could be a single function. I kept them separate to show how you could implement a different API provider.
-
You can extend the call-endpoint functions for your specific application. You could even add a full RAG retrieval pipeline here, for example one built on Azure AI Search.
Running the Prompt Flow evaluation
All that's left is to define the evaluations and run them.
-
Define the evaluators. For a list of available evaluators see here. You can also create your own evaluators.
-
Next, create the evaluation configuration and run it for each model.
To view the results, print them, or turn them into a pandas DataFrame for better readability.
Analyzing Prompt Flow results in Azure AI Studio
Because we passed the (optional) Azure AI Studio project configuration, we can view the results of the Prompt Flow evaluations, including charts, in Azure AI Studio.
In Azure AI Studio, select "Tools -> Evaluations" from the left-hand menu. All model evaluation runs that you logged to your project from the SDK show up here.
-
In the Evaluations menu, click "Switch to Dashboard" in the top-right corner. The dashboard gives a better overview for comparing runs.
-
Select one or more runs to compare. Each model we defined in the code above shows up as a separate run. Let's select both the GPT-4o and the GPT-35-TURBO runs. As the screenshot below shows, this gives a clear comparison of all the metrics we defined. In our example, GPT-4o seems to be the better model in almost every regard (which is not too surprising).
Evaluation dashboard comparing the GPT-4o and GPT-35-TURBO runs
Scroll down for detailed comparisons of the individual answers of each run.
Side-by-side answers of each evaluation run
-
Besides comparing runs, you can open each run for its detailed evaluation results. You get charts for each metric, plus the questions, answers and grades for every individual evaluation.
Detailed evaluation results of a single run
That's the whole setup. It takes quite a few steps, but you end up with a repeatable way to evaluate models before upgrading: add the new model to the model endpoints and evaluate it against your existing baseline model.
An evaluation run checks the model once, before the upgrade. To see how the new version behaves with real user traffic afterwards, trace your production calls with an observability tool such as Langfuse or Opik. If you would rather not set up this evaluation and upgrade process on your own, our AI consulting team in Vorarlberg builds and runs Azure-based RAG and agent applications for companies.
Using Prompt Flow without Azure AI Studio
You can also use Prompt Flow without Azure AI Studio. The process is the same as above, minus the code that refers to the Azure AI Studio project (and the content safety evaluator, which needs it). Here is the complete code for evaluating models without Azure AI Studio.
Further reading
- How to fine-tune GPT-4o mini (for free until September 2024)
- Chat with your confluence using LLMs
- Need a privacy-friendly ChatGPT alternative?
- Building enterprise AI agents with the Microsoft Agent Framework
Interested in building high-quality AI agent systems?
We prepared a comprehensive guide based on cutting-edge research for how to build robust, reliable AI agent systems that actually work in production. This guide covers:
- Understanding the 14 systematic failure modes in multi-agent systems
- Evidence-based best practices for agent design
- Structured communication protocols and verification mechanisms



