| title | Launch a Java Microservice Application with Managed Java Components | ||
|---|---|---|---|
| titleSuffix | Azure Container Apps | ||
| description | Learn how to deploy a Java microservice project in Azure Container Apps with managed Java components. | ||
| services | container-apps | ||
| author | KarlErickson | ||
| ms.author | karler | ||
| ms.reviewer | yiliu6 | ||
| ms.service | azure-container-apps | ||
| ms.topic | quickstart | ||
| ms.date | 03/26/2026 | ||
| ms.custom |
|
This article explains how to deploy an application in Azure Container Apps that uses Java components to handle configuration management, service discovery, and health and metrics. The sample application shown in this example is the Java PetClinic, which uses the microservice architecture pattern. The following diagram depicts the architecture of the PetClinic application on Azure Container Apps:
:::image type="complex" source="media/java-microservice-get-started/azure-container-apps-pet-clinic-architecture.png" alt-text="Diagram of the relationship between the Java components and the microservice applications." lightbox="media/java-microservice-get-started/azure-container-apps-pet-clinic-architecture.png"::: Diagram of an Azure Container Apps environment showing the architecture of four microservices-based applications deployed within an Azure resource group. A resource group contains the Azure Container Apps environment. The environment includes three Azure Container Apps managed Java components: a config server, a service registry, and an admin server. The config server fetches configuration data stored as versioned YAML files in a Git repository external to the Azure Container Apps environment. The service registry handles service discovery and registration. The admin server provides a live view of the system. An API gateway routes requests to three microservices: vets service, customers service, and visits service. Each service is linked to its own database for data persistence. The environment supports external interactions through a browser and a mobile app and integrates with monitoring tools via Azure Log Analytics Workspaces for tracking system performance and health. :::image-end:::
The PetClinic application includes the following features:
- The front end is a standalone Node.js web app hosted on the API gateway app.
- The API gateway routes requests to back-end service apps.
- Back-end apps are built with Spring Boot.
- Each back-end app uses a HyperSQL database as the persistent store.
- The apps use managed Java components on Azure Container Apps, including a service registry, config server, and admin server.
- The config server reads data from a Git repository.
- A Log Analytics workspace logs server data.
In this tutorial, you:
[!div class="checklist"]
- Create a config server, Eureka server, admin server, and admin components
- Create a series of microservice apps
- Bind the server components to your microservices apps
- Deploy the collection of apps
- Review the deployed apps
By the end of this article, you deploy one web application and three back-end applications that are configured to work with three different Java components. You can then manage each component via the Azure portal.
- An Azure account. If you don't have an Azure account, create one for free. For this quickstart, you need the Contributor or Owner role on the Azure subscription. For more information, see Assign Azure roles using the Azure portal.
- Install the Azure CLI.
- Azure Container Apps CLI extension, version 0.3.47 or higher. Use the
az extension add --name containerapp --upgrade --allow-previewcommand to install the latest version.
To create environment variables, a resource group, and an Azure Container Apps environment, use the following steps:
-
The environment variables contain your custom values, so replace the placeholder values surrounded by
<>with your own values before you run the following commands:export RESOURCE_GROUP=<your-resource-group> export LOCATION=<region> export CONTAINER_APP_ENVIRONMENT=<container-apps-environment>
-
Create more environment variables that contain the settings for your microservices app. These values are used to define the names and configurations of the Java components and the Azure Container Apps that you use to deploy the microservices. Create these environment variables by using the following commands:
export CONFIG_SERVER_COMPONENT=configserver export ADMIN_SERVER_COMPONENT=admin export EUREKA_SERVER_COMPONENT=eureka export CONFIG_SERVER_URI=https://github.com/spring-petclinic/spring-petclinic-microservices-config.git export CUSTOMERS_SERVICE=customers-service export VETS_SERVICE=vets-service export VISITS_SERVICE=visits-service export API_GATEWAY=api-gateway export CUSTOMERS_SERVICE_IMAGE=ghcr.io/azure-samples/javaaccelerator/spring-petclinic-customers-service export VETS_SERVICE_IMAGE=ghcr.io/azure-samples/javaaccelerator/spring-petclinic-vets-service export VISITS_SERVICE_IMAGE=ghcr.io/azure-samples/javaaccelerator/spring-petclinic-visits-service export API_GATEWAY_IMAGE=ghcr.io/azure-samples/javaaccelerator/spring-petclinic-api-gateway
-
Sign in to the Azure CLI and choose your active subscription by using the following command:
az login -
Create a resource group to organize your Azure services by using the following command:
az group create \ --name $RESOURCE_GROUP \ --location $LOCATION -
Create your Azure Container Apps environment, which hosts both the Java components and your container apps, using the following command:
az containerapp env create \ --resource-group $RESOURCE_GROUP \ --name $CONTAINER_APP_ENVIRONMENT \ --location $LOCATION
Now you create the following Java components that support your app:
- Config server: Manages configuration settings for your microservices apps.
- Eureka server: Manages service registry and discovery.
- Admin server: Monitors and manages the health and metrics of your microservices apps.
To create these server components, use the following steps:
-
Create the config server for your Java components by using the following command:
az containerapp env java-component config-server-for-spring create \ --resource-group $RESOURCE_GROUP \ --name $CONFIG_SERVER_COMPONENT \ --environment $CONTAINER_APP_ENVIRONMENT \ --configuration spring.cloud.config.server.git.uri=$CONFIG_SERVER_URI -
Create the Eureka server for your Java components by using the following command:
az containerapp env java-component eureka-server-for-spring create \ --resource-group $RESOURCE_GROUP \ --name $EUREKA_SERVER_COMPONENT --environment $CONTAINER_APP_ENVIRONMENT \ -
Create the admin server for your Java components by using the following command:
az containerapp env java-component admin-for-spring create \ --resource-group $RESOURCE_GROUP \ --name $ADMIN_SERVER_COMPONENT --environment $CONTAINER_APP_ENVIRONMENT \
To create the three Java components, use the following steps:
-
Open your Container Apps environment in the Azure portal.
-
Under Services in the sidebar menu, select Services.
-
To create the config server component, use these steps:
-
Select Configure and choose Java component to create a new Java component.
-
Use the following table to add the values in the portal window:
Setting Value Remarks Java component type Select Config Server for Spring. Java component name Enter configserver. This value matches what you defined for the $CONFIG_SERVER_COMPONENTvariable. -
In the Git repositories section, select Add.
-
For the URI field, enter https://github.com/spring-petclinic/spring-petclinic-microservices-config.git. (Don't include the final period.)
-
Select Add.
-
Select Next.
-
Select Configure to finish the configuration.
-
-
To create the Eureka server component, use these steps:
-
Select Configure, and choose Java component to create a new Java component.
-
Use the following table to add the values in the portal window:
Setting Value Remarks Java component type Select Eureka Server for Spring. Java component name Enter eureka. This value matches what you defined for the $EUREKA_SERVER_COMPONENTvariable. -
Select Next.
-
Select Configure to finish the configuration.
-
-
To create the admin server component, use the following steps:
-
Select Configure and choose Java component to create a new Java component.
-
Use the following table to add the values in the portal window:
Setting Value Remarks Java component type Select Admin for Spring. Java component name Enter admin. This value matches what you defined for the $ADMIN_SERVER_COMPONENTvariable. -
Select Next.
-
Select Configure to finish the configuration.
-
To deploy the Java microservice apps to Azure Container Apps using the prebuilt container images, use the following steps:
Note
In this article, you use a series of built images for the Spring Petclinic microservice apps. You also have the option to customize the sample code and use your own images. For more information, see the azure-container-apps-java-samples GitHub repository.
-
Create the customer data app by using the following command:
az containerapp create \ --resource-group $RESOURCE_GROUP \ --name $CUSTOMERS_SERVICE \ --environment $CONTAINER_APP_ENVIRONMENT \ --image $CUSTOMERS_SERVICE_IMAGE -
Create the vet app by using the following command:
az containerapp create \ --resource-group $RESOURCE_GROUP \ --name $VETS_SERVICE \ --environment $CONTAINER_APP_ENVIRONMENT \ --image $VETS_SERVICE_IMAGE -
Create the visits app by using the following command:
az containerapp create \ --resource-group $RESOURCE_GROUP \ --name $VISITS_SERVICE \ --environment $CONTAINER_APP_ENVIRONMENT \ --image $VISITS_SERVICE_IMAGE -
Create the API gateway app by using the following command:
az containerapp create \ --resource-group $RESOURCE_GROUP \ --name $API_GATEWAY \ --environment $CONTAINER_APP_ENVIRONMENT \ --image $API_GATEWAY_IMAGE \ --ingress external \ --target-port 8080 \ --query properties.configuration.ingress.fqdn
Next, bind the Java components to your container apps. The bindings that you create in this section provide the following functionality:
- Inject configuration data into each app from the managed config server on startup.
- Register the app with the managed Eureka server for service discovery.
- Enable the admin server to monitor the app.
Use the containerapp update command to create bindings for each app by using the following steps:
-
Add bindings to the customer data app by using the following command:
az containerapp update \ --resource-group $RESOURCE_GROUP \ --name $CUSTOMERS_SERVICE \ --bind $CONFIG_SERVER_COMPONENT $EUREKA_SERVER_COMPONENT $ADMIN_SERVER_COMPONENT -
Add bindings to the vet service by using the following command:
az containerapp update \ --resource-group $RESOURCE_GROUP \ --name $VETS_SERVICE \ --bind $CONFIG_SERVER_COMPONENT $EUREKA_SERVER_COMPONENT $ADMIN_SERVER_COMPONENT -
Add bindings to the visits service by using the following command:
az containerapp update \ --resource-group $RESOURCE_GROUP \ --name $VISITS_SERVICE \ --bind $CONFIG_SERVER_COMPONENT $EUREKA_SERVER_COMPONENT $ADMIN_SERVER_COMPONENT -
Add bindings to the API gateway. Use the following command to return the URL of the front-end application:
az containerapp update \ --resource-group $RESOURCE_GROUP \ --name $API_GATEWAY \ --bind $CONFIG_SERVER_COMPONENT $EUREKA_SERVER_COMPONENT $ADMIN_SERVER_COMPONENT \ --query properties.configuration.ingress.fqdn
Use the following steps to create bindings for each app:
-
Open your Container Apps environment in the Azure portal.
-
Under Services in the sidebar menu, select Service.
-
For each of the three components, select the component by name.
-
In the Bindings section, add the four apps created in this quickstart.
:::image type="content" source="media/java-microservice-get-started/azure-container-apps-bindings-section.png" alt-text="Screenshot of the Bindings section. Four apps are listed: customers-service, vets-service, visits-service, and API gateway.":::
-
To find the URL of the front-end application, search for and select Container Apps in the portal, then select api-gateway. In the Overview section, copy the application URL.
Use the following steps to verify the app status:
-
Using the URL that you found in the previous section, view the front-end application in your browser. The application should resemble the following screenshot:
:::image type="content" source="media/java-microservice-get-started/azure-container-apps-petclinic-home-page.png" alt-text="Screenshot of the home page of the pet clinic application." lightbox="media/java-microservice-get-started/azure-container-apps-petclinic-home-page.png":::
-
View the Eureka server dashboard by using the following steps:
[!IMPORTANT] To view the Eureka Server dashboard and Admin for Spring dashboard, you need to have at least the
Microsoft.App/managedEnvironments/writerole assigned to your account on the managed environment resource. You can explicitly assign theOwnerorContributorrole on the resource. You can also follow the steps to create a custom role definition and assign it to your account.-
Run the following command to return the dashboard URL:
az containerapp env java-component eureka-server-for-spring show \ --resource-group $RESOURCE_GROUP \ --name $EUREKA_SERVER_COMPONENT \ --environment $CONTAINER_APP_ENVIRONMENT \ --query properties.ingress.fqdn -
Open the URL in your browser. You should see an application that resembles the following screenshot:
:::image type="content" source="media/java-microservice-get-started/azure-container-apps-petclinic-eureka-server.png" alt-text="Screenshot of pet clinic application Eureka Server." lightbox="media/java-microservice-get-started/azure-container-apps-petclinic-eureka-server.png":::
-
-
View the Admin for Spring dashboard by using the following steps:
-
Use the following command to return the dashboard URL:
az containerapp env java-component admin-for-spring show \ --resource-group $RESOURCE_GROUP \ --name $ADMIN_SERVER_COMPONENT \ --environment $CONTAINER_APP_ENVIRONMENT \ --query properties.ingress.fqdn -
Open the URL in your browser. You should see an application that resembles the following screenshot:
:::image type="content" source="media/java-microservice-get-started/azure-container-apps-pet-clinic-administration.png" alt-text="Screenshot of the pet clinic admin dashboard showing five services up, along with version information for four of the services." lightbox="media/java-microservice-get-started/azure-container-apps-pet-clinic-administration.png":::
-
You can configure the Java components created in this quickstart through the Azure portal by using the Configurations section.
:::image type="content" source="media/java-microservice-get-started/azure-portal-java-configurations-sections.png" alt-text="Screenshot of the Configurations section, showing Property Name and Value textboxes, and the ability to delete a property." lightbox="media/java-microservice-get-started/azure-portal-java-configurations-sections.png":::
For more information on configuring the three Java components you created in this quickstart, see the following links:
The resources created in this quickstart have an effect on your Azure bill. If you aren't going to use these services long-term, use the following command to remove everything created in this quickstart:
az group delete --resource-group $RESOURCE_GROUP