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
Copy file name to clipboardExpand all lines: articles/dev-spaces/quickstart-java.md
+30-36Lines changed: 30 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,28 +9,21 @@ manager: gwallace
9
9
---
10
10
# Quickstart: Debug and iterate on Kubernetes with Visual Studio Code and Java - Azure Dev Spaces
11
11
12
-
In this guide, you will learn how to:
13
-
14
-
- Set up Azure Dev Spaces with a managed Kubernetes cluster in Azure.
15
-
- Iteratively develop code in containers using Visual Studio Code.
16
-
- Debug the code in your dev space from Visual Studio Code.
17
-
18
-
Azure Dev Spaces also allows you to debug and iterate using:
19
-
-[Node.js and Visual Studio Code](quickstart-nodejs.md)
20
-
-[.NET Core and Visual Studio Code](quickstart-netcore.md)
21
-
-[.NET Core and Visual Studio](quickstart-netcore-visualstudio.md)
12
+
In this quickstart, you set up Azure Dev Spaces with a managed Kubernetes cluster, and use a Java app in Visual Studio Code to iteratively develop and debug code in containers. Azure Dev Spaces lets you debug and test all the components of your application in Azure Kubernetes Service (AKS) with minimal development machine setup.
22
13
23
14
## Prerequisites
24
15
25
-
- An Azure subscription. If you don't have one, you can create a [free account](https://azure.microsoft.com/free).
26
-
-[Visual Studio Code installed](https://code.visualstudio.com/download).
27
-
- The [Azure Dev Spaces](https://marketplace.visualstudio.com/items?itemName=azuredevspaces.azds) and [Java Debugger for Azure Dev Spaces](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-debugger-azds) extensions for Visual Studio Code installed.
-[Maven installed and configured](https://maven.apache.org).
16
+
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio).
17
+
-[Java Development Kit (JDK) 1.8.0+](https://aka.ms/azure-jdks).
-[Visual Studio Code](https://code.visualstudio.com/download).
20
+
- The [Azure Dev Spaces](https://marketplace.visualstudio.com/items?itemName=azuredevspaces.azds) and [Java Debugger for Azure Dev Spaces](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-debugger-azds) extensions for Visual Studio Code.
You need to create an AKS cluster in a [supported region][supported-regions]. The below commands create a resource group called *MyResourceGroup* and an AKS cluster called *MyAKS*.
26
+
You need to create an AKS cluster in a [supported region][supported-regions]. The following commands create a resource group called *MyResourceGroup* and an AKS cluster called *MyAKS*.
34
27
35
28
```cmd
36
29
az group create --name MyResourceGroup --location eastus
@@ -39,14 +32,15 @@ az aks create -g MyResourceGroup -n MyAKS --location eastus --disable-rbac --gen
39
32
40
33
## Enable Azure Dev Spaces on your AKS cluster
41
34
42
-
Use the `use-dev-spaces` command to enable Dev Spaces on your AKS cluster and follow the prompts. The below command enables Dev Spaces on the *MyAKS* cluster in the *MyResourceGroup* group and creates a *default* dev space.
35
+
Use the `use-dev-spaces` command to enable Dev Spaces on your AKS cluster and follow the prompts. The following command enables Dev Spaces on the *MyAKS* cluster in the *MyResourceGroup* group and creates a *default* dev space.
43
36
44
37
> [!NOTE]
45
-
> The `use-dev-spaces` command will also install the Azure Dev Spaces CLI if its not already installed. You cannot install the Azure Dev Spaces CLI in the Azure Cloud Shell.
38
+
> The `use-dev-spaces` command will also install the Azure Dev Spaces CLI if its not already installed. You can't install the Azure Dev Spaces CLI in the Azure Cloud Shell.
46
39
47
40
```cmd
48
41
$ az aks use-dev-spaces -g MyResourceGroup -n MyAKS
49
42
43
+
50
44
'An Azure Dev Spaces Controller' will be created that targets resource 'MyAKS' in resource group 'MyResourceGroup'. Continue? (y/N): y
51
45
52
46
Creating and selecting Azure Dev Spaces Controller 'MyAKS' in resource group 'MyResourceGroup' that targets resource 'MyAKS' in resource group 'MyResourceGroup'...2m 24s
## Prepare the sample application in Visual Studio Code
76
70
77
-
Open Visual Studio Code, click *File* then *Open...*, navigate to the *dev-spaces/samples/java/getting-started/webfrontend* directory, and click *Open*.
71
+
Open Visual Studio Code, select **File** then **Open**, navigate to the *dev-spaces/samples/java/getting-started/webfrontend* directory, and select **Open**.
78
72
79
73
You now have the *webfrontend* project open in Visual Studio Code. To run the application in your dev space, generate the Docker and Helm chart assets using the Azure Dev Spaces extension in the Command Palette.
80
74
81
-
To open the Command Palette in Visual Studio Code, click *View* then *Command Palette*. Begin typing `Azure Dev Spaces` and click on `Azure Dev Spaces: Prepare configuration files for Azure Dev Spaces`.
75
+
To open the Command Palette in Visual Studio Code, select **View** then **Command Palette**. Begin typing `Azure Dev Spaces` and select **Azure Dev Spaces: Prepare configuration files for Azure Dev Spaces**.
82
76
83
77

84
78
@@ -93,59 +87,59 @@ When Visual Studio Code also prompts you to configure your base images, exposed
93
87
This command prepares your project to run in Azure Dev Spaces by generating a Dockerfile and Helm chart. It also generates a *.vscode* directory with debugging configuration at the root of your project.
94
88
95
89
> [!TIP]
96
-
> The [Dockerfile and Helm chart](how-dev-spaces-works.md#prepare-your-code) for your project is used by Azure Dev Spaces to build and run your code, but you can modify these files if you want to change how the project is built and ran.
90
+
> The [Dockerfile and Helm chart](how-dev-spaces-works.md#prepare-your-code) for your project is used by Azure Dev Spaces to build and run your code, but you can modify these files if you want to change how the project is built and run.
97
91
98
-
## Build and run code in Kubernetes from Visual Studio
92
+
## Build and run code in Kubernetes from Visual Studio Code
99
93
100
-
Click on the *Debug* icon on the left and click *Launch Java Program (AZDS)* at the top.
94
+
Select the **Debug** icon on the left and select **Launch Java Program (AZDS)** at the top.
This command builds and runs your service in Azure Dev Spaces. The *Terminal* window at the bottom shows the build output and URLs for your service running Azure Dev Spaces. The *Debug Console* shows the log output.
98
+
This command builds and runs your service in Azure Dev Spaces. The **Terminal** window at the bottom shows the build output and URLs for your service running Azure Dev Spaces. The **Debug Console** shows the log output.
105
99
106
100
> [!Note]
107
-
> If you don't see any Azure Dev Spaces commands in the *Command Palette*, make sure you have installed the [Visual Studio Code extension for Azure Dev Spaces](https://marketplace.visualstudio.com/items?itemName=azuredevspaces.azds). Also verify you opened the *dev-spaces/samples/java/getting-started/webfrontend* directory in Visual Studio Code.
101
+
> If you don't see any Azure Dev Spaces commands in the **Command Palette**, make sure you have installed the [Visual Studio Code extension for Azure Dev Spaces](https://marketplace.visualstudio.com/items?itemName=azuredevspaces.azds). Also verify you opened the *dev-spaces/samples/java/getting-started/webfrontend* directory in Visual Studio Code.
108
102
109
103
You can see the service running by opening the public URL.
110
104
111
-
Click *Debug* then *Stop Debugging* to stop the debugger.
105
+
Select **Debug** then **Stop Debugging** to stop the debugger.
112
106
113
107
## Update code
114
108
115
-
To deploy an updated version of your service, you can update any file in your project and rerun *Launch Java Program (AZDS)*. For example:
109
+
To deploy an updated version of your service, you can update any file in your project and rerun **Launch Java Program (AZDS)**. For example:
116
110
117
-
1. If your application is still running, click *Debug* then *Stop Debugging* to stop it.
111
+
1. If your application is still running, select **Debug** then **Stop Debugging** to stop it.
118
112
1. Update [line 19 in `src/main/java/com/ms/sample/webfrontend/Application.java`](https://github.com/Azure/dev-spaces/blob/master/samples/java/getting-started/webfrontend/src/main/java/com/ms/sample/webfrontend/Application.java#L19) to:
119
113
120
114
```java
121
115
return"Hello from webfrontend in Azure!";
122
116
```
123
117
124
118
1.Save your changes.
125
-
1.Rerun*LaunchJavaProgram (AZDS)*.
119
+
1.Rerun**LaunchJavaProgram (AZDS)**.
126
120
1.Navigate to your running service and observe your changes.
127
-
1.Click*Debug* then *StopDebugging* to stop your application.
121
+
1.Select**Debug** then **StopDebugging** to stop your application.
128
122
129
123
## Setting and using breakpoints for debugging
130
124
131
-
Start your service using *LaunchJavaProgram (AZDS)*.This also runs your service in debugging mode.
125
+
Start your service using **LaunchJavaProgram (AZDS)**.This also runs your service in debugging mode.
132
126
133
-
Navigate back to the *Explorer* view by clicking *View* then *Explorer*.Open`src/main/java/com/ms/sample/webfrontend/Application.java` and click somewhere on line 19 to put your cursor there. To set a breakpoint hit *F9* or click *Debug* then *ToggleBreakpoint*.
127
+
Navigate back to the **Explorer** view by selecting **View** then **Explorer**.Open*src/main/java/com/ms/sample/webfrontend/Application.java* and click somewhere on line 19 to put your cursor there. To set a breakpoint press **F9** or select **Debug** then **ToggleBreakpoint**.
134
128
135
-
Open your service in a browser and notice no message is displayed. Return to VisualStudioCode and observe line 19 is highlighted. The breakpoint you set has paused the service at line 19.To resume the service, hit *F5* or click *Debug* then *Continue*.Return to your browser and notice the message is now displayed.
129
+
Open your service in a browser and notice no message is displayed. Return to VisualStudioCode and observe line 19 is highlighted. The breakpoint you set has paused the service at line 19.To resume the service, press **F5** or select **Debug** then **Continue**.Return to your browser and notice the message is now displayed.
136
130
137
131
While running your service in Kubernetes with a debugger attached, you have full access to debug information such as the call stack, local variables, and exception information.
138
132
139
-
Remove the breakpoint by putting your cursor on line 19 in `src/main/java/com/ms/sample/webfrontend/Application.java` and hitting *F9*.
133
+
Remove the breakpoint by putting your cursor on line 19 in *src/main/java/com/ms/sample/webfrontend/Application.java* and pressing **F9**.
140
134
141
135
## Update code from VisualStudioCode
142
136
143
-
While the service is running in debugging mode, update line 19 in `src/main/java/com/ms/sample/webfrontend/Application.java`.For example:
137
+
While the service is running in debugging mode, update line 19 in *src/main/java/com/ms/sample/webfrontend/Application.java*.For example:
144
138
```java
145
139
return"Hello from webfrontend in Azure while debugging!";
146
140
```
147
141
148
-
Save the file. Click *Debug* then *Restart Debugging* or in the *Debug toolbar*, click the *Restart Debugging* button.
142
+
Save the file. Select **Debug** then **Restart Debugging** or in the **Debug toolbar**, select the **Restart Debugging** button.
0 commit comments