Skip to content

Commit 60dd9c3

Browse files
authored
multiple improvements on the docs (#166)
## Purpose - add operations to save/load environment variables - hide option 2 for lab 5 - update setup-azd to v2 - others ## Does this introduce a breaking change? <!-- Mark one with an "x". --> ``` [ ] Yes [x] No ``` ## Pull Request Type What kind of change does this Pull Request introduce? <!-- Please check the one that applies to this PR using "x". --> ``` [ ] Bugfix [ ] Feature [ ] Code style update (formatting, local variables) [ ] Refactoring (no functional changes, no api changes) [x] Documentation content changes [ ] Other... Please describe: ```
1 parent a62b170 commit 60dd9c3

File tree

9 files changed

+51
-22
lines changed

9 files changed

+51
-22
lines changed

.devcontainer/funcs.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
DEV_ENV_FILE="$HOME/.dev-environment"
4+
5+
function saveenv() {
6+
declare -p | grep "declare \(--\|-x\)" | grep -v "^declare \(--\|-x\) \(PS[0-9]\|BASH_.*\|PATH\|PWD\|LS_COLORS\)=" > "$DEV_ENV_FILE"
7+
}
8+
9+
function clearenv() {
10+
rm -f "$DEV_ENV_FILE"
11+
}
12+

.devcontainer/postCreateCommand.sh

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
#!/usr/bin/env bash
22

3+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
4+
source "$DIR/funcs.sh"
5+
36
azd config set alpha.deployment.stacks on
47

5-
DEV_ENV_FILE="\$HOME/.dev-environment"
8+
grep saveenv "$HOME/.bashrc" > /dev/null 2>&1
9+
if [[ $? -ne 0 ]]; then
610

7-
cat <<EOT >> "$HOME/.bashrc"
11+
cat <<EOT >> "$HOME/.bashrc"
12+
13+
DEV_ENV_FILE="\$HOME/.dev-environment"
814
915
# auto load
10-
if [[ -f "$DEV_ENV_FILE" ]]; then
11-
source "$DEV_ENV_FILE"
16+
if [[ -f "\$DEV_ENV_FILE" ]]; then
17+
source "\$DEV_ENV_FILE"
1218
fi
1319
14-
saveenv() {
15-
# Check if var_save is set
16-
declare -p | grep -v "declare -[a-z]*r" > "$DEV_ENV_FILE"
17-
}
20+
EOT
1821

19-
clearenv() {
20-
echo "" > "$DEV_ENV_FILE"
21-
}
22+
declare -f saveenv clearenv >> "$HOME/.bashrc"
2223

23-
EOT
24+
fi

.devcontainer/saveenv.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
2+
3+
source "$DIR/funcs.sh"
4+
saveenv

.github/workflows/azure-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
uses: actions/checkout@v4
2424

2525
- name: Install azd
26-
uses: Azure/setup-azd@v1.0.0
26+
uses: Azure/setup-azd@v2
2727

2828
- name: Install Az extensions
2929
run: |

docs/02_lab_launch/0209.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,9 @@ In this lab, you deployed the Spring Petclinic microservices application to Azur
1212
The below image illustrates the end state you have build in this lab.
1313

1414
![lab 2 overview](../../images/acalab2.png)
15+
16+
Tips for next labs:
17+
18+
- This is the fundemental part for the next labs, please keep the azure resource undeleted.
19+
- During this lab, we defined some environment variables, some of the variables are required in the next labs. To save these variables, in the command-line window, under the directory `spring-petclinic-microservices`, run the command `source ../.devcontainer/saveenv.sh`, this command will save the environment variables to file `~/.dev-environment`.
20+
- The new bash environment will automatically pick up the saved environment variables. Also you can manually load the saved variables with command `source ~/.dev-environment`.

docs/05_lab_openai/0501.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
---
2-
title: 'Create Azure OpenAI resources (Optional)'
2+
title: '1. Create Azure OpenAI resources (Optional)'
33
layout: default
44
nav_order: 1
55
parent: 'Lab 5: Integrate with Azure OpenAI'
66
---
77

8-
To add AI capablities to the application, you need create an Azure OpenAI account and deploy language models. You can use the following guidance:
8+
To add AI capabilities to the application, you need create an Azure OpenAI account and deploy language models. You can use the following guidance:
99
- [Create and deploy an Azure OpenAI Service resource](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/create-resource)
1010

11+
Skip this step if you already have valid `AZURE-OPENAI-ENDPOINT` and `AZURE-OPENAI-API-KEY` for your new AI service.
12+
1113
# Step by step guidance
1214

1315
1. Create an Azure OpenAI account. Run the following commands to create an Azure OpenAI account. Note that the name of the account must be globally unique, so adjust it accordingly in case the randomly generated name is already in use.

docs/05_lab_openai/05_openai.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: 'Create AI application from scratch'
2+
title: '2. Create AI application from scratch'
33
layout: default
44
nav_order: 3
55
parent: 'Lab 5: Integrate with Azure OpenAI'
@@ -13,8 +13,8 @@ We will start by creating a new Spring Boot application to connect with Azure Op
1313

1414
Prerequisites:
1515

16-
- Install extension `Github Copilot Chat` in VSCode.
17-
- Prepare the Open AI instance and install deployment 'gpt-4o'.
16+
- Install extension `GitHub Copilot Chat` in VSCode, try [GitHub Copilot Free](https://docs.github.com/en/copilot/managing-copilot/managing-copilot-as-an-individual-subscriber/about-github-copilot-free#vs-code).
17+
- Prepare the Open AI instance and install deployment `gpt-4o`, see [guide]({% link docs/05_lab_openai/0501.md %}).
1818
- Get the `endpoint` and `api-key` from the Open AI instance.
1919

2020
# Step by step guide
@@ -45,13 +45,13 @@ Prerequisites:
4545

4646
Edit with VSCode will accelerate your work in the next steps.
4747

48-
Get the `spring-ai` version from the project.
48+
Get the `spring-ai` version from the file `pom.xml` in the project.
4949

5050
```xml
5151
<spring-ai.version>1.0.0-M5</spring-ai.version>
5252
```
5353

54-
Here the spring-ai version is `1.0.0-M5`, save it in variable:
54+
Here the spring-ai version is `1.0.0-M5`, save it as variable in your command-line window:
5555

5656
```bash
5757
SPRING_AI_VERSION=1.0.0-M5
@@ -79,6 +79,7 @@ Prerequisites:
7979
Input the following text to the input box:
8080

8181
```text
82+
You are a Java engineer want to write your first AI empowered service and you start the new project from some samples.
8283
Refer to the sample file named "AzureOpenAIChatClientIT.java", add a new ChatController with POST endpoint at '/chatclient' to the chat-service project:
8384
* Use ChatClient to do the chat completion with Azure OpenAI Endpoint
8485
* Use system prompt from static string "You are a joke bot. You are funny and witty."
@@ -105,9 +106,11 @@ Prerequisites:
105106
mvn clean package -DskipTests
106107
```
107108

108-
- Fix some potential errors. You might need some minor fixes in the AI generated code. Some of the fixes including:
109+
Read the code generated by GitHub Copilot. Refer to [Azure OpenAI chat properties](https://docs.spring.io/spring-ai/reference/api/chat/azure-openai-chat.html) for more info on configuration properties.
109110

110-
- In ChatController.java: `response.getResults().get(0).getOutput().getText()` --> `response.getResults().get(0).getOutput().getContent()`
111+
- Fix some potential errors. You might need some minor fixes in the AI generated code. Some of the fixes including:
112+
113+
a. In ChatController.java: `response.getResults().get(0).getOutput().getText()` --> `response.getResults().get(0).getOutput().getContent()`
111114
112115
- Run the new project locally:
113116

docs/05_lab_openai/05_openai_existing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: 'Integrate AI to existing project'
33
layout: default
44
nav_order: 4
5+
nav_exclude: true
56
parent: 'Lab 5: Integrate with Azure OpenAI'
67
---
78

images/adminserver_wallboard.png

-11.6 KB
Loading

0 commit comments

Comments
 (0)