Azure-AI_Foundry

Module 4: Prompt Engineering & Playground — Overview

Introduction

The Azure AI Foundry Playground is your interactive workbench for crafting, testing, and refining prompts before writing a single line of application code. Combined with Prompt Flow for productionizing prompt logic, this module covers everything from basic prompt techniques to advanced orchestration.

Official Documentation: Prompt Engineering Techniques


What Is Prompt Engineering?

Prompt engineering is the practice of designing inputs to language models to reliably produce desired outputs. It encompasses:


Azure AI Foundry Playground Features

Playground Purpose Key Features
Chat Multi-turn conversations with GPT models System prompt, message history, parameter tuning
Completions Single-turn text generation Prompt + completion, legacy models
Images Image generation with DALL-E Style, quality, and size controls
Audio Speech-to-text (Whisper) and text-to-speech (TTS) Upload audio, select voices

What You Can Do in the Playground


Why Prompt Engineering Matters

Poor prompt:    "Summarize this."
Better prompt:  "Summarize the following customer support ticket in 2-3 bullet points,
                 focusing on the customer's issue and the resolution. Use past tense."

Poor prompt:    "Write code."
Better prompt:  "Write a Python function that takes a list of integers and returns
                 the top 3 most frequent values. Include type hints and a docstring."

A well-engineered prompt can be the difference between a usable product and a frustrating one — often with no code changes or model upgrades required.


Quick Example: Chat Playground to Code

# This code was exported from the Azure AI Foundry Chat Playground
from openai import AzureOpenAI

client = AzureOpenAI(
    azure_endpoint="https://your-resource.openai.azure.com/",
    api_key="your-api-key",
    api_version="2024-12-01-preview"
)

response = client.chat.completions.create(
    model="gpt-4o-prod",
    messages=[
        {
            "role": "system",
            "content": (
                "You are a helpful customer support agent for Contoso Electronics. "
                "Answer questions about products, orders, and returns. "
                "Be concise, friendly, and professional. "
                "If you don't know the answer, say so — do not make up information."
            )
        },
        {
            "role": "user",
            "content": "What is your return policy for laptops?"
        }
    ],
    temperature=0.3,
    max_tokens=300,
    top_p=0.95
)

print(response.choices[0].message.content)

Module Learning Objectives

By the end of this module, you will be able to:

  1. Use the Playground effectively to test prompts, tune parameters, and export code
  2. Apply prompt engineering techniques — zero-shot, few-shot, chain-of-thought, and structured outputs
  3. Tune model parameters — temperature, top_p, max_tokens, frequency/presence penalties
  4. Build with Prompt Flow — create, test, and deploy multi-step prompt orchestrations

Module Lessons

Lesson Topic
Lesson 1 Playground deep dive — Chat, Images, Audio, exporting code
Lesson 2 Prompt techniques — zero-shot, few-shot, CoT, JSON mode, function calling
Lesson 3 Prompt Flow — building, testing, and deploying prompt orchestrations
Knowledge Check 15 scenario-based review questions

Tips

💡 Tip: Always start in the Playground before writing code. It is faster to iterate on prompts interactively than through code-deploy-test cycles.

💡 Tip: The “View Code” button in the Playground generates ready-to-use code in Python, C#, JavaScript, and curl. Use it as your starting point.

💡 Tip: Save your system prompts as versioned files in source control — treat them like code, because changes to prompts change application behavior just like code changes do.