Skip to content

Integration of latest docs change requests and Readme.md cleanup #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 5 additions & 127 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,138 +1,16 @@
# Deploying and running Java Applications with AI in Azure Container Apps
# Java and AI

[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/Azure-Samples/java-on-aca)
[![Open in Dev Containers](https://img.shields.io/static/v1?style=for-the-badge&label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/azure-samples/java-on-aca)

This project shows how to deploy the [Spring Petclinic Microservices](https://github.com/Azure-Samples/java-on-aca/tree/main/src) application with OpenAI to [Azure Container Apps](https://learn.microsoft.com/azure/container-apps/overview) and integrate it with additional Azure services, also some samples for Azure Container Apps features.
This repository supports the [Java and AI](https://azure-samples.github.io/java-on-aca/) lab series. In these labs, you'll walk through deploying the sample [Spring Petclinic](https://github.com/Azure-Samples/java-on-aca/tree/main/src) application to an [Azure Container Apps](https://learn.microsoft.com/azure/container-apps/overview) environment while also integrating additional Azure services, such as [Azure OpenAI](https://learn.microsoft.com/en-us/azure/ai-services/openai/overview).

[Features](#features) • [Gettting Started](#getting-started) • [Guidance](#guidance)
Please visit the [**Java and AI lab series documentation**](https://azure-samples.github.io/java-on-aca/) for information on lab requirements, how to prepare your development environment, and instruction on running these labs.

![main page](./images/api-gateway-main.png)

## 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.
The application code and configuration files contained in this repo are for educational purposes, and were built specifically to showcase specific Microsoft Azure services and tools. You should not use this code in your production environments without thoroughly reviewing it and 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](https://learn.microsoft.com/en-us/azure/security/fundamentals/best-practices-and-patterns), [Azure security baseline for Intelligent Recommendations](https://learn.microsoft.com/en-us/security/benchmark/azure/baselines/intelligent-recommendations-security-baseline)

## Features

The following technologies are part of the project:

* Java 17
* Maven
* [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/)
* [Azure Developer CLI (azd)](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/)

This project provides the following features:

* A [Spring Petclinic Microservices](https://github.com/Azure-Samples/java-on-aca/tree/main/src) deployment on Azure Container Apps with AI chat agent.
* Azure Container Apps java components ([eureka server](https://learn.microsoft.com/en-us/azure/container-apps/java-eureka-server-usage) /[config server](https://learn.microsoft.com/en-us/azure/container-apps/java-config-server-usage) / [spring boot admin](https://learn.microsoft.com/en-us/azure/container-apps/java-admin-for-spring-usage)) support.
* [Bicep files](https://docs.microsoft.com/azure/azure-resource-manager/bicep/) for provisioning Azure resources, including Azure OpenAI, Azure Container Apps, Azure Database for MySQL - Flexible Server, Azure Container Registry, Azure Log Analytics, Azure Application Insights and RBAC roles. See [Deploy to Azure automatically](https://azure-samples.github.io/java-on-aca/docs/06_lab_automation/06_openlab_automation.html).
* Best practices to build [more secure](https://azure-samples.github.io/java-on-aca/docs/07_lab_security/07_openlab_security_aca.html), [more reliable](https://azure-samples.github.io/java-on-aca/docs/10_lab_reliable_application/10_reliable_java_aca.html) and [more flexible](https://azure-samples.github.io/java-on-aca/docs/11_lab_scale/11_openlab_scale_aca.html) java apps on Azure Container Apps.
* AI chat agent to take advantage of large-scale, generative AI models with deep understandings of language and code to enable new reasoning and comprehension capabilities. See [Integrate with Azure OpenAI](https://azure-samples.github.io/java-on-aca/docs/05_lab_openai/05_openlab_openai_aca.html)

![Screenshot of the chat app](./images/acalab-ai-chat.png)

### Architecture Diagram

![Architecture Diagram](./images/acalab6.png)

## Getting Started

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

* [GitHub codespace](#github-codespaces)
* [Visual Studio Code with remote containers option](#vs-code-dev-containers)
* [Local Development](#local-environment)

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

### GitHub Codespaces

* Prepare the environment following the steps in [Using a GitHub codespace](https://azure-samples.github.io/java-on-aca/install.html#using-a-github-codespace)
* Continue with [deploying steps](#deploying)

### VS Code Dev Containers

* Prepare the environment following the steps in [Using Visual Studio Code with remote containers](https://azure-samples.github.io/java-on-aca/install.html#using-a-github-codespace)
* Continue with [deploying steps](#deploying)

### Local Environment

* Prepare the environment following the steps in [Install all the tools on your local machine](https://azure-samples.github.io/java-on-aca/install.html#install-all-the-tools-on-your-local-machine)
* Continue with [deploying steps](#deploying)

### Deploying

Once you've opened the project in [Codespaces](#github-codespaces), in [Dev Containers](#vs-code-dev-containers), or [locally](#local-environment), you can deploy it to Azure.

* Your Azure account must have `Microsoft.Authorization/roleAssignments/write` permissions, such as [Role Based Access Control Administrator](https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#role-based-access-control-administrator-preview), [User Access Administrator](https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#user-access-administrator), or [Owner](https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#owner). If you don't have subscription-level permissions, you must be granted [RBAC](https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#role-based-access-control-administrator-preview) for an existing resource group and [deploy to that existing group](./docs/06_lab_automation/0604.md).
* Your Azure account also needs `Microsoft.Resources/deployments/write` permissions on the subscription level.

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

1. Login to Azure

`azd auth login`

`az login`

1. 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](#region-availability) (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.

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

```text
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
```

1. 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](https://learn.microsoft.com/en-us/azure/ai-services/openai/overview) 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](https://learn.microsoft.com/azure/ai-services/openai/concepts/models#standard-deployment-model-availability) and select a region during deployment accordingly

1. The template uses [Azure Database for MySQL - Flexible Server](https://learn.microsoft.com/en-us/azure/mysql/flexible-server/overview) 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](https://azure-samples.github.io/java-on-aca/docs/06_lab_automation/0604.html).

* 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](https://azure.microsoft.com/pricing/calculator/)

* Azure Container Apps - [Consumption](https://azure.microsoft.com/en-us/pricing/details/container-apps/)
* Azure Database for MySQL - [Flexible Server](https://azure.microsoft.com/en-us/pricing/details/mysql/)
* Azure OpenAI Service - [Standard](https://azure.microsoft.com/en-us/pricing/details/cognitive-services/openai-service/)
* Azure Monitor - [Analytics Logs](https://azure.microsoft.com/en-us/pricing/details/monitor/)

### Security

This template has [Managed Identity](https://learn.microsoft.com/entra/identity/managed-identities-azure-resources/overview) 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](https://github.com/microsoft/security-devops-action) 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](https://docs.github.com/code-security/secret-scanning/about-secret-scanning) setting is enabled in your repos.

## Resources

* Go to the lab for more details [Deploying and running Java Applications with AI in Azure Container Apps](https://azure-samples.github.io/java-on-aca/)
* Full installation guidance and options for running this lab can be found in the [Installation instructions](install.md).
For a more comprehensive list of best practices and security recommendations for building intelligent applications on Azure, review the [Azure security best practices and patterns](https://learn.microsoft.com/en-us/azure/security/fundamentals/best-practices-and-patterns) and [Azure security baseline for Intelligent Recommendations](https://learn.microsoft.com/en-us/security/benchmark/azure/baselines/intelligent-recommendations-security-baseline) guides.
6 changes: 3 additions & 3 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
title: Java on ACA
description: This lab walks you through the creation of a Java application on Azure Container Apps integrated with multiple Azure services
title: Java and AI
description: This lab walks you through the creation of an intelligent Java application on Azure Container Apps integrated with multiple Azure services.
theme: just-the-docs

# url: https://Azure-Samples.github.io/java-on-aca

aux_links:
"Java on ACA lab on GitHub":
"Java and AI lab on GitHub":
- "https://github.com/Azure-Samples/java-on-aca"


Expand Down
4 changes: 2 additions & 2 deletions docs/01_lab_plan/0101.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ parent: 'Lab 1: Plan your application deployment'

# Examine the application components based on the GitHub repository information

Your first step is to familiarize yourself with the existing [Spring Petclinic Microservices](https://github.com/spring-petclinic/spring-petclinic-microservices) workload, its components, and the GitHub repository where its source code is located.
Your first step is to familiarize yourself with the existing [Spring Petclinic](https://github.com/spring-petclinic/spring-petclinic-microservices) workload, its components, and the GitHub repository where its source code is located.

## Step-by-step guidance

To start, you’ll learn about the Spring Petclinic Microservices workload.
To start, you’ll learn about the Spring Petclinic workload.

1. On your lab computer, open a web browser, go to [GitHub](https://github.com), and sign in to your GitHub account. If you don’t have a GitHub account, create one (go to [Join GitHub](https://github.com/join), and follow the instructions at [Signing up for a new GitHub account](https://docs.github.com/en/get-started/signing-up-for-github/signing-up-for-a-new-github-account)).
1. Go to the [source folder of this lab’s GitHub repo](https://github.com/Azure-Samples/java-on-aca/tree/main/src), and review the **README.md file**.
Expand Down
4 changes: 2 additions & 2 deletions docs/01_lab_plan/0102.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ parent: 'Lab 1: Plan your application deployment'

# Understand the Azure resources that you’ll use

Now that you’ve familiarized yourself with the example Spring Petclinic Microservices workload that you’ll be deploying, you can explore the Azure services that you’ll use to host it.
Now that you’ve familiarized yourself with the example Spring Petclinic workload that you’ll be deploying, you can explore the Azure services that you’ll use to host it.

## Azure Container Apps

For this deployment, we’re going to use [Azure Container Apps](https://learn.microsoft.com/azure/container-apps/overview) to run the [Spring Petclinic Microservices](https://github.com/spring-petclinic/spring-petclinic-microservices) application. Azure Container Apps is a good choice in this scenario because:
For this deployment, we’re going to use [Azure Container Apps](https://learn.microsoft.com/azure/container-apps/overview) to run the [Spring Petclinic](https://github.com/spring-petclinic/spring-petclinic-microservices) application. Azure Container Apps is a good choice in this scenario because:

- It’s a serverless hosting platform that allows you to maintain less infrastructure and save costs while running containerized applications. This means that instead of worrying about server configuration, container orchestration, and deployment details, Container Apps provides all the up-to-date server resources required to keep your applications stable and secure.
- It supports native Spring Boot applications and Spring Boot–managed components that we’ll use in our app, like [Eureka Server](https://learn.microsoft.com/azure/container-apps/java-eureka-server?tabs=azure-cli), [Config Server](https://learn.microsoft.com/azure/container-apps/java-config-server?tabs=azure-cli), and [Spring Boot Admin](https://learn.microsoft.com/azure/container-apps/java-admin?tabs=azure-cli).
Expand Down
4 changes: 2 additions & 2 deletions docs/01_lab_plan/01_openlab_plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ has_children: true

## Introduction

Before you can deploy the example Spring Petclinic Microservices workload to Azure, you need to determine what application components need to run on Azure, which Azure resources you’ll use to host these components, and what tools you’ll need to perform the deployment.
Before you can deploy the example Spring Petclinic workload to Azure, you need to determine what application components need to run on Azure, which Azure resources you’ll use to host these components, and what tools you’ll need to perform the deployment.

In this first lab session, you’ll explore the sample application code and configure your development environment. You’ll also evaluate the application’s technical and operational requirements to determine the best hosting, storage, and organizational approach for moving the Spring Petclinic Microservices workload to Azure.
In this first lab session, you’ll explore the sample application code and configure your development environment. You’ll also evaluate the application’s technical and operational requirements to determine the best hosting, storage, and organizational approach for moving the Spring Petclinic workload to Azure.

## What you’ll cover

Expand Down
2 changes: 1 addition & 1 deletion docs/02_lab_launch/0204.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ parent: 'Lab 2: Deploy applications to Azure Container Apps'

You’ve set up the compute and database services that will host your applications and store your application data. The next step is to set up the application configuration settings that allow your Spring Boot application to connect with the database you just created.

The example Spring Petclinic Microservices workload includes a config server that the workload’s various component applications will all use for this purpose. In Azure Container Apps, we can also make use of the built-in config server component, which you will use in one of the following modules.
The example Spring Petclinic workload includes a config server that the workload’s various component applications will all use for this purpose. In Azure Container Apps, we can also make use of the built-in config server component, which you will use in one of the following modules.

## Step-by-step guidance

Expand Down
2 changes: 1 addition & 1 deletion docs/02_lab_launch/0209.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ parent: 'Lab 2: Deploy applications to Azure Container Apps'

# Review

In this lab, you deployed the Spring Petclinic Microservices workload to Azure.
In this lab, you deployed the Spring Petclinic workload to Azure.

The following image should reflect your application architecture after a successful deployment.

Expand Down
2 changes: 1 addition & 1 deletion docs/02_lab_launch/02_openlab_setup_aca.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ has_children: true

## Introduction

In the previous lab, you reviewed the sample Spring Petclinic Microservices workload that you’ll deploy, examined the Azure services that the component Spring applications will rely on, and made sure that the necessary tooling is configured and ready in your development environment. Now it’s time to deploy the workload to an Azure Container Apps instance.
In the previous lab, you reviewed the sample Spring Petclinic workload that you’ll deploy, examined the Azure services that the component Spring applications will rely on, and made sure that the necessary tooling is configured and ready in your development environment. Now it’s time to deploy the workload to an Azure Container Apps instance.

## What you’ll cover

Expand Down
2 changes: 1 addition & 1 deletion docs/03_lab_monitor/0306.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ parent: 'Lab 3: Enable monitoring'

# Review

In this lab, you added monitoring to the example Spring Petclinic Microservices workload that you deployed in the previous lab.
In this lab, you added monitoring to the example Spring Petclinic workload that you deployed in the previous lab.

As part of this process, you:

Expand Down
2 changes: 1 addition & 1 deletion docs/04_lab_secrets/0404.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ parent: 'Lab 4: Connect to a database with managed identity'

# Review

In this lab, you secured your database connection secrets for your Spring Petclinic Microservices workload, without needing to make application code changes, by using Azure Service Connector and managed identities.
In this lab, you secured your database connection secrets for your Spring Petclinic workload, without needing to make application code changes, by using Azure Service Connector and managed identities.

As part of this process, you:

Expand Down
2 changes: 1 addition & 1 deletion docs/04_lab_secrets/04_openlab_secrets_aca.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ has_children: true

## Introduction

You now have your copy of the Spring Petclinic Microservices workload running in Azure. However, your applications use secrets, such as your database connection string, which depend on passwords that are stored in your configuration repository.
You now have your copy of the Spring Petclinic workload running in Azure. However, your applications use secrets, such as your database connection string, which depend on passwords that are stored in your configuration repository.

Passwords are insecure. They can be stolen, guessed, or found via brute force attacks, so protecting your passwords can be a major challenge. You want to find a way to connect to your database without having to deal with this potential vulnerability.

Expand Down
Loading