Setting Up the Development Environment for Azure AI Foundry
July 2, 2026 · View on GitHub
This guide sets up Azure AI Foundry models for the Java AI apps in this course, using keyless authentication (Microsoft Entra ID) — no API keys to manage. New to the tooling? Start with the development environment guide.
This guide sets up Azure AI Foundry models for the Java AI apps in this course. You have two paths:
- Option A — Provision with
azd+ Bicep (recommended): one command deploys the Foundry account and models as code. No portal clicking. - Option B — Create resources manually in the Azure AI Foundry portal.
Both paths use keyless authentication (Microsoft Entra ID) — there are no API keys to copy or leak.
Table of Contents
- What Gets Created
- Prerequisites
- Option A: Provision with azd + Bicep (Recommended)
- Option B: Create Resources Manually
- Configure Your Environment
- Test Your Setup
- What's Next?
- Resources
- Additional Resources
What Gets Created
The Bicep templates in infra/ provision:
- An Azure AI Foundry account (
Microsoft.CognitiveServices/accounts, kindAIServices) with a project - A chat deployment —
gpt-4o-mini - An embedding deployment —
text-embedding-3-small(used in later chapters) - A keyless role assignment (
Cognitive Services OpenAI User) so you sign in withaz logininstead of managing keys
Prerequisites
Option A: Provision with azd + Bicep (Recommended)
From the 02-SetupDevEnvironment folder:
cd 02-SetupDevEnvironment
# Sign in (both tools)
azd auth login
az login
# Provision the Foundry account + model deployments
azd up
azd prompts for an environment name (for example genai-java) and a region. Choose a region where gpt-4o-mini and text-embedding-3-small are available — for example eastus2 or swedencentral.
When provisioning finishes, azd:
- Deploys everything defined in
infra/main.bicep. - Runs a postprovision hook that writes
examples/basic-chat-azure/.envwith your endpoint and deployment names (no secrets).
Tip: Re-run
azd upany time to apply changes. Runazd downto delete everything and stop incurring cost.
To see the generated settings:
azd env get-values
Now skip to Test Your Setup.
Option B: Create Resources Manually
Prefer the portal? Create the resources by hand:
- Go to the Azure AI Foundry portal and sign in.
- Create a project (this also creates an AI Foundry resource). Give it a name like
GenAIJava. - In your project, open Models + endpoints → Deploy model → Deploy base model.
- Deploy gpt-4o-mini (deployment name
gpt-4o-mini). Repeat for text-embedding-3-small if you want the embedding examples. - From Overview, copy the endpoint (for example
https://<resource>.openai.azure.com/). - Grant yourself keyless access: on the resource, open Access control (IAM) → Add role assignment → assign Cognitive Services OpenAI User to your account.
Still having trouble? See the Azure AI Foundry documentation.
Configure Your Environment
If you used Option A (azd up), your settings file is already written — there's nothing to configure. Skip to Test Your Setup.
If you used Option B (manual), create the example's .env file yourself:
cd 02-SetupDevEnvironment/examples/basic-chat-azure
cp .env.example .env
Edit .env with your endpoint (no key — auth is keyless):
AZURE_OPENAI_ENDPOINT=https://<your-resource>.openai.azure.com/
AZURE_OPENAI_DEPLOYMENT=gpt-4o-mini
Security note: There is no API key to store. You authenticate with Microsoft Entra ID via
az login(locally) or a managed identity (in Azure). The.envfile holds only non-secret settings and is already covered by.gitignore.
Test Your Setup
Make sure you're signed in so keyless auth can get a token, then run the example:
cd 02-SetupDevEnvironment/examples/basic-chat-azure
az login # if you aren't already signed in
mvn clean spring-boot:run
You should see a response from the gpt-4o-mini model!
VS Code users: Press
F5to run. The app loads your.envautomatically.
Full example: See the Basic Chat with Azure AI Foundry example for details and troubleshooting.
What's Next?
Setup complete! You now have:
- Azure AI Foundry with
gpt-4o-miniandtext-embedding-3-smalldeployed - Keyless authentication (Microsoft Entra ID) — no keys to manage
- A local
.envwith your endpoint and deployment names - A Java development environment ready to go
Continue to Chapter 3: Core Generative AI Techniques to start building AI applications!
Resources
- Azure Developer CLI (azd)
- Keyless authentication with Microsoft Entra ID
- Azure AI Foundry Documentation
- Spring AI Azure OpenAI Documentation
- Azure OpenAI Java SDK