Skip to main content

Quickstart: Get Started with Azure AI

This quickstart guides you through creating your first Azure AI project and deploying an intelligent application. You’ll set up the necessary resources and run your first AI workload in under 15 minutes.

Prerequisites

Before you begin, ensure you have:
  • An Azure account with an active subscription (Create a free account)
  • Basic familiarity with the Azure portal or command line tools
  • A code editor (VS Code recommended)

Choose Your Path

Select the Azure AI service that best fits your needs:
Best for building AI agents, chatbots, and generative AI applications.

Option 1: Microsoft Foundry Quickstart

1

Create a Foundry Resource

Navigate to the Microsoft Foundry portal and sign in with your Azure account.Click Create workspace and provide:
  • Workspace name: A unique identifier for your project
  • Subscription: Your Azure subscription
  • Resource group: Create new or use existing
  • Region: Choose the region closest to you
Click Create to provision your Foundry resource.
2

Create Your First Agent

Once your workspace is ready:
  1. Select Agents from the left navigation
  2. Click + New agent
  3. Choose a model (e.g., GPT-4)
  4. Add custom instructions for your agent’s behavior
  5. Configure tools if needed (code interpreter, functions, etc.)
Click Create to deploy your agent.
3

Test Your Agent

In the agent playground:
  1. Type a message to your agent
  2. Observe the response and behavior
  3. Adjust instructions or parameters as needed
  4. Test different scenarios
Your agent is now ready to integrate into applications.

Deploy with Python SDK

Install the Microsoft Foundry SDK:
pip install azure-ai-projects
Create and interact with an agent:
from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential

# Initialize client
credential = DefaultAzureCredential()
client = AIProjectClient(
    credential=credential,
    subscription_id="your-subscription-id",
    resource_group_name="your-resource-group",
    project_name="your-project-name"
)

# Create an agent
agent = client.agents.create(
    model="gpt-4",
    name="assistant",
    instructions="You are a helpful AI assistant."
)

# Create a thread and send a message
thread = client.agents.create_thread()
message = client.agents.create_message(
    thread_id=thread.id,
    role="user",
    content="What are the key features of Azure AI?"
)

# Run the agent
run = client.agents.create_run(
    thread_id=thread.id,
    agent_id=agent.id
)

# Get the response
response = client.agents.get_message(
    thread_id=thread.id,
    message_id=run.message_id
)

print(response.content)
The Microsoft Foundry API provides a consistent contract for working across different model providers including Azure OpenAI, DeepSeek, xAI, and marketplace models.

Option 2: Azure Machine Learning Quickstart

1

Create a Workspace

Sign in to Azure Machine Learning studio.Click Create workspace and provide:
  • Workspace name: Unique name for your workspace
  • Subscription: Your Azure subscription
  • Resource group: Create or select existing
  • Region: Choose your preferred region
Click Review + Create, then Create.
2

Create a Compute Instance

A compute instance is your cloud development environment.
  1. Select your workspace
  2. Click NewCompute instance
  3. Provide a name and keep defaults
  4. Click Create
Wait a few minutes for provisioning to complete.
3

Run Your First Notebook

  1. Navigate to Notebooks in the left panel
  2. Click Samples to view sample notebooks
  3. Browse to SDK v2 folder
  4. Select a quickstart notebook (e.g., quickstart.ipynb)
  5. Click Clone to copy to your workspace
  6. Select your compute instance
  7. Run the cells to train your first model

Train a Model with Python

Install the Azure ML SDK:
pip install azure-ai-ml azure-identity
Submit a training job:
from azure.ai.ml import MLClient, command
from azure.identity import DefaultAzureCredential
from azure.ai.ml.entities import Environment

# Connect to workspace
ml_client = MLClient(
    DefaultAzureCredential(),
    subscription_id="your-subscription-id",
    resource_group_name="your-resource-group",
    workspace_name="your-workspace"
)

# Define training job
job = command(
    code="./src",
    command="python train.py --data ${{inputs.data}}",
    inputs={"data": "azureml:training-data:1"},
    environment="azureml:sklearn-env:1",
    compute="cpu-cluster",
    display_name="quickstart-train"
)

# Submit job
returned_job = ml_client.jobs.create_or_update(job)
print(f"Job submitted: {returned_job.studio_url}")

Option 3: Azure AI Search Quickstart

1

Create a Search Service

  1. Open the Azure portal
  2. Click Create a resource → Search for “Azure AI Search”
  3. Click Create and fill in:
    • Service name: Unique name for your search service
    • Subscription: Your Azure subscription
    • Resource group: Create or select existing
    • Location: Choose your region
    • Pricing tier: Start with Free or Basic
  4. Click Review + Create, then Create
2

Create Your First Index

In the Azure portal, navigate to your search service:
  1. Click Import data to use the wizard
  2. Connect to a data source (Azure Blob Storage, SQL, etc.)
  3. Optionally add AI enrichment for text extraction and analysis
  4. Define index fields and attributes
  5. Create an indexer to populate the index
Or create an index programmatically using the SDK.
3

Query Your Index

Use the Search Explorer in the portal:
  1. Select your index
  2. Enter a search query
  3. View results and refine your query
  4. Test different query types (full-text, vector, hybrid)

Query with Python SDK

Install the Azure Search SDK:
pip install azure-search-documents azure-identity
Perform a search query:
from azure.search.documents import SearchClient
from azure.core.credentials import AzureKeyCredential

# Initialize client
search_client = SearchClient(
    endpoint="https://your-service.search.windows.net",
    index_name="your-index",
    credential=AzureKeyCredential("your-api-key")
)

# Perform a search
results = search_client.search(
    search_text="machine learning",
    select=["title", "content", "category"],
    top=10
)

# Display results
for result in results:
    print(f"Title: {result['title']}")
    print(f"Content: {result['content'][:200]}...")
    print(f"Score: {result['@search.score']}")
    print("---")

Next Steps

Now that you’ve completed the quickstart, explore these resources:

Build an AI Agent

Create a multi-tool agent with memory and knowledge integration

Train a Custom Model

Learn MLOps best practices for production deployments

Implement RAG

Build a retrieval-augmented generation app with AI Search

Explore Samples

Browse code samples for common scenarios

Troubleshooting

If you encounter authentication errors:
  • Ensure you’re logged in to the correct Azure account
  • Verify your subscription has the necessary permissions
  • Check that your service principal has the required roles
  • Try using az login to refresh credentials
Common reasons for failures:
  • Insufficient quota in the selected region
  • Resource name already in use (names must be globally unique)
  • Missing permissions on the subscription or resource group
  • Region doesn’t support the selected tier or features
If pip installation fails:
  • Upgrade pip: pip install --upgrade pip
  • Use a virtual environment: python -m venv venv
  • Check Python version (3.8+ recommended)
  • Try installing with --user flag
Free Trial: New Azure accounts receive free credits. Use the Free tier for Foundry exploration and AI Search, and leverage free compute hours in Azure Machine Learning.

Additional Resources

Build docs developers (and LLMs) love