Skip to content

Commit d6ed2a1

Browse files
Merge pull request #284244 from mumian/0809-readEnvironmentVariable
Add readEnvironmentVariable() remarks
2 parents 45cb3e4 + 015c483 commit d6ed2a1

File tree

3 files changed

+61
-4
lines changed

3 files changed

+61
-4
lines changed

articles/azure-resource-manager/bicep/bicep-core-diagnostics.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,15 +320,15 @@ If you need more information about a particular diagnostic code, select the **Fe
320320
| BCP334 | Warning | The provided value can have a length as small as {sourceMinLength} and may be too short to assign to a target with a configured minimum length of {targetMinLength}. |
321321
| BCP335 | Warning | The provided value can have a length as large as {sourceMaxLength} and may be too long to assign to a target with a configured maximum length of {targetMaxLength}. |
322322
| BCP337 | Error | This declaration type is not valid for a Bicep Parameters file. Specify a "{LanguageConstants.UsingKeyword}", "{LanguageConstants.ParameterKeyword}" or "{LanguageConstants.VariableKeyword}" declaration. |
323-
| BCP338 | Error | Failed to evaluate parameter "{parameterName}": {message} |
323+
| <a id='BCP338' />[BCP338](./diagnostics/bcp338.md) | Error | Failed to evaluate parameter \<parameter-name>: \<error-message>` |
324324
| BCP339 | Error | The provided array index value of "{indexSought}" is not valid. Array index should be greater than or equal to 0. |
325325
| BCP340 | Error | Unable to parse literal YAML value. Please ensure that it is well-formed. |
326326
| BCP341 | Error | This expression is being used inside a function declaration, which requires a value that can be calculated at the start of the deployment. {variableDependencyChainClause}{accessiblePropertiesClause} |
327327
| BCP342 | Error | User-defined types are not supported in user-defined function parameters or outputs. |
328328
| BCP344 | Error | Expected an assert identifier at this location. |
329329
| BCP345 | Error | A test declaration can only reference a Bicep File |
330-
| BCP0346 | Error | Expected a test identifier at this location. |
331-
| BCP0347 | Error | Expected a test path string at this location. |
330+
| BCP346 | Error | Expected a test identifier at this location. |
331+
| BCP347 | Error | Expected a test path string at this location. |
332332
| BCP348 | Error | Using a test declaration statement requires enabling EXPERIMENTAL feature "{nameof(ExperimentalFeaturesEnabled.TestFramework)}". |
333333
| BCP349 | Error | Using an assert declaration requires enabling EXPERIMENTAL feature "{nameof(ExperimentalFeaturesEnabled.Assertions)}". |
334334
| BCP350 | Error | Value of type "{valueType}" cannot be assigned to an assert. Asserts can take values of type 'bool' only. |

articles/azure-resource-manager/bicep/bicep-functions-parameters-file.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Bicep functions - parameters file
33
description: This article describes the Bicep functions to be used in Bicep parameter files.
44
ms.topic: reference
55
ms.custom: devx-track-bicep
6-
ms.date: 03/20/2024
6+
ms.date: 08/09/2024
77
---
88

99
# Parameters file function for Bicep
@@ -81,6 +81,28 @@ Namespace: [sys](bicep-functions.md#namespaces-for-functions).
8181

8282
The string value of the environment variable or a default value.
8383

84+
### Remarks
85+
86+
The following command sets the environment variable only for the PowerShell process in which it's executed. You get [BCP338](./diagnostics/bcp338.md) from Visual Studio Code.
87+
88+
```PowerShell
89+
$env:testEnvironmentVariable = "Hello World!"
90+
```
91+
92+
To set the environment variable at the user level, use the following command:
93+
94+
```powershell
95+
[System.Environment]::SetEnvironmentVariable('testEnvironmentVariable','Hello World!', 'User')
96+
```
97+
98+
To set the environment variable at the machine level, use the following command:
99+
100+
```powershell
101+
[System.Environment]::SetEnvironmentVariable('testEnvironmentVariable','Hello World!', 'Machine')
102+
```
103+
104+
For more information, see [Environment.SetEnvironmentVariable Method](/dotnet/api/system.environment.setenvironmentvariable).
105+
84106
### Examples
85107

86108
The following examples show how to retrieve the values of environment variables.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
title: BCP338
3+
description: Error - Failed to evaluate parameter <parameter-name>.
4+
ms.topic: reference
5+
ms.custom: devx-track-bicep
6+
ms.date: 08/09/2024
7+
---
8+
9+
# Bicep error code - BCP338
10+
11+
This error occurs when Bicep can't resolve a parameter name in the Bicep parameter file.
12+
13+
## Error description
14+
15+
`Failed to evaluate parameter <parameter-name>: <error-message>`.
16+
17+
## Solution
18+
19+
Check the parameter value.
20+
21+
## Examples
22+
23+
The following Bicep parameter file raises the error because _testEnvironmentVariable_ can't be found:
24+
25+
```bicep
26+
using 'main.bicep'
27+
param parTest = readEnvironmentVariable('testEnvironmentVariable')
28+
```
29+
30+
It could be because the environment variable isn't defined in the user or system level. For more information, see [`readEnvironmentVariable`](../bicep-functions-parameters-file.md)
31+
You can fix the error by assigning a string whose length is within the allowable range.
32+
33+
## Next steps
34+
35+
For more information about Bicep error and warning codes, see [Bicep core diagnostics](../bicep-core-diagnostics.md).

0 commit comments

Comments
 (0)