You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can deploy your Java application with many different options, including a local file system, a code repository, Maven, an IDE, a WAR file, a JAR file, or even directly from the source code. By the end of this tutorial, you deploy a web application that you can manage through the Azure portal. The following screenshot shows the home page of the PetClinic application deployed to Azure Container Apps:
10
+
There are several options available for deploying Java applications, including the following options:
11
+
12
+
- Deployment from a local file system or from a code repository.
13
+
- Deployment using Maven or an IDE.
14
+
- Deployment using a WAR file, a JAR file, or directly from source code.
15
+
16
+
By the end of this tutorial, you deploy a web application that you can manage through the Azure portal. The following screenshot shows the home page of the PetClinic application deployed to Azure Container Apps:
10
17
11
18
:::image type="content" source="../media/java-get-started/azure-container-apps-spring-pet-clinic-home-page.png" alt-text="Screenshot of the home page of the PetClinic app." lightbox="../media/java-get-started/azure-container-apps-spring-pet-clinic-home-page.png":::
12
19
13
20
## Prerequisites
14
21
15
22
- An Azure subscription. [Create one for free.](https://azure.microsoft.com/free/).
16
23
- The `Contributor` or `Owner` permission on the Azure subscription. For more information, see [Assign Azure roles using the Azure portal](../../role-based-access-control/role-assignments-portal.yml?tabs=current).
17
-
-[A GitHub Account](https://github.com/join).
18
-
-[git](https://git-scm.com/downloads)
24
+
-[A GitHub account](https://github.com/join).
25
+
-[Git](https://git-scm.com/downloads)
19
26
-[Azure CLI](/cli/azure/install-azure-cli)
20
-
- The Azure Container Apps CLI extension, version 0.3.47 or higher.
27
+
- The Azure Container Apps CLI extension, version 0.3.47 or higher. Use the following command to install the latest version: `az extension add --name containerapp --upgrade --allow-preview`
21
28
-[The Java Development Kit](/java/openjdk/install), version 17 or later.
After the deployment finishes, from the Azure portal, you can navigate to the **Overview** page of your container app and set the **Application Url** field. After doing that, you can see the project running in the cloud. The following screenshot shows the application status of the app running on Azure:
12
-
13
-
:::image type="content" source="../media/java-get-started/azure-container-apps-spring-pet-clinic-in-azure-portal.png" alt-text="Screenshot of the application details in Azure, with the Application URL field highlighted." lightbox="../media/java-get-started/azure-container-apps-spring-pet-clinic-in-azure-portal.png":::
12
+
After the deployment finishes, go to the Azure portal **Overview** page of your container app and select **Application Url** to see the application running in the cloud.
14
13
15
14
## Clean up resources
16
15
17
16
If you plan to continue working with more quickstarts and tutorials, you might want to leave these resources in place. When you no longer need the resources, you can remove them to avoid Azure charges, by using the following command:
1. If you haven't yet, sign in to Azure from the CLI. For more information, see the [Setup](quickstart-code-to-cloud.md?tabs=bash%2Cjava#setup) section of [Build and deploy from local source code to Azure Container Apps](quickstart-code-to-cloud.md).
69
+
1. Sign in to Azure from the CLIif you aren't already signed in. For more information, see the [Setup](quickstart-code-to-cloud.md?tabs=bash%2Cjava#setup) section of [Build and deploy from local source code to Azure Container Apps](quickstart-code-to-cloud.md).
69
70
70
71
1. Build and deploy the Spring PetClinic app by using the following command. The `..` (dot dot) indicates that you're using the Dockerfile in the parent folder.
71
72
72
-
> [!NOTE]
73
-
> This command accomplishes the following tasks:
74
-
>
75
-
> - Creates the resource group.
76
-
> - Creates an Azure container registry.
77
-
> - Builds the container image and pushes it to the registry.
78
-
> - Creates the Container Apps environment with a Log Analytics workspace.
79
-
> - Creates and deploys the container app using the built container image.
80
-
81
73
```azurecli
82
74
az containerapp up \
83
75
--resource-group $RESOURCE_GROUP \
@@ -87,4 +79,12 @@ Deploy the PetClinic application to Azure Container Apps by using the following
87
79
--source ..
88
80
```
89
81
82
+
This command accomplishes the following tasks:
83
+
84
+
- Creates the resource group.
85
+
- Creates an Azure container registry.
86
+
- Builds the container image and pushes it to the registry.
87
+
- Creates the Container Apps environment with a Log Analytics workspace.
88
+
- Creates and deploys the container app using the built container image.
Use the **Fork** button on the [Azure Container Apps Java Samples](https://github.com/Azure-Samples/azure-container-apps-java-samples.git) repo page to fork the repo to your personal GitHub account.
22
+
Use the **Fork** button on the [Azure Container Apps Java Samples](https://github.com/Azure-Samples/azure-container-apps-java-samples.git) repo page to fork the repo to your personal GitHub account. When the fork is complete, copy the fork's URL for use in the next section.
22
23
23
24
## Deploy the project
24
25
@@ -28,35 +29,35 @@ Deploy the project by using the following steps:
1. If you haven't yet, sign in to Azure from the CLI. For more information, see the [Setup](quickstart-code-to-cloud.md?tabs=bash%2Cjava#setup) section of [Quickstart: Build and deploy from local source code to Azure Container Apps](quickstart-code-to-cloud.md).
38
+
1. Sign in to Azure from the CLIif you aren't already signed in. For more information, see the [Setup](quickstart-code-to-cloud.md?tabs=bash%2Cjava#setup) section of [Quickstart: Build and deploy from local source code to Azure Container Apps](quickstart-code-to-cloud.md).
37
39
38
40
1. Build and deploy your Spring Boot app by using the following command:
39
41
40
-
> [!NOTE]
41
-
> This command performs the following tasks:
42
-
>
43
-
> - Creates the resource group.
44
-
> - Creates an Azure container registry.
45
-
> - Builds the container image and pushes it to the registry.
46
-
> - Creates the Container Apps environment with a Log Analytics workspace.
47
-
> - Creates and deploys the container app by using the built container image.
48
-
49
42
```azurecli
50
43
az containerapp up \
51
44
--resource-group $RESOURCE_GROUP \
52
45
--name $CONTAINER_APP_NAME \
53
46
--location $LOCATION \
54
47
--environment $ENVIRONMENT \
55
48
--context-path ./spring-petclinic \
56
-
--repo <url-of-your-github-fork>
49
+
--repo $REPO_URL
57
50
```
58
51
59
-
When you push new code to the repository, the GitHub Action performs the following tasks:
52
+
This command performs the following tasks:
53
+
54
+
- Creates the resource group.
55
+
- Creates an Azure container registry.
56
+
- Builds the container image and pushes it to the registry.
57
+
- Creates the Container Apps environment with a Log Analytics workspace.
58
+
- Creates and deploys the container app by using the built container image.
59
+
60
+
The project is now deployed. When you push new code to the repository, a GitHub Action performs the following tasks:
60
61
61
62
- Builds the container image and pushes it to the Azure container registry.
62
63
- Deploys the container image to the created container app.
# Quickstart: Launch your first Java application in Azure Container Apps with a WAR or JAR file
15
+
# Quickstart: Launch your first Java application in Azure Container Apps using a WAR or JAR file
15
16
16
-
This article shows you how to use a WAR or JAR file to deploy the Spring PetClinic sample application to Azure Container Apps.
17
+
This article shows you how to deploy the Spring PetClinic sample application to Azure Container Apps using a web application archive (WAR) file or a Java Archive (JAR) file.
@@ -52,12 +53,10 @@ Build the project by using the following steps:
52
53
1. Initialize and update the **Spring PetClinic Sample Application** repo to the latest version by using the following command:
53
54
54
55
```bash
55
-
git submodule update \
56
-
--init \
57
-
--recursive
56
+
git submodule update --init --recursive
58
57
```
59
58
60
-
1. Use the following command to clean the Maven build area, compile the project's code, create a JAR file, and skip all tests during these processes:
59
+
1. Use the following command to clean the Maven build area, compile the project's code, and create a JAR file, skipping all tests during these processes:
61
60
62
61
```bash
63
62
mvn clean verify
@@ -75,7 +74,7 @@ You now have a **/target/petclinic.jar** file.
75
74
cd spring-framework-petclinic
76
75
```
77
76
78
-
1. Clean the Maven build area, compile the project's code, create a JAR file, and skip all tests during these processes, by using the following command:
77
+
1. Use the following command to clean the Maven build area, compile the project's code, and create a JAR file, skipping all tests during these processes:
79
78
80
79
```bash
81
80
mvn clean verify
@@ -89,19 +88,19 @@ You now have a **/target/petclinic.war** file.
89
88
90
89
::: zone pivot="jar"
91
90
92
-
Deploy the JAR package to Container Apps by using the following command:
91
+
Deploy the JAR package to Azure Container Apps by using the following command:
93
92
94
93
> [!NOTE]
95
-
> The default JDK version is 17. You have the option of specifying the version by using environment variables. To change the JDK version forcompatibility with your application, use the `--build-env-vars BP_JVM_VERSION=<YOUR_JDK_VERSION>` argument. For more information, see [Build environment variables for Javain Azure Container Apps (preview)](java-build-environment-variables.md).
94
+
> The default JDK version is 17. You have the option of specifying the version by using environment variables. To change the JDK version forcompatibility with your application, use the `--build-env-vars BP_JVM_VERSION=<your-JDK-version>` argument. For more information, see [Build environment variables for Javain Azure Container Apps (preview)](java-build-environment-variables.md).
96
95
97
96
```azurecli
98
97
az containerapp up \
99
-
--resource-group <RESOURCE_GROUP> \
100
-
--name <CONTAINER_APP_NAME> \
101
-
--subscription <SUBSCRIPTION_ID>\
102
-
--location <LOCATION> \
103
-
--environment <ENVIRONMENT_NAME> \
104
-
--artifact <JAR_FILE_PATH_AND_NAME> \
98
+
--resource-group <resource-group> \
99
+
--name <container-app-name> \
100
+
--subscription <subscription-ID>\
101
+
--location <location> \
102
+
--environment <environment-name> \
103
+
--artifact <JAR-file-path-and-name> \
105
104
--ingress external \
106
105
--target-port 8080 \
107
106
--query properties.configuration.ingress.fqdn
@@ -114,17 +113,16 @@ az containerapp up \
114
113
Deploy the WAR file to Azure Container Apps by using the following command:
115
114
116
115
> [!NOTE]
117
-
> The default Tomcat version is 9. To change the version forcompatibility with your application, use the `--build-env-vars BP_TOMCAT_VERSION=<YOUR_TOMCAT_VERSION>` argument. In this example, the Tomcat version is set to 10 (including any minor versions) by setting `BP_TOMCAT_VERSION=10.*`. For more information, see [Build environment variables for Javain Azure Container Apps (preview)](java-build-environment-variables.md).
116
+
> The default Tomcat version is 9. To change the version forcompatibility with your application, use the `--build-env-vars BP_TOMCAT_VERSION=<your-Tomcat-version>` argument. In this example, the Tomcat version is set to 10 - including any minor versions - by setting `BP_TOMCAT_VERSION=10.*`. For more information, see [Build environment variables for Javain Azure Container Apps (preview)](java-build-environment-variables.md).
In this example, `containerapp up`command includes the `--query properties.configuration.ingress.fqdn` argument, which returns the fully qualified domain name (FQDN), also known as the app's URL.
137
+
138
+
View the application by pasting this URL into a browser.
139
+
140
+
## Clean up resources
141
+
142
+
If you plan to continue working with more quickstarts and tutorials, you might want to leave these resources in place. When you no longer need the resources, you can remove them to avoid Azure charges, by using the following command:
0 commit comments