Skip to content

Azure-Samples/java-microservices-aca-lab

Repository files navigation

Deploying and running Java Applications with AI in Azure Container Apps

Open in GitHub Codespaces Open in Dev Containers

This project shows how to deploy the Spring Petclinic Microservices application with OpenAI to Azure Container Apps and integrate it with additional Azure services, also some samples for Azure Container Apps features.

FeaturesGettting StartedGuidance

main page

Important Security Notice

This template, the application code and configuration it contains, has been built to showcase Microsoft Azure specific services and tools. We strongly advise our customers not to make this code part of their production environments without implementing or enabling additional security features.

For a more comprehensive list of best practices and security recommendations for Intelligent Applications, visit Azure security best practices and patterns, Azure security baseline for Intelligent Recommendations

Features

The following technologies are part of the project:

This project provides the following features:

Screenshot of the chat app

Architecture Diagram

Architecture Diagram

Getting Started

You have a few options for getting started with this template.

All the steps of this lab have been tested in the GitHub CodeSpace. This is the preferred option for running this lab!

GitHub Codespaces

VS Code Dev Containers

Local Environment

Deploying

Once you've opened the project in Codespaces, in Dev Containers, or locally, you can deploy it to Azure.

Suggested: Both Contributor and User Access Administrator roles on the subscription.

  1. Login to Azure

    azd auth login

    az login

  2. Provision and deploy all the resources:

    azd up

    It will prompt you to provide an azd environment name (like "java-ai"), select a subscription from your Azure account, and select a location where OpenAI is available (like "eastus2"). Then it will provision the resources in your account and deploy the latest code. If you get an error or timeout with deployment, changing the location can help, as there may be availability constraints for the OpenAI resource.

  3. When azd has finished deploying, visit the api-gateway url and begin your experience on AI java apps.

    INFO: Deploy finish succeed!
    INFO: Api Gateway App url: https://api-gateway.<cluster>.<region>.azurecontainerapps.io
    INFO: Spring Boot Admin url: https://springbootadmin-azure-java.ext.<cluster>.<region>.azurecontainerapps.io
    
  4. When you've made any changes to the app code, you can just run:

    • azd deploy for all services

    • azd deploy -n <service> for single service

Guidance

Prerequisites

For running this lab you will need:

  • A GitHub account
  • An Azure Subscription

Region Availability

  1. This template uses Azure OpenAI Service deployment mododules gpt-4o and text-embedding-ada-002 which may not be available in all Azure regions. Check for up-to-date region availability and select a region during deployment accordingly

  2. The template uses Azure Database for MySQL - Flexible Server version 8.0 to store data. You may select a region suite for this service. Or create a database instance manually then Reuse existing service.

  • We recommend using East US, East US 2, North Central US, Sweden Central.

Costs

You can estimate the cost of this project's architecture with Azure's pricing calculator

Security

This template has Managed Identity built in to eliminate the need for developers to manage these credentials.

Applications can use managed identities to obtain Microsoft Entra tokens without having to manage any credentials. Additionally, we have added a GitHub Action tool that scans the infrastructure-as-code files and generates a report containing any detected issues. To ensure best practices in your repo we recommend anyone creating solutions based on our templates ensure that the Github secret scanning setting is enabled in your repos.

Resources