Skip to content

Commit 60ef313

Browse files
committed
Update examples not to use lambda expressions
1 parent 87b2cae commit 60ef313

File tree

2 files changed

+47
-54
lines changed

2 files changed

+47
-54
lines changed

docs/reference/schemas/config/functions/cidrHost.md

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ messages: []
107107
hadErrors: false
108108
```
109109

110-
### Example 3 - Generate network device IPs with range
110+
### Example 3 - Allocate IPs for network infrastructure
111111

112-
The configuration uses the [`range()`][03] function to generate IP addresses
113-
for multiple network devices systematically, demonstrating how to combine
114-
functions for dynamic IP allocation.
112+
This configuration shows allocating specific IP addresses for various network
113+
infrastructure components within a subnet, demonstrating practical host number
114+
offsets for different device types.
115115

116116
```yaml
117117
# cidrHost.example.3.dsc.config.yaml
@@ -120,21 +120,19 @@ parameters:
120120
networkCidr:
121121
type: string
122122
defaultValue: 192.168.100.0/24
123-
startHost:
124-
type: int
125-
defaultValue: 20
126-
deviceCount:
127-
type: int
128-
defaultValue: 5
129123
resources:
130-
- name: Device IP allocation
124+
- name: Network infrastructure IPs
131125
type: Microsoft.DSC.Debug/Echo
132126
properties:
133127
output:
134128
network: "[parameters('networkCidr')]"
135129
gateway: "[cidrHost(parameters('networkCidr'), 1)]"
136-
dnsServer: "[cidrHost(parameters('networkCidr'), 2)]"
137-
deviceIPs: "[map(range(parameters('startHost'), parameters('deviceCount')), 'i', cidrHost(parameters('networkCidr'), add(i, parameters('startHost'))))]"
130+
primaryDNS: "[cidrHost(parameters('networkCidr'), 2)]"
131+
secondaryDNS: "[cidrHost(parameters('networkCidr'), 3)]"
132+
loadBalancer: "[cidrHost(parameters('networkCidr'), 10)]"
133+
webServer1: "[cidrHost(parameters('networkCidr'), 20)]"
134+
webServer2: "[cidrHost(parameters('networkCidr'), 21)]"
135+
dbServer: "[cidrHost(parameters('networkCidr'), 50)]"
138136
```
139137

140138
```bash
@@ -143,20 +141,19 @@ dsc config get --file cidrHost.example.3.dsc.config.yaml
143141

144142
```yaml
145143
results:
146-
- name: Device IP allocation
144+
- name: Network infrastructure IPs
147145
type: Microsoft.DSC.Debug/Echo
148146
result:
149147
actualState:
150148
output:
151149
network: 192.168.100.0/24
152150
gateway: 192.168.100.1
153-
dnsServer: 192.168.100.2
154-
deviceIPs:
155-
- 192.168.100.20
156-
- 192.168.100.21
157-
- 192.168.100.22
158-
- 192.168.100.23
159-
- 192.168.100.24
151+
primaryDNS: 192.168.100.2
152+
secondaryDNS: 192.168.100.3
153+
loadBalancer: 192.168.100.10
154+
webServer1: 192.168.100.20
155+
webServer2: 192.168.100.21
156+
dbServer: 192.168.100.50
160157
messages: []
161158
hadErrors: false
162159
```
@@ -217,15 +214,13 @@ The `cidrHost()` function raises errors for the following conditions:
217214
## Related functions
218215

219216
- [`cidrSubnet()`][02] - Creates a subnet from a larger CIDR block
220-
- [`parseCidr()`][04] - Parses CIDR notation and returns network details
221-
- [`range()`][03] - Generates a sequence of numbers
222-
- [`map()`][05] - Applies a function to each element in an array
223-
- [`parameters()`][06] - Retrieves parameter values
217+
- [`parseCidr()`][03] - Parses CIDR notation and returns network details
218+
- [`add()`][04] - Adds two numbers together
219+
- [`parameters()`][05] - Retrieves parameter values
224220

225221
<!-- Link reference definitions -->
226222
[01]: https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing
227223
[02]: ./cidrSubnet.md
228-
[03]: ./range.md
229-
[04]: ./parseCidr.md
230-
[05]: ./map.md
231-
[06]: ./parameters.md
224+
[03]: ./parseCidr.md
225+
[04]: ./add.md
226+
[05]: ./parameters.md

docs/reference/schemas/config/functions/cidrSubnet.md

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ messages: []
7171
hadErrors: false
7272
```
7373
74-
### Example 2 - Dynamic subnet allocation with range
74+
### Example 2 - Create subnets for multiple regions
7575
76-
The configuration uses [`range()`][02] to generate multiple subnets dynamically,
77-
perfect for scenarios where you need to create subnets programmatically based
78-
on the number of availability zones or regions.
76+
This configuration demonstrates creating dedicated subnets for different regions
77+
or environments, showing how to systematically allocate non-overlapping network
78+
segments from a larger address space.
7979
8080
```yaml
8181
# cidrSubnet.example.2.dsc.config.yaml
@@ -87,14 +87,16 @@ parameters:
8787
newPrefix:
8888
type: int
8989
defaultValue: 24
90-
subnetCount:
91-
type: int
92-
defaultValue: 5
9390
resources:
94-
- name: Generate subnets
91+
- name: Regional subnets
9592
type: Microsoft.DSC.Debug/Echo
9693
properties:
97-
output: "[map(range(0, parameters('subnetCount')), 'i', cidrSubnet(parameters('baseNetwork'), parameters('newPrefix'), i))]"
94+
output:
95+
eastus: "[cidrSubnet(parameters('baseNetwork'), parameters('newPrefix'), 0)]"
96+
westus: "[cidrSubnet(parameters('baseNetwork'), parameters('newPrefix'), 1)]"
97+
northeurope: "[cidrSubnet(parameters('baseNetwork'), parameters('newPrefix'), 2)]"
98+
westeurope: "[cidrSubnet(parameters('baseNetwork'), parameters('newPrefix'), 3)]"
99+
southeastasia: "[cidrSubnet(parameters('baseNetwork'), parameters('newPrefix'), 4)]"
98100
```
99101
100102
```bash
@@ -103,16 +105,16 @@ dsc config get --file cidrSubnet.example.2.dsc.config.yaml
103105

104106
```yaml
105107
results:
106-
- name: Generate subnets
108+
- name: Regional subnets
107109
type: Microsoft.DSC.Debug/Echo
108110
result:
109111
actualState:
110112
output:
111-
- 10.144.0.0/24
112-
- 10.144.1.0/24
113-
- 10.144.2.0/24
114-
- 10.144.3.0/24
115-
- 10.144.4.0/24
113+
eastus: 10.144.0.0/24
114+
westus: 10.144.1.0/24
115+
northeurope: 10.144.2.0/24
116+
westeurope: 10.144.3.0/24
117+
southeastasia: 10.144.4.0/24
116118
messages: []
117119
hadErrors: false
118120
```
@@ -249,16 +251,12 @@ The `cidrSubnet()` function raises errors for the following conditions:
249251

250252
## Related functions
251253

252-
- [`cidrHost()`][03] - Calculates a host IP address within a CIDR block
253-
- [`parseCidr()`][04] - Parses CIDR notation and returns network details
254-
- [`range()`][02] - Generates a sequence of numbers
255-
- [`map()`][05] - Applies a function to each element in an array
256-
- [`parameters()`][06] - Retrieves parameter values
254+
- [`cidrHost()`][02] - Calculates a host IP address within a CIDR block
255+
- [`parseCidr()`][03] - Parses CIDR notation and returns network details
256+
- [`parameters()`][04] - Retrieves parameter values
257257

258258
<!-- Link reference definitions -->
259259
[01]: https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing
260-
[02]: ./range.md
261-
[03]: ./cidrHost.md
262-
[04]: ./parseCidr.md
263-
[05]: ./map.md
264-
[06]: ./parameters.md
260+
[02]: ./cidrHost.md
261+
[03]: ./parseCidr.md
262+
[04]: ./parameters.md

0 commit comments

Comments
 (0)