|
| 1 | +--- |
| 2 | +description: Reference for the 'toLower' DSC configuration document function |
| 3 | +ms.date: 10/03/2025 |
| 4 | +ms.topic: reference |
| 5 | +title: toLower |
| 6 | +--- |
| 7 | + |
| 8 | +# toLower |
| 9 | + |
| 10 | +## Synopsis |
| 11 | + |
| 12 | +Converts the specified string to lower case. |
| 13 | + |
| 14 | +## Syntax |
| 15 | + |
| 16 | +```Syntax |
| 17 | +toLower(<stringToChange>) |
| 18 | +``` |
| 19 | + |
| 20 | +## Description |
| 21 | + |
| 22 | +The `toLower()` function converts all uppercase letters in the input string to |
| 23 | +lowercase letters. Numbers, symbols, punctuation, and whitespace are unchanged. |
| 24 | +The function supports Unicode characters and preserves the original string |
| 25 | +structure. Use it for normalizing string comparisons, creating consistent |
| 26 | +naming conventions, or formatting output for case-sensitive operations. |
| 27 | + |
| 28 | +## Examples |
| 29 | + |
| 30 | +### Example 1 - Normalize resource names |
| 31 | + |
| 32 | +The following example converts a parameter value to lowercase for consistent |
| 33 | +resource naming. |
| 34 | + |
| 35 | +```yaml |
| 36 | +# tolower.example.1.dsc.config.yaml |
| 37 | +$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json |
| 38 | +parameters: |
| 39 | + resourceName: |
| 40 | + type: string |
| 41 | + defaultValue: WEB-API-SERVICE |
| 42 | +resources: |
| 43 | +- name: Resource name normalization |
| 44 | + type: Microsoft.DSC.Debug/Echo |
| 45 | + properties: |
| 46 | + output: |
| 47 | + originalName: "[parameters('resourceName')]" |
| 48 | + normalizedName: "[toLower(parameters('resourceName'))]" |
| 49 | +``` |
| 50 | +
|
| 51 | +```bash |
| 52 | +dsc config get --file tolower.example.1.dsc.config.yaml |
| 53 | +``` |
| 54 | + |
| 55 | +```yaml |
| 56 | +results: |
| 57 | +- name: Resource name normalization |
| 58 | + type: Microsoft.DSC.Debug/Echo |
| 59 | + result: |
| 60 | + actualState: |
| 61 | + output: |
| 62 | + originalName: WEB-API-SERVICE |
| 63 | + normalizedName: web-api-service |
| 64 | +messages: [] |
| 65 | +hadErrors: false |
| 66 | +``` |
| 67 | +
|
| 68 | +### Example 2 - Create consistent file paths |
| 69 | +
|
| 70 | +The following example demonstrates using `toLower()` with the [`concat()`][01] |
| 71 | +function to create lowercase file paths. |
| 72 | + |
| 73 | +```yaml |
| 74 | +# tolower.example.2.dsc.config.yaml |
| 75 | +$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json |
| 76 | +parameters: |
| 77 | + fileName: |
| 78 | + type: string |
| 79 | + defaultValue: CONFIG-FILE |
| 80 | + extension: |
| 81 | + type: string |
| 82 | + defaultValue: JSON |
| 83 | +resources: |
| 84 | +- name: File path creation |
| 85 | + type: Microsoft.DSC.Debug/Echo |
| 86 | + properties: |
| 87 | + output: |
| 88 | + filePath: "[concat('/etc/', toLower(parameters('fileName')), '.', toLower(parameters('extension')))]" |
| 89 | +``` |
| 90 | + |
| 91 | +```bash |
| 92 | +dsc config get --file tolower.example.2.dsc.config.yaml |
| 93 | +``` |
| 94 | + |
| 95 | +```yaml |
| 96 | +results: |
| 97 | +- name: File path creation |
| 98 | + type: Microsoft.DSC.Debug/Echo |
| 99 | + result: |
| 100 | + actualState: |
| 101 | + output: |
| 102 | + filePath: /etc/config-file.json |
| 103 | +messages: [] |
| 104 | +hadErrors: false |
| 105 | +``` |
| 106 | + |
| 107 | +### Example 3 - Case-insensitive comparison preparation |
| 108 | + |
| 109 | +The following example uses `toLower()` to normalize strings for comparison |
| 110 | +using the `equals()` function. |
| 111 | + |
| 112 | +```yaml |
| 113 | +# tolower.example.3.dsc.config.yaml |
| 114 | +$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json |
| 115 | +parameters: |
| 116 | + userInput: |
| 117 | + type: string |
| 118 | + defaultValue: Production |
| 119 | + expectedValue: |
| 120 | + type: string |
| 121 | + defaultValue: PRODUCTION |
| 122 | +resources: |
| 123 | +- name: Case-insensitive comparison |
| 124 | + type: Microsoft.DSC.Debug/Echo |
| 125 | + properties: |
| 126 | + output: |
| 127 | + matches: "[equals(toLower(parameters('userInput')), toLower(parameters('expectedValue')))]" |
| 128 | +``` |
| 129 | + |
| 130 | +```bash |
| 131 | +dsc config get --file tolower.example.3.dsc.config.yaml |
| 132 | +``` |
| 133 | + |
| 134 | +```yaml |
| 135 | +results: |
| 136 | +- name: Case-insensitive comparison |
| 137 | + type: Microsoft.DSC.Debug/Echo |
| 138 | + result: |
| 139 | + actualState: |
| 140 | + output: |
| 141 | + matches: true |
| 142 | +messages: [] |
| 143 | +hadErrors: false |
| 144 | +``` |
| 145 | + |
| 146 | +### Example 4 - Unicode and special character handling |
| 147 | + |
| 148 | +The following example shows how `toLower()` handles Unicode characters and |
| 149 | +preserves special characters. |
| 150 | + |
| 151 | +```yaml |
| 152 | +# tolower.example.4.dsc.config.yaml |
| 153 | +$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json |
| 154 | +resources: |
| 155 | +- name: Unicode and special character conversion |
| 156 | + type: Microsoft.DSC.Debug/Echo |
| 157 | + properties: |
| 158 | + output: |
| 159 | + ascii: "[toLower('HELLO WORLD!')]" |
| 160 | + unicode: "[toLower('CAFÉ RÉSUMÉ')]" |
| 161 | + mixed: "[toLower('SERVER-01 (PRIMARY)')]" |
| 162 | +``` |
| 163 | + |
| 164 | +```bash |
| 165 | +dsc config get --file tolower.example.4.dsc.config.yaml |
| 166 | +``` |
| 167 | + |
| 168 | +```yaml |
| 169 | +results: |
| 170 | +- name: Unicode and special character conversion |
| 171 | + type: Microsoft.DSC.Debug/Echo |
| 172 | + result: |
| 173 | + actualState: |
| 174 | + output: |
| 175 | + ascii: hello world! |
| 176 | + unicode: café résumé |
| 177 | + mixed: server-01 (primary) |
| 178 | +messages: [] |
| 179 | +hadErrors: false |
| 180 | +``` |
| 181 | + |
| 182 | +## Parameters |
| 183 | + |
| 184 | +### stringToChange |
| 185 | + |
| 186 | +The string value to convert to lower case. |
| 187 | + |
| 188 | +```yaml |
| 189 | +Type: string |
| 190 | +Required: true |
| 191 | +Position: 1 |
| 192 | +``` |
| 193 | + |
| 194 | +## Output |
| 195 | + |
| 196 | +The `toLower()` function returns the input string with all uppercase letters |
| 197 | +converted to lowercase. Numbers, symbols, punctuation, and whitespace remain |
| 198 | +unchanged. |
| 199 | + |
| 200 | +```yaml |
| 201 | +Type: string |
| 202 | +``` |
| 203 | + |
| 204 | +## Related functions |
| 205 | + |
| 206 | +- [`toUpper()`][00] - Converts a string to upper case |
| 207 | +- [`concat()`][01] - Concatenates strings together |
| 208 | +- [`equals()`][02] - Compares two values for equality |
| 209 | +- [`if()`][03] - Returns values based on a condition |
| 210 | +- [`string()`][04] - Converts values to strings |
| 211 | +- [`parameters()`][05] - Retrieves parameter values |
| 212 | + |
| 213 | +<!-- Link reference definitions --> |
| 214 | +[00]: ./toUpper.md |
| 215 | +[01]: ./concat.md |
| 216 | +[02]: ./equals.md |
| 217 | +[03]: ./if.md |
| 218 | +[04]: ./string.md |
| 219 | +[05]: ./parameters.md |
0 commit comments