| title | Tutorial: Create a Highly Available Eureka Server Component Cluster in Azure Container Apps |
|---|---|
| description | Find out how to create a highly available Eureka service in Azure Container Apps. Go through steps for linking Eureka server instances to form a cluster. |
| services | container-apps |
| author | craigshoemaker |
| ms.service | azure-container-apps |
| ms.custom | devx-track-extended-java |
| ms.topic | tutorial |
| ms.date | 11/13/2025 |
| ms.author | cshoe |
In this tutorial, you find out how to create a Eureka service that's designed to remain operational in the face of failures and high demand. Building a highly available Eureka service helps ensure the service registry that you use for Azure Container Apps is always available to clients regardless of demand.
Achieving high availability status for Eureka includes linking multiple Eureka server instances together so they form a cluster. The cluster provides resources so that if one Eureka server fails, the other services remain available for requests.
In this tutorial, you:
[!div class="checklist"]
- Create Eureka servers for Spring components.
- Bind two Eureka servers for Spring components together into a cluster.
- Bind a container app to both Eureka servers for highly available service discovery.
- An Azure account with an active subscription. If you don't already have one, you can create one for free.
- The Azure CLI.
When you run managed Java components in Container Apps, be aware of the following details:
[!INCLUDE container-apps/component-considerations.md]
Use the following steps to create some resources that you need for your Eureka service cluster.
-
Create variables that hold application configuration values.
export LOCATION=eastus export RESOURCE_GROUP=my-services-resource-group export ENVIRONMENT=my-environment export EUREKA_COMPONENT_FIRST=eureka01 export EUREKA_COMPONENT_SECOND=eureka02 export APP_NAME=sample-service-eureka-client export IMAGE="mcr.microsoft.com/javacomponents/samples/sample-service-eureka-client:latest"
-
Use the Azure CLI to sign in to Azure.
az login -
Create a resource group.
az group create --name $RESOURCE_GROUP --location $LOCATION -
Create your Container Apps environment.
az containerapp env create \ --name $ENVIRONMENT \ --resource-group $RESOURCE_GROUP \ --location $LOCATION
Create two Eureka Server for Spring components.
az containerapp env java-component eureka-server-for-spring create \
--environment $ENVIRONMENT \
--resource-group $RESOURCE_GROUP \
--name $EUREKA_COMPONENT_FIRST
az containerapp env java-component eureka-server-for-spring create \
--environment $ENVIRONMENT \
--resource-group $RESOURCE_GROUP \
--name $EUREKA_COMPONENT_SECOND
For the Eureka servers to work in a high-availability configuration, they need to be linked together as a cluster.
-
Bind the first Eureka server to the second.
az containerapp env java-component eureka-server-for-spring update \ --environment $ENVIRONMENT \ --resource-group $RESOURCE_GROUP \ --name $EUREKA_COMPONENT_FIRST \ --bind $EUREKA_COMPONENT_SECOND -
Bind the second Eureka server to the first.
az containerapp env java-component eureka-server-for-spring update \ --environment $ENVIRONMENT \ --resource-group $RESOURCE_GROUP \ --name $EUREKA_COMPONENT_SECOND \ --bind $EUREKA_COMPONENT_FIRST
With the server components linked together, you can create the container app and bind it to the two Eureka components.
-
Create the container app.
az containerapp create \ --name $APP_NAME \ --resource-group $RESOURCE_GROUP \ --environment $ENVIRONMENT \ --image $IMAGE \ --min-replicas 1 \ --max-replicas 1 \ --ingress external \ --target-port 8080 -
Bind the container app to the first Eureka server component.
az containerapp update \ --name $APP_NAME \ --resource-group $RESOURCE_GROUP \ --bind $EUREKA_COMPONENT_FIRST -
Bind the container app to the second Eureka server component.
az containerapp update \ --name $APP_NAME \ --resource-group $RESOURCE_GROUP \ --bind $EUREKA_COMPONENT_SECOND
Important
To view the Eureka Server for Spring dashboard, you need to have the Microsoft.App/managedEnvironments/write, Owner, or Contributor role assigned to your account for the Container Apps environment resource.
- If you already have one of these roles, skip to the Get the dashboard URL section to get the URL and view the dashboard.
- If you want to create a custom role definition and assign it to your account, take the steps in the following section, Create and assign a custom role.
- If you want to assign your account the
OwnerorContributorrole for the resource, make that assignment, and then skip to the Get the dashboard URL section.
-
Create the custom role definition. Before you run this command, replace the placeholder in the
AssignableScopesvalue with your subscription ID.az role definition create --role-definition '{ "Name": "Java Component Dashboard Access", "IsCustom": true, "Description": "Can access managed Java Component dashboards in managed environments", "Actions": [ "Microsoft.App/managedEnvironments/write" ], "AssignableScopes": ["/subscriptions/<SUBSCRIPTION_ID>"] }' -
Get the resource ID of the Container Apps environment.
export ENVIRONMENT_ID=$(az containerapp env show \ --name $ENVIRONMENT --resource-group $RESOURCE_GROUP \ --query id \ --output tsv) -
Assign the custom role to your account for the Container Apps environment resource. Before you run this command, replace the placeholder in the
assigneevalue with your user object ID or service principal ID.az role assignment create \ --assignee <USER_OR_SERVICE_PRINCIPAL_ID> \ --role "Java Component Dashboard Access" \ --scope $ENVIRONMENT_ID
Get the URL of the Eureka Server for Spring dashboard.
az containerapp env java-component eureka-server-for-spring show \
--environment $ENVIRONMENT \
--resource-group $RESOURCE_GROUP \
--name $EUREKA_COMPONENT_FIRST \
--query properties.ingress.fqdn \
--output tsv
This command returns the URL you can use to access the Eureka Server for Spring dashboard. Through the dashboard, you can verify that the Eureka server setup consists of two replicas.
:::image type="content" source="media/java-components/eureka-highly-available.png" alt-text="Screenshot of a Eureka for Spring dashboard. The registered instances section lists a container app and two Eureka servers, all with a status of up." lightbox="media/java-components/eureka-highly-available.png":::
The resources created in this tutorial affect your Azure bill. If you aren't going to use these services in the long term, run the following command to remove everything created in this tutorial.
az group delete --resource-group $RESOURCE_GROUP
[!div class="nextstepaction"] Tutorial: Connect to a managed Eureka Server for Spring in Azure Container Apps