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
@@ -31,7 +33,7 @@ This article is intended to help you quickly get to deployment. Before going to
31
33
* This article requires at least version 2.31.0 of Azure CLI. If using Azure Cloud Shell, the latest version is already installed.
32
34
33
35
> [!NOTE]
34
-
> This guidance can also be executed from a local developer command line with Azure CLI installed. To learn how to install the Azure CLI, see [How to install the Azure CLI](/cli/azure/install-azure-cli).
36
+
> This guidance can also be executed from a local developer command line with Azure CLI installed. To learn how to install the Azure CLI, see [How to install the Azure CLI](/cli/azure/install-azure-cli).
35
37
36
38
* If running the commands in this guide locally (instead of Azure Cloud Shell):
37
39
* Prepare a local machine with Unix-like operating system installed (for example, Ubuntu, Azure Linux, macOS, Windows Subsystem for Linux).
@@ -45,19 +47,28 @@ This article is intended to help you quickly get to deployment. Before going to
45
47
The following steps guide you to create a Liberty runtime on AKS. After completing these steps, you have an Azure Container Registry and an Azure Kubernetes Service cluster for deploying your containerized application.
46
48
47
49
1. Visit the [Azure portal](https://portal.azure.com/). In the search box at the top of the page, type *IBM WebSphere Liberty and Open Liberty on Azure Kubernetes Service*. When the suggestions start appearing, select the one and only match that appears in the **Marketplace** section. If you prefer, you can go directly to the offer with this shortcut link: [https://aka.ms/liberty-aks](https://aka.ms/liberty-aks).
50
+
48
51
1. Select **Create**.
49
-
1. In the **Basics** pane, create a new resource group. Because resource groups must be unique within a subscription, pick a unique name. An easy way to have unique names is to use a combination of your initials, today's date, and some identifier. For example, `ejb0913-java-liberty-project-rg`. Select *East US* as **Region**. Select **Next** to **AKS** pane.
50
-
1. This pane allows you to select an existing AKS cluster and Azure Container Registry (ACR), instead of causing the deployment to create a new one, if desired. This capability enables you to use the sidecar pattern, as shown in the [Azure architecture center](/azure/architecture/patterns/sidecar). You can also adjust the settings for the size and number of the virtual machines in the AKS node pool. Leave all other values at the defaults and select **Next** to **Load balancing** pane.
51
-
1. Next to **Connect to Azure Application Gateway?** select **Yes**. This section lets you customize the following deployment options.
52
-
1. You can customize the virtual network and subnet into which the deployment will place the resources. Leave these values at their defaults.
53
-
1. You can provide the TLS/SSL certificate presented by the Azure Application Gateway. Leave the values at the default to cause the offer to generate a self-signed certificate. Don't go to production using a self-signed certificate. For more information about self-signed certificates, see [Create a self-signed public certificate to authenticate your application](../active-directory/develop/howto-create-self-signed-certificate.md).
54
-
1. You can enable cookie based affinity, also known as sticky sessions. We want sticky sessions enabled for this article, so ensure this option is selected.
55
-

56
-
1. Select **Next** to **Operator and application** pane. This quickstart uses all defaults in this pane. However, it lets you customize the following deployment options.
52
+
53
+
1. In the **Basics** pane:
54
+
55
+
1. Create a new resource group. Because resource groups must be unique within a subscription, pick a unique name. An easy way to have unique names is to use a combination of your initials, today's date, and some identifier. For example, `ejb0913-java-liberty-project-rg`.
56
+
1. Select *East US* as **Region**.
57
+
58
+
1. Select **Next**, enter the **AKS** pane. This pane allows you to select an existing AKS cluster and Azure Container Registry (ACR), instead of causing the deployment to create a new one, if desired. This capability enables you to use the sidecar pattern, as shown in the [Azure architecture center](/azure/architecture/patterns/sidecar). You can also adjust the settings for the size and number of the virtual machines in the AKS node pool. Leave all other values at the defaults.
59
+
60
+
1. Select **Next**, enter the **Load Balancing** pane. Next to **Connect to Azure Application Gateway?** select **Yes**. This section lets you customize the following deployment options.
61
+
62
+
1. You can customize the **virtual network** and **subnet** into which the deployment will place the resources. Leave these values at their defaults.
63
+
1. You can provide the **TLS/SSL certificate** presented by the Azure Application Gateway. Leave the values at the default to cause the offer to generate a self-signed certificate. Don't go to production using a self-signed certificate. For more information about self-signed certificates, see [Create a self-signed public certificate to authenticate your application](../active-directory/develop/howto-create-self-signed-certificate.md).
64
+
1. You can select **Enable cookie based affinity**, also known as sticky sessions. We want sticky sessions enabled for this article, so ensure this option is selected.
65
+
66
+
1. Select **Next**, enter the **Operator and application** pane. This quickstart uses all defaults in this pane. However, it lets you customize the following deployment options.
67
+
57
68
1. You can deploy WebSphere Liberty Operator by selecting **Yes** for option **IBM supported?**. Leaving the default **No** deploys Open Liberty Operator.
58
69
1. You can deploy an application for your selected Operator by selecting **Yes** for option **Deploy an application?**. Leaving the default **No** doesn't deploy any application.
59
-
1. Select **Review + create** to validate your selected options.
60
-
1.When you see the message **Validation Passed**, select **Create**. The deployment may take up to 20 minutes.
70
+
71
+
1.Select **Review + create** to validate your selected options. In the ***Review + create** pane, when you see **Create** light up after validation pass, select **Create**. The deployment may take up to 20 minutes.
61
72
62
73
## Capture selected information from the deployment
63
74
@@ -75,9 +86,17 @@ If you navigated away from the **Deployment is in progress** page, the following
75
86
1. Using the same copy technique as with the preceding values, save aside the values for the following outputs:
76
87
77
88
*`cmdToConnectToCluster`
78
-
*`appDeploymentTemplateYaml`
89
+
*`appDeploymentTemplateYaml` if you select **No** to **Deploy an application?** when deploying the Marketplace offer; or `appDeploymentYaml` if you select **yes** to **Deploy an application?**.
90
+
91
+
### [Bash](#tab/in-bash)
92
+
93
+
Paste the value of `appDeploymentTemplateYaml` or `appDeploymentYaml` into a Bash shell, append `| grep secretName`, and execute. This command will output the Ingress TLS secret name, such as `- secretName: secret785e2c`. Save aside the value for `secretName` from the output.
94
+
95
+
### [PowerShell](#tab/in-powershell)
96
+
97
+
Paste the quoted string in `appDeploymentTemplateYaml` or `appDeploymentYaml` into a PowerShell, append `| ForEach-Object { [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($_)) } | Select-String "secretName"`, and execute. This command will output the Ingress TLS secret name, such as `- secretName: secret785e2c`. Save aside the value for `secretName` from the output.
79
98
80
-
1. Paste the value of `appDeploymentTemplateYaml` into a Bash shell, append `| grep secretName`, and execute. This command will output the Ingress TLS secret name, such as `- secretName: secret785e2c`. Save aside the value for `secretName` from the output.
99
+
---
81
100
82
101
These values will be used later in this article. Note that several other useful commands are listed in the outputs.
83
102
@@ -97,7 +116,7 @@ The following steps guide you through creating an Azure SQL Database single data
97
116
>
98
117
> At the **Networking** step, set **Connectivity method** to **Public endpoint**, **Allow Azure services and resources to access this server** to **Yes**, and **Add current client IP address** to **Yes**.
99
118
>
100
-
> 
119
+
> :::image type="content" source="media/howto-deploy-java-liberty-app/create-sql-database-networking.png" alt-text="Screenshot of the Azure portal that shows the Networking tab of the Create SQL Database page with the Connectivity method and Firewall rules settings highlighted." lightbox="media/howto-deploy-java-liberty-app/create-sql-database-networking.png":::
101
120
102
121
Now that the database and AKS cluster have been created, we can proceed to preparing AKS to host your Open Liberty application.
103
122
@@ -111,7 +130,7 @@ Clone the sample code for this guide. The sample is on [GitHub](https://github.c
111
130
112
131
There are a few samples in the repository. We'll use *java-app/*. Here's the file structure of the application.
@@ -151,23 +170,47 @@ In directory *liberty/config*, the *server.xml* file is used to configure the DB
151
170
152
171
Now that you've gathered the necessary properties, you can build the application. The POM file for the project reads many variables from the environment. As part of the Maven build, these variables are used to populate values in the YAML files located in *src/main/aks*. You can do something similar for your application outside Maven if you prefer.
153
172
173
+
### [Bash](#tab/in-bash)
174
+
154
175
```bash
155
176
cd<path-to-your-repo>/java-app
156
177
157
178
# The following variables will be used for deployment file generation into target.
You can now run and test the project locally before deploying to Azure. For convenience, we use the `liberty-maven-plugin`. To learn more about the `liberty-maven-plugin`, see [Building a web application with Maven](https://openliberty.io/guides/maven-intro.html). For your application, you can do something similar using any other mechanism, such as your local IDE. You can also consider using the `liberty:devc` option intended for development with containers. You can read more about `liberty:devc` in the [Liberty docs](https://openliberty.io/docs/latest/development-mode.html#_container_support_for_dev_mode).
@@ -199,15 +242,30 @@ You can now use the following steps to test the Docker image locally before depl
199
242
200
243
1. Run the image using the following command. Note we're using the environment variables defined previously.
201
244
245
+
### [Bash](#tab/in-bash)
246
+
202
247
```bash
203
248
docker run -it --rm -p 9080:9080 \
204
-
-e DB_SERVER_NAME=${DB_SERVER_NAME} \
205
-
-e DB_NAME=${DB_NAME} \
206
-
-e DB_USER=${DB_USER} \
207
-
-e DB_PASSWORD=${DB_PASSWORD} \
208
-
javaee-cafe:v1
249
+
-e DB_SERVER_NAME=${DB_SERVER_NAME} \
250
+
-e DB_NAME=${DB_NAME} \
251
+
-e DB_USER=${DB_USER} \
252
+
-e DB_PASSWORD=${DB_PASSWORD} \
253
+
javaee-cafe:v1
254
+
```
255
+
256
+
### [PowerShell](#tab/in-powershell)
257
+
258
+
```powershell
259
+
docker run -it --rm -p 9080:9080 `
260
+
-e DB_SERVER_NAME=${Env:DB_SERVER_NAME} `
261
+
-e DB_NAME=${Env:DB_NAME} `
262
+
-e DB_USER=${Env:DB_USER} `
263
+
-e DB_PASSWORD=${Env:DB_PASSWORD} `
264
+
javaee-cafe:v1
209
265
```
210
266
267
+
---
268
+
211
269
1. Once the container starts, go to `http://localhost:9080/` in your browser to access the application.
212
270
213
271
1. Press <kbd>Ctrl</kbd>+<kbd>C</kbd> to stop.
@@ -216,15 +274,27 @@ You can now use the following steps to test the Docker image locally before depl
216
274
217
275
Upload the built image to the ACR created in the offer.
218
276
277
+
### [Bash](#tab/in-bash)
278
+
219
279
```bash
220
280
docker tag javaee-cafe:v1 ${LOGIN_SERVER}/javaee-cafe:v1
The following steps deploy and test the application.
297
+
Use the following steps to deploy and test the application:
228
298
229
299
1. Connect to the AKS cluster.
230
300
@@ -245,15 +315,13 @@ The following steps deploy and test the application.
245
315
kubectl apply -f openlibertyapplication-agic.yaml
246
316
```
247
317
248
-
1. Wait for the pods to be restarted.
249
-
250
-
Wait until all pods are restarted successfully using the following command.
318
+
1. Wait until all pods are restarted successfully by using the following command:
251
319
252
320
```bash
253
321
kubectl get pods --watch
254
322
```
255
323
256
-
You should see output similar to the following to indicate that all the pods are running.
324
+
You should see output similar to the following example to indicate that all the pods are running:
257
325
258
326
```output
259
327
NAME READY STATUS RESTARTS AGE
@@ -274,22 +342,44 @@ The following steps deploy and test the application.
274
342
275
343
1. Go to `https://<ADDRESS>` to test the application. For your convenience, this shell command will create an environment variable whose value you can paste straight into the browser.
If the web page doesn't render correctly or returns a `502 Bad Gateway` error, that's because the app is still starting in the background. Wait for a few minutes and then try again.
283
362
284
363
## Clean up resources
285
364
286
365
To avoid Azure charges, you should clean up unnecessary resources. When the cluster is no longer needed, use the [az group delete](/cli/azure/group#az-group-delete) command to remove the resource group, container service, container registry, and all related resources.
287
366
288
-
```azurecli-interactive
367
+
### [Bash](#tab/in-bash)
368
+
369
+
```bash
289
370
az group delete --name $RESOURCE_GROUP_NAME --yes --no-wait
290
371
az group delete --name <db-resource-group> --yes --no-wait
291
372
```
292
373
374
+
### [PowerShell](#tab/in-powershell)
375
+
376
+
```powershell
377
+
az group delete --name $Env:RESOURCE_GROUP_NAME --yes --no-wait
378
+
az group delete --name <db-resource-group> --yes --no-wait
0 commit comments