Skip to content

Commit 6a7af4c

Browse files
committed
feedback updates
1 parent a5b7166 commit 6a7af4c

File tree

1 file changed

+8
-25
lines changed

1 file changed

+8
-25
lines changed

articles/azure-developer-cli/manage-environment-variables.md

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -208,39 +208,22 @@ This pattern keeps your templates flexible, enables per-environment customizatio
208208
209209
### Hooks
210210
211-
In custom scripts and [hooks](azd-extensibility.md) defined in your `azure.yaml` file, you can access environment variables using the `azd env get-values` command:
211+
`azd` environment variables are automatically preloaded and available in [hooks](azd-extensibility.md) and custom scripts defined in your `azure.yaml` file, you can access environment variables using the following syntax:
212212
213213
### [Bash](#tab/bash)
214214
215215
```bash
216-
#!/bin/bash
217-
echo "Loading azd .env file from current environment..."
218-
219-
while IFS='=' read -r key value; do
220-
value=$(echo "$value" | sed 's/^"//' | sed 's/"$//')
221-
export "$key=$value"
222-
done <<EOF
223-
$(azd env get-values)
224-
EOF
225-
226-
# Now you can use the variables like regular environment variables
216+
# Use the variables in your script
227217
echo "API endpoint: $API_ENDPOINT"
218+
echo "Deploying to: $AZURE_LOCATION"
228219
```
229220

230221
### [PowerShell](#tab/powershell)
231222

232223
```powershell
233-
Write-Host "Loading azd .env file from current environment"
234-
foreach ($line in (& azd env get-values)) {
235-
if ($line -match "([^=]+)=(.*)") {
236-
$key = $matches[1]
237-
$value = $matches[2] -replace '^"|"$'
238-
[Environment]::SetEnvironmentVariable($key, $value)
239-
}
240-
}
241-
242-
# Now you can use the variables like regular environment variables
243-
Write-Host "API endpoint: $env:API_ENDPOINT"
224+
# Use the variables in your script
225+
Write-Host "API endpoint: $API_ENDPOINT"
226+
Write-Host "Deploying to: $AZURE_LOCATION"
244227
```
245228

246229
---
@@ -327,7 +310,7 @@ Write-Host "AZD variable: $(azd env get-value MY_VARIABLE)"
327310

328311
---
329312

330-
**Convert `azd` environment variables to OS environment variables:**
313+
**Write `azd` environment variables to OS or framework environment variables:**
331314

332315
### [Bash](#tab/bash)
333316

@@ -356,7 +339,7 @@ foreach ($line in (& azd env get-values)) {
356339

357340
---
358341

359-
## Common environment variables
342+
## Standard environment variables
360343

361344
`azd` sets and uses several common environment variables across all environments:
362345

0 commit comments

Comments
 (0)