Skip to content

Commit c08af40

Browse files
challenge env fix
1 parent aa42ac3 commit c08af40

File tree

4 files changed

+64
-25
lines changed

4 files changed

+64
-25
lines changed

src/App/.env

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/start.cmd

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,59 @@ set APP_ENV_FILE=%ROOT_DIR%\src\App\.env
5454
) > "%APP_ENV_FILE%"
5555
echo Updated src/App/.env with APP_API_BASE_URL
5656

57-
REM Copy .env to workshop
58-
set MICROHACK_ENV_FILE=%ROOT_DIR%\workshop\docs\workshop\.env
59-
copy /Y "%ENV_FILE%" "%MICROHACK_ENV_FILE%"
57+
@REM REM Copy .env to workshop
58+
@REM set MICROHACK_ENV_FILE=%ROOT_DIR%\workshop\docs\workshop\.env
59+
@REM copy /Y "%ENV_FILE%" "%MICROHACK_ENV_FILE%"
60+
@REM if errorlevel 1 (
61+
@REM echo Failed to copy .env to workshop/docs/workshop
62+
@REM exit /b 1
63+
@REM )
64+
@REM echo Copied .env to workshop/docs/workshop
65+
66+
REM Define paths
67+
set "SOURCE_ENV_FILE=%ENV_FILE%"
68+
set "TARGET_ENV_FILE=%ROOT_DIR%\workshop\docs\workshop\.env"
69+
set "TEMP_MERGED_FILE=%TEMP%\merged_env.tmp"
70+
71+
REM Ensure the source env file exists
72+
if not exist "%SOURCE_ENV_FILE%" (
73+
echo Source .env file not found at %SOURCE_ENV_FILE%
74+
exit /b 1
75+
)
76+
77+
REM Create temporary merged file
78+
copy /Y "%TARGET_ENV_FILE%" "%TEMP_MERGED_FILE%" >nul 2>&1
79+
80+
REM Read lines from SOURCE_ENV_FILE
81+
for /f "usebackq tokens=* delims=" %%A in ("%SOURCE_ENV_FILE%") do (
82+
set "line=%%A"
83+
84+
REM Skip empty lines or comments
85+
if not "!line!"=="" if not "!line:~0,1!"=="#" (
86+
87+
REM Extract variable name (text before '=')
88+
for /f "tokens=1 delims==" %%B in ("!line!") do (
89+
set "var=%%B"
90+
91+
REM Check if variable already exists in TARGET_ENV_FILE
92+
findstr /b /i "%%B=" "%TARGET_ENV_FILE%" >nul
93+
if errorlevel 1 (
94+
echo !line!>>"%TEMP_MERGED_FILE%"
95+
) else (
96+
echo Skipping existing variable: %%B
97+
)
98+
)
99+
)
100+
)
101+
102+
REM Move merged file back to .env
103+
move /Y "%TEMP_MERGED_FILE%" "%TARGET_ENV_FILE%" >nul
60104
if errorlevel 1 (
61-
echo Failed to copy .env to workshop/docs/workshop
105+
echo Failed to update .env file
62106
exit /b 1
63107
)
64-
echo Copied .env to workshop/docs/workshop
108+
109+
echo Successfully merged .env variables.
65110

66111
REM Authenticate with Azure
67112
echo Checking Azure login status...

workshop/docs/workshop/.env.sample

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,2 @@
1-
# All configurations must be filled with valid values.
2-
# Rename file or create a new file ".env"
3-
4-
AZURE_OPENAI_ENDPOINT=""
51
AZURE_OPENAI_API_KEY=""
6-
AZURE_OPENAI_API_VERSION=""
7-
AZURE_OPENAI_DEPLOYMENT=""
8-
AZURE_SUBSCRIPTION_ID=""
9-
AZURE_RESOURCE_GROUP_NAME=""
10-
AZURE_PROJECT_NAME=""
11-
AZURE_API_ENDPOINT=""
2+
AZURE_AI_SEARCH_API_KEY=""

workshop/docs/workshop/Challenge-3-and-4/Challenge-3.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,33 +47,37 @@ One of the easiest and most fun changes you can make to the app is updating the
4747
<img src={AppLogo} alt="Logo" style={{ width: '30px' }} />
4848
```
4949

50-
50+
---
5151

5252
### Step 3: Run the App
5353

5454
1. Go to the [Azure Portal](https://portal.azure.com).
5555
2. In the **search bar**, type the name of the **Resource Group** you created during **Challenge 1**.
56-
3. Within the resource group, look for the **API App Service**.
57-
It will have a name similar to: kms2lspvbjwagg-api
56+
3. Within the resource group, look for the **API App Service** ending in -api.
5857
4. In the App Service, navigate to **Settings > Environment variables**.
5958
![Azure Portal Settings > Configuration](../img/portal-app-api-env.png)
6059
5. Locate the following environment variables:
6160
- `AZURE_AI_SEARCH_API_KEY`
6261
- `AZURE_OPENAI_API_KEY`
63-
6. Copy their values and paste them into your local `.env` file.
64-
7. Open a terminal or command prompt.
65-
8. Navigate to the project directory where `start.cmd` is located:
62+
6. Copy their values and paste them into your local `\workshop\docs\workshop\.env.sample` file:
63+
`AZURE_AI_SEARCH_API_KEY=your-key-from-portal`
64+
`AZURE_OPENAI_API_KEY=your-other-key-from-portal`
65+
7. Rename the .env.sample file to .env
66+
8. Open a terminal or command prompt.
67+
9. Navigate to the project directory where `start.cmd` is located:
6668

6769
```bash
6870
cd src/
6971
```
70-
9. Start the application:
72+
10. Make sure your Python virtual environment is activated, as done in the Challenge 1 deployment steps.
73+
74+
11. Start the application:
7175

7276
```bash
7377
./start.cmd
7478
```
75-
10. Two terminal windows will open — one for the backend and one for the frontend.
79+
12. Two terminal windows will open — one for the backend and one for the frontend.
7680

77-
Once the app starts, you should see your new logo and working backend in action!
81+
Once the app starts, you should see your new logo!
7882

7983

0 commit comments

Comments
 (0)