Azure OpenAI Service: Getting Started
Back to Tutorials
Azure AIBeginner5 Steps

Azure OpenAI Service: Getting Started

Microsoft LearnSeptember 15, 202535 min watch35 min video

Learn how to provision Azure OpenAI Service, deploy GPT-4 and GPT-4o models, use the playground, and integrate the API into your applications with SDKs.

Azure OpenAI Service

Azure OpenAI Service provides REST API access to OpenAI's powerful models (GPT-4o, GPT-4, GPT-3.5 Turbo, DALL-E, Whisper) with the enterprise security, compliance, and regional availability of Azure.

Why Azure OpenAI vs OpenAI Direct?

Feature Azure OpenAI OpenAI API
Data privacy Your data stays in your Azure tenant Sent to OpenAI servers
Compliance SOC 2, HIPAA, ISO 27001, FedRAMP Limited certifications
Networking Private endpoints, VNet integration Public API only
Content safety Configurable content filters Fixed safety layer
SLA 99.9% uptime SLA Best-effort
Scale Provisioned throughput (PTU) Shared capacity

Prerequisites

Step 1: Create an Azure OpenAI Resource

# Using Azure CLI
az cognitiveservices account create \
  --name "my-openai-resource" \
  --resource-group "my-rg" \
  --kind "OpenAI" \
  --sku "S0" \
  --location "eastus2"

Or via the Azure Portal:

  1. Search for "Azure OpenAI" in the marketplace
  2. Click Create
  3. Choose subscription, resource group, region, and name
  4. Click Review + Create

Step 2: Deploy a Model

# Deploy GPT-4o
az cognitiveservices account deployment create \
  --name "my-openai-resource" \
  --resource-group "my-rg" \
  --deployment-name "gpt-4o" \
  --model-name "gpt-4o" \
  --model-version "2024-08-06" \
  --model-format "OpenAI" \
  --sku-capacity 30 \
  --sku-name "Standard"

Step 3: Use the Playground

  1. Go to Azure AI Foundry or the Azure OpenAI portal
  2. Select your deployment
  3. Open the Chat Playground
  4. Configure:
    • System message: Set the AI's persona and rules
    • Temperature: 0 (deterministic) to 1 (creative)
    • Max tokens: Limit response length
    • Top P: Nucleus sampling parameter

Example System Message

You are a helpful Azure solutions architect assistant.
You help users design cloud architectures using Azure services.
Always provide cost-effective, scalable, and secure recommendations.
Use markdown formatting and include relevant Azure service names.

Step 4: API Integration

Python SDK

from openai import AzureOpenAI

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

response = client.chat.completions.create(
    model="gpt-4o",  # deployment name
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Explain Azure Functions in 3 sentences."}
    ],
    temperature=0.7,
    max_tokens=500
)

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

C# / .NET SDK

using Azure.AI.OpenAI;
using Azure;

var client = new AzureOpenAIClient(
    new Uri("https://my-openai-resource.openai.azure.com/"),
    new AzureKeyCredential("your-api-key"));

var chatClient = client.GetChatClient("gpt-4o");

var response = await chatClient.CompleteChatAsync(new[]
{
    new SystemChatMessage("You are a helpful assistant."),
    new UserChatMessage("Explain Azure Functions in 3 sentences.")
});

Console.WriteLine(response.Value.Content[0].Text);

Step 5: Content Filtering

Azure OpenAI includes configurable content filters:

  1. Go to Content filters in the Azure OpenAI portal
  2. Create a custom filter configuration
  3. Set severity thresholds for: Hate, Sexual, Violence, Self-harm
  4. Configure Prompt Shield to block jailbreak attempts
  5. Assign the filter to your deployment

Resources

Video: Watch the Azure OpenAI Getting Started on Microsoft Azure YouTube channel.

Azure OpenAIGPT-4AI ServicesREST APIAzure

Share this tutorial

Chapters (5)

  1. 1

    Azure OpenAI Overview

    What Azure OpenAI offers and pricing tiers

  2. 2

    Provisioning & Model Deployment

    Create a resource and deploy GPT-4o

  3. 3

    Using the Playground

    Test prompts, system messages, and parameters

  4. 4

    API Integration with SDKs

    Call the API from Python and C# applications

  5. 5

    Content Filtering & Safety

    Configure responsible AI content filters

About the Author

KH

Microsoft Learn

Microsoft MVP | AI Engineer

Software & AI Engineer specializing in Microsoft Azure, .NET, and cutting-edge AI technologies.

Need help with your project?

Let's discuss how I can help bring your ideas to life.

Get In Touch