Setting Up the Development Environment for Generative AI for Java
July 2, 2026 · View on GitHub
Quick Start: Provision your AI models on Azure AI Foundry as code with Bicep +
azdfor small time — see the Azure AI Foundry Setup Guide. Authentication no get key (Microsoft Entra ID), so no API keys wey you go manage.
Wetin You Go Learn
- Set up Java development environment for AI applications
- Choose and configure your preferred development environment (cloud-first with Codespaces, local dev container, or full local setup)
- Test your setup by connecting to Azure AI Foundry model
Table of Contents
- Wetn You Go Learn
- Introduction
- Step 1: Set Up Your Development Environment
- Step 2: Provision Azure AI Foundry
- Step 3: Test Your Setup
- Troubleshooting
- Summary
- Next Steps
Introduction
This chapter go guide you how to set up development environment. We go use Azure AI Foundry for all di models for dis course. You go provision di models as code with Bicep and Azure Developer CLI (azd), then connect with keyless authentication (Microsoft Entra ID) — no API keys wey you go copy or leak.
No local setup necessary! You fit use GitHub Codespaces, wey go give you full development environment inside your browser, and provision Foundry from there.
We dey use Azure AI Foundry for dis course because e:
- Provisioned as code — one
azd upgo deploy di account and model deployments - Keyless — authenticate with your Azure sign-in or managed identity
- Production-ready — di same code fit run locally and for Azure
- Flexible — you fit swap models by changing deployment name, no be your code
Note: Azure AI Foundry deployments dey charge by token (pay-as-you-go). See di Azure AI Foundry setup guide for provisioning, region, and cost details.
Step 1: Set Up Your Development Environment
We don create preconfigured development container to reduce setup time and make sure say you get all di tools you need for dis Generative AI for Java course. Choose your preferred development approach:
Environment Setup Options:
Option A: GitHub Codespaces (Recommended)
Start to code for 2 minutes - no local setup necessary!
- Fork this repository to your GitHub account
Note: If you want change basic config, abeg check the Dev Container Configuration
- Click Code → Codespaces tab → ... → New with options...
- Use the defaults – this one go select Dev container configuration: Generative AI Java Development Environment custom devcontainer created for this course
- Click Create codespace
- Wait ~2 minutes make environment ready
- Go to Step 2: Provision Azure AI Foundry
Benefits of Codespaces:
- No local installation necessary
- E go work on any device wey get browser
- Pre-configured with all tools and dependencies
- Free 60 hours every month for personal accounts
- Consistent environment for all learners
Option B: Local Dev Container
For developers wey like local development with Docker
- Fork and clone this repository to your local machine
Note: If you want change basic config, abeg check the Dev Container Configuration
- Install Docker Desktop and VS Code
- Install the Dev Containers extension for VS Code
- Open the repository folder inside VS Code
- When e ask, click Reopen in Container (or use
Ctrl+Shift+P→ "Dev Containers: Reopen in Container") - Wait make container build and start
- Go to Step 2: Provision Azure AI Foundry
Option C: Use Your Existing Local Installation
For developers wey don get Java environments properly
Prerequisites:
- Java 21+
- Maven 3.9+
- VS Code or your preferred IDE
Steps:
- Clone this repository to your local machine
- Open the project inside your IDE
- Go to Step 2: Provision Azure AI Foundry
Pro Tip: If your machine low-spec but you want VS Code locally, use GitHub Codespaces! You fit connect your local VS Code to cloud-hosted Codespace make you get best of both worlds.
Step 2: Provision Azure AI Foundry
Deploy di course AI models to Azure AI Foundry as code. From di repository root:
cd 02-SetupDevEnvironment
azd auth login
az login
azd up
azd go ask you environment name and region, go provision Azure AI Foundry account with gpt-4o-mini and text-embedding-3-small deployments, write the endpoint inside di example .env — all this na with keyless authentication (no API keys).
Full walkthrough: See the Azure AI Foundry Setup Guide for prerequisites, manual (portal) alternative, region guidance, and cost/cleanup notes.
Step 3: Test Your Setup
Once your Foundry models don provision, test di connection with the example app inside 02-SetupDevEnvironment/examples/basic-chat-azure.
- Open terminal inside your development environment.
- Go inside the example:
cd 02-SetupDevEnvironment/examples/basic-chat-azure - Make sure say you don sign in (keyless auth need token):
az loginIf you run
azd up,.envfile wey get your endpoint don already write for you. - Run the application:
mvn clean spring-boot:run
You suppose see response from gpt-4o-mini model.
How the Example Code Work
The example under examples/basic-chat-azure na Spring Boot app wey dey use Spring AI to connect Azure AI Foundry with keyless authentication.
Wetin dis code dey do:
- Connect to Azure AI Foundry using your Azure sign-in (Microsoft Entra ID) — no API key
- Send prompt to
gpt-4o-minimodel - Receive and show AI response
- Check say your setup dey work well
Key Dependency (for pom.xml):
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-model-azure-openai</artifactId>
</dependency>
Configuration (application.yml):
spring:
ai:
azure:
openai:
# Endpoint only - no api-key. Spring AI uses DefaultAzureCredential (keyless).
endpoint: ${AZURE_OPENAI_ENDPOINT}
chat:
options:
deployment-name: ${AZURE_OPENAI_DEPLOYMENT:gpt-4o-mini}
Summary
Correct! You don set up everything:
- Provisioned Azure AI Foundry models as code with Bicep +
azd - Your Java development environment dey run (whether Codespaces, dev containers, or local)
- Connected to Azure AI Foundry with keyless authentication (Microsoft Entra ID) — no API keys
- Test all works with simple example wey dey talk to your model
Next Steps
Chapter 3: Core Generative AI Techniques
Troubleshooting
Get wahala? Here na common problems and how to fix dem:
-
Authentication dey fail (401/403)?
- Run
az login— authentication no need key, you must sign in - Check say your account get Cognitive Services OpenAI User role on the resource
- If you just provision, wait small make role assignment go full propagate
- Run
-
Maven no dey?
- If you dey use dev containers/Codespaces, Maven dey pre-installed
- For local setup, make sure Java 21+ and Maven 3.9+ dey installed
- Run
mvn --versionto check
-
azdno dey or provisioning no dey work?- Install Azure Developer CLI and run
azd auth login - Choose region wey
gpt-4o-minidey available (e.g.eastus2) - See Azure AI Foundry setup guide for details
- Install Azure Developer CLI and run
-
Dev container no dey start?
- Make sure Docker Desktop dey run (for local development)
- Try rebuild di container:
Ctrl+Shift+P→ "Dev Containers: Rebuild Container"
-
Application get compile errors?
- Make sure you dey inside correct directory:
02-SetupDevEnvironment/examples/basic-chat-azure - Try clean and rebuild:
mvn clean compile
- Make sure you dey inside correct directory:
Need help?: Still get wahala? Open issue inside repository, we go help you.
Disclaimer: Dis document don translate wit AI translation service Co-op Translator. Even tho we dey try make am correct, abeg make you know say automated translation fit get errors or mistakes. Di original document for dia own language na im be di correct source. For important info, make person wey sabi human translation do am. We no go responsible for any misunderstanding or wrong understanding wey fit happen because of dis translation.