Skip to content

Commit 6d0c570

Browse files
Migrate NetworkFunction from generation to main (#24850)
* Move NetworkFunction to main * update ChangeLog --------- Co-authored-by: YanaXu <[email protected]>
1 parent 224655f commit 6d0c570

17 files changed

+248
-54
lines changed

src/NetworkFunction/NetworkFunction.Autorest/custom/New-AzNetworkFunctionCollectorPolicy.ps1

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -167,23 +167,33 @@ param(
167167
)
168168

169169
process {
170-
$rg = $PSBoundParameters.ResourceGroupName
171-
170+
$hasIngestionPolicyIngestionSource = $PSBoundParameters.Remove('IngestionPolicyIngestionSource')
172171
# Ensure exr circuit bandwidth 1G or more
173-
$cktname = $IngestionPolicyIngestionSource.ResourceId | Where {$IngestionPolicyIngestionSource.ResourceId -match "/*subscriptions/(?<subid>.*)/resourceGroups/(?<rgname>.*)/providers/Microsoft.Network/expressRouteCircuits/(?<circuitname>.*)"} | Foreach {$Matches['circuitname']}
174-
Import-Module Az.Network -Force
175-
$exrCircuit = Get-AzExpressRouteCircuit -Name $cktname -ResourceGroupName $rg
176-
$bandwidthInGbps = $exrCircuit.BandwidthInGbps
177-
$bandwidthInMbps = $exrCircuit.ServiceProviderProperties.BandwidthInMbps
178-
179-
if ($bandwidthInGbps -and ($bandwidthInGbps -lt 1)) {
180-
throw "CollectorPolicy can not be updated because circuit has bandwidth less than 1G. Circuit size with a bandwidth of 1G or more is supported."
181-
}
182-
183-
if ($bandwidthInMbps -and ($bandwidthInMbps -lt 1000)) {
184-
throw "CollectorPolicy can not be updated because circuit has bandwidth less than 1G. Circuit size with a bandwidth of 1G or more is supported."
172+
if ($hasIngestionPolicyIngestionSource) {
173+
Import-Module Az.Network -Force
174+
$ResourceIdSplit = $IngestionPolicyIngestionSource.ResourceId.Split(' ')
175+
foreach ($ResourceId in $ResourceIdSplit)
176+
{
177+
$Splits = $ResourceId -split "/"
178+
$cktsub = $Splits[2]
179+
$cktrg = $Splits[4]
180+
$cktname = $Splits[8]
181+
Set-AzContext $cktsub -ErrorVariable notPresent -ErrorAction SilentlyContinue
182+
$exrCircuit = Get-AzExpressRouteCircuit -Name $cktname -ResourceGroupName $cktrg
183+
$bandwidthInGbps = $exrCircuit.BandwidthInGbps
184+
$bandwidthInMbps = $exrCircuit.ServiceProviderProperties.BandwidthInMbps
185+
186+
if ($bandwidthInGbps -and ($bandwidthInGbps -lt 1)) {
187+
throw "CollectorPolicy can not be created because circuit has bandwidth less than 1G. Circuit size with a bandwidth of 1G or more is supported."
188+
}
189+
190+
if ($bandwidthInMbps -and ($bandwidthInMbps -lt 1000)) {
191+
throw "CollectorPolicy can not be created because circuit has bandwidth less than 1G. Circuit size with a bandwidth of 1G or more is supported."
192+
}
193+
}
185194
}
186-
195+
Set-AzContext $SubscriptionId -ErrorVariable notPresent -ErrorAction SilentlyContinue
196+
$PSBoundParameters.Add('IngestionPolicyIngestionSource', $IngestionPolicyIngestionSource)
187197
Az.NetworkFunction.internal\New-AzNetworkFunctionCollectorPolicy @PSBoundParameters
188198
}
189199
}

src/NetworkFunction/NetworkFunction.Autorest/custom/Update-AzNetworkFunctionCollectorPolicy.ps1

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -173,23 +173,33 @@ process {
173173
$null = $PSBoundParameters.Remove('WhatIf')
174174
$null = $PSBoundParameters.Remove('Confirm')
175175
$null = $PSBoundParameters.Remove('Location')
176-
$rg = $PSBoundParameters.ResourceGroupName
177176

178177
# 2. Ensure exr circuit bandwidth 1G or more
179-
$cktname = $IngestionPolicyIngestionSource.ResourceId | Where {$IngestionPolicyIngestionSource.ResourceId -match "/*subscriptions/(?<subid>.*)/resourceGroups/(?<rgname>.*)/providers/Microsoft.Network/expressRouteCircuits/(?<circuitname>.*)"} | Foreach {$Matches['circuitname']}
180-
Import-Module Az.Network -Force
181-
$exrCircuit = Get-AzExpressRouteCircuit -Name $cktname -ResourceGroupName $rg
182-
$bandwidthInGbps = $exrCircuit.BandwidthInGbps
183-
$bandwidthInMbps = $exrCircuit.ServiceProviderProperties.BandwidthInMbps
184-
185-
if ($bandwidthInGbps -and ($bandwidthInGbps -lt 1)) {
186-
throw "CollectorPolicy can not be updated because circuit has bandwidth less than 1G. Circuit size with a bandwidth of 1G or more is supported."
187-
}
188-
189-
if ($bandwidthInMbps -and ($bandwidthInMbps -lt 1000)) {
190-
throw "CollectorPolicy can not be updated because circuit has bandwidth less than 1G. Circuit size with a bandwidth of 1G or more is supported."
178+
if ($hasIngestionPolicyIngestionSource) {
179+
Import-Module Az.Network -Force
180+
# Ensure exr circuit bandwidth 1G or more
181+
$ResourceIdSplit = $IngestionPolicyIngestionSource.ResourceId.Split(' ')
182+
foreach ($ResourceId in $ResourceIdSplit)
183+
{
184+
$Splits = $ResourceId -split "/"
185+
$cktsub = $Splits[2]
186+
$cktrg = $Splits[4]
187+
$cktname = $Splits[8]
188+
Set-AzContext $cktsub -ErrorVariable notPresent -ErrorAction SilentlyContinue
189+
$exrCircuit = Get-AzExpressRouteCircuit -Name $cktname -ResourceGroupName $cktrg
190+
$bandwidthInGbps = $exrCircuit.BandwidthInGbps
191+
$bandwidthInMbps = $exrCircuit.ServiceProviderProperties.BandwidthInMbps
192+
193+
if ($bandwidthInGbps -and ($bandwidthInGbps -lt 1)) {
194+
throw "CollectorPolicy can not be updated because circuit has bandwidth less than 1G. Circuit size with a bandwidth of 1G or more is supported."
195+
}
196+
197+
if ($bandwidthInMbps -and ($bandwidthInMbps -lt 1000)) {
198+
throw "CollectorPolicy can not be updated because circuit has bandwidth less than 1G. Circuit size with a bandwidth of 1G or more is supported."
199+
}
200+
}
191201
}
192-
202+
Set-AzContext $SubscriptionId -ErrorVariable notPresent -ErrorAction SilentlyContinue
193203
$cp = Get-AzNetworkFunctionCollectorPolicy @PSBoundParameters
194204

195205
# 3. PUT

src/NetworkFunction/NetworkFunction.Autorest/test/New-AzNetworkFunctionCollectorPolicy.Tests.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ Describe 'New-AzNetworkFunctionCollectorPolicy' {
2727
}
2828
}
2929

30+
It 'CreateExpanded2' {
31+
{
32+
{ New-AzNetworkFunctionCollectorPolicy -collectorpolicyname $env.collectorPolicyName -azuretrafficcollectorname $env.azureTrafficCollectorName -resourcegroupname $env.resourceGroup -location $env.location -IngestionPolicyIngestionSource @{ResourceId = $env.ResourceIdLessThan1G}, @{ResourceId = $env.ResourceId1G} -IngestionPolicyIngestionType $env.IngestionType } | Should -Throw -ExpectedMessage "CollectorPolicy can not be updated because circuit has bandwidth less than 1G. Circuit size with a bandwidth of 1G or more is supported."
33+
}
34+
}
35+
3036
It 'Create' {
3137
{
3238
{ New-AzNetworkFunctionCollectorPolicy -collectorpolicyname $env.collectorPolicyName -azuretrafficcollectorname $env.azureTrafficCollectorName -resourcegroupname $env.resourceGroup -location $env.location -IngestionPolicyIngestionSource @{ResourceId = $env.ResourceId1G} -IngestionPolicyIngestionType $env.IngestionType } | Should -Not -Throw

src/NetworkFunction/NetworkFunction.Autorest/test/Update-AzNetworkFunctionCollectorPolicy.Tests.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,10 @@ Describe 'Update-AzNetworkFunctionCollectorPolicy' {
2626
{ Update-AzNetworkFunctionCollectorPolicy -collectorpolicyname $env.collectorPolicyName -azuretrafficcollectorname $env.azureTrafficCollectorName -resourcegroupname $env.resourceGroup -location $env.location -IngestionPolicyIngestionSource @{ResourceId = $env.ResourceIdLessThan1G} -IngestionPolicyIngestionType $env.IngestionType } | Should Throw -ExpectedMessage "CollectorPolicy can not be updated because circuit has bandwidth less than 1G. Circuit size with a bandwidth of 1G or more is supported."
2727
}
2828
}
29+
30+
It 'UpdateExpanded2' {
31+
{
32+
{ Update-AzNetworkFunctionCollectorPolicy -collectorpolicyname $env.collectorPolicyName -azuretrafficcollectorname $env.azureTrafficCollectorName -resourcegroupname $env.resourceGroup -location $env.location -IngestionPolicyIngestionSource @{ResourceId = $env.ResourceIdLessThan1G}, @{ResourceId = $env.ResourceId1G} -IngestionPolicyIngestionType $env.IngestionType } | Should Throw -ExpectedMessage "CollectorPolicy can not be updated because circuit has bandwidth less than 1G. Circuit size with a bandwidth of 1G or more is supported."
33+
}
34+
}
2935
}

src/NetworkFunction/NetworkFunction/Az.NetworkFunction.psd1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Microsoft Corporation
55
#
6-
# Generated on: 23/04/2024
6+
# Generated on: 5/8/2024
77
#
88

99
@{
@@ -57,13 +57,13 @@ RequiredModules = @(@{ModuleName = 'Az.Accounts'; ModuleVersion = '2.19.0'; })
5757
RequiredAssemblies = 'NetworkFunction.Autorest/bin/Az.NetworkFunction.private.dll'
5858

5959
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
60-
# ScriptsToProcess = @()
60+
ScriptsToProcess = @()
6161

6262
# Type files (.ps1xml) to be loaded when importing this module
63-
# TypesToProcess = @()
63+
TypesToProcess = @()
6464

6565
# Format files (.ps1xml) to be loaded when importing this module
66-
FormatsToProcess = 'NetworkFunction.Autorest\Az.NetworkFunction.format.ps1xml'
66+
FormatsToProcess = 'NetworkFunction.Autorest/Az.NetworkFunction.format.ps1xml'
6767

6868
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
6969
NestedModules = @('NetworkFunction.Autorest/Az.NetworkFunction.psm1')
@@ -104,7 +104,7 @@ PrivateData = @{
104104
PSData = @{
105105

106106
# Tags applied to this module. These help with module discovery in online galleries.
107-
Tags = 'Azure','ResourceManager','ARM','PSModule','NetworkFunction'
107+
Tags = 'Azure', 'ResourceManager', 'ARM', 'PSModule', 'NetworkFunction'
108108

109109
# A URL to the license for this module.
110110
LicenseUri = 'https://aka.ms/azps-license'
@@ -130,7 +130,7 @@ PrivateData = @{
130130

131131
} # End of PSData hashtable
132132

133-
} # End of PrivateData hashtable
133+
} # End of PrivateData hashtable
134134

135135
# HelpInfo URI of this module
136136
# HelpInfoURI = ''

src/NetworkFunction/NetworkFunction/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Changed parsing logic in ATC custom cmdlet
2122

2223
## Version 0.1.3
2324
* Introduced secrets detection feature to safeguard sensitive data.

src/NetworkFunction/NetworkFunction/help/Get-AzNetworkFunctionCollectorPolicy.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ Gets the collector policy in a specified Traffic Collector
1515
### List (Default)
1616
```
1717
Get-AzNetworkFunctionCollectorPolicy -AzureTrafficCollectorName <String> -ResourceGroupName <String>
18-
[-SubscriptionId <String[]>] [-DefaultProfile <PSObject>]
18+
[-SubscriptionId <String[]>] [-DefaultProfile <PSObject>] [-ProgressAction <ActionPreference>]
1919
[<CommonParameters>]
2020
```
2121

2222
### Get
2323
```
2424
Get-AzNetworkFunctionCollectorPolicy -AzureTrafficCollectorName <String> -Name <String>
2525
-ResourceGroupName <String> [-SubscriptionId <String[]>] [-DefaultProfile <PSObject>]
26-
[<CommonParameters>]
26+
[-ProgressAction <ActionPreference>] [<CommonParameters>]
2727
```
2828

2929
### GetViaIdentity
3030
```
3131
Get-AzNetworkFunctionCollectorPolicy -InputObject <INetworkFunctionIdentity> [-DefaultProfile <PSObject>]
32-
[<CommonParameters>]
32+
[-ProgressAction <ActionPreference>] [<CommonParameters>]
3333
```
3434

3535
## DESCRIPTION
@@ -137,6 +137,21 @@ Accept pipeline input: False
137137
Accept wildcard characters: False
138138
```
139139
140+
### -ProgressAction
141+
{{ Fill ProgressAction Description }}
142+
143+
```yaml
144+
Type: System.Management.Automation.ActionPreference
145+
Parameter Sets: (All)
146+
Aliases: proga
147+
148+
Required: False
149+
Position: Named
150+
Default value: None
151+
Accept pipeline input: False
152+
Accept wildcard characters: False
153+
```
154+
140155
### -ResourceGroupName
141156
The name of the resource group.
142157

src/NetworkFunction/NetworkFunction/help/Get-AzNetworkFunctionTrafficCollector.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@ Gets the specified Azure Traffic Collector in a specified resource group
1515
### List (Default)
1616
```
1717
Get-AzNetworkFunctionTrafficCollector [-SubscriptionId <String[]>] [-DefaultProfile <PSObject>]
18-
[<CommonParameters>]
18+
[-ProgressAction <ActionPreference>] [<CommonParameters>]
1919
```
2020

2121
### Get
2222
```
2323
Get-AzNetworkFunctionTrafficCollector -Name <String> -ResourceGroupName <String> [-SubscriptionId <String[]>]
24-
[-DefaultProfile <PSObject>] [<CommonParameters>]
24+
[-DefaultProfile <PSObject>] [-ProgressAction <ActionPreference>] [<CommonParameters>]
2525
```
2626

2727
### List1
2828
```
2929
Get-AzNetworkFunctionTrafficCollector -ResourceGroupName <String> [-SubscriptionId <String[]>]
30-
[-DefaultProfile <PSObject>] [<CommonParameters>]
30+
[-DefaultProfile <PSObject>] [-ProgressAction <ActionPreference>] [<CommonParameters>]
3131
```
3232

3333
### GetViaIdentity
3434
```
3535
Get-AzNetworkFunctionTrafficCollector -InputObject <INetworkFunctionIdentity> [-DefaultProfile <PSObject>]
36-
[<CommonParameters>]
36+
[-ProgressAction <ActionPreference>] [<CommonParameters>]
3737
```
3838

3939
## DESCRIPTION
@@ -153,6 +153,21 @@ Accept pipeline input: False
153153
Accept wildcard characters: False
154154
```
155155
156+
### -ProgressAction
157+
{{ Fill ProgressAction Description }}
158+
159+
```yaml
160+
Type: System.Management.Automation.ActionPreference
161+
Parameter Sets: (All)
162+
Aliases: proga
163+
164+
Required: False
165+
Position: Named
166+
Default value: None
167+
Accept pipeline input: False
168+
Accept wildcard characters: False
169+
```
170+
156171
### -ResourceGroupName
157172
The name of the resource group.
158173

src/NetworkFunction/NetworkFunction/help/New-AzNetworkFunctionCollectorPolicy.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ New-AzNetworkFunctionCollectorPolicy -AzureTrafficCollectorName <String> -Name <
1818
[-EmissionPolicy <IEmissionPoliciesPropertiesFormat[]>]
1919
[-IngestionPolicyIngestionSource <IIngestionSourcesPropertiesFormat[]>]
2020
[-IngestionPolicyIngestionType <IngestionType>] [-Tag <Hashtable>] [-DefaultProfile <PSObject>] [-AsJob]
21-
[-NoWait] [-WhatIf] [-Confirm] [<CommonParameters>]
21+
[-NoWait] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
2222
```
2323

2424
## DESCRIPTION
@@ -201,6 +201,21 @@ Accept pipeline input: False
201201
Accept wildcard characters: False
202202
```
203203
204+
### -ProgressAction
205+
{{ Fill ProgressAction Description }}
206+
207+
```yaml
208+
Type: System.Management.Automation.ActionPreference
209+
Parameter Sets: (All)
210+
Aliases: proga
211+
212+
Required: False
213+
Position: Named
214+
Default value: None
215+
Accept pipeline input: False
216+
Accept wildcard characters: False
217+
```
218+
204219
### -ResourceGroupName
205220
The name of the resource group.
206221

src/NetworkFunction/NetworkFunction/help/New-AzNetworkFunctionTrafficCollector.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Creates or updates a Azure Traffic Collector resource
1515
```
1616
New-AzNetworkFunctionTrafficCollector -Name <String> -ResourceGroupName <String> [-SubscriptionId <String>]
1717
-Location <String> [-Tag <Hashtable>] [-DefaultProfile <PSObject>] [-AsJob] [-NoWait]
18-
[-WhatIf] [-Confirm] [<CommonParameters>]
18+
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
1919
```
2020

2121
## DESCRIPTION
@@ -119,6 +119,21 @@ Accept pipeline input: False
119119
Accept wildcard characters: False
120120
```
121121
122+
### -ProgressAction
123+
{{ Fill ProgressAction Description }}
124+
125+
```yaml
126+
Type: System.Management.Automation.ActionPreference
127+
Parameter Sets: (All)
128+
Aliases: proga
129+
130+
Required: False
131+
Position: Named
132+
Default value: None
133+
Accept pipeline input: False
134+
Accept wildcard characters: False
135+
```
136+
122137
### -ResourceGroupName
123138
The name of the resource group.
124139
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Docs
2+
This directory contains the documentation of the cmdlets for the `Az.NetworkFunction` module. To run documentation generation, use the `generate-help.ps1` script at the root module folder. Files in this folder will *always be overridden on regeneration*. To update documentation examples, please use the `..\examples` folder.
3+
4+
## Info
5+
- Modifiable: no
6+
- Generated: all
7+
- Committed: yes
8+
- Packaged: yes
9+
10+
## Details
11+
The process of documentation generation loads `Az.NetworkFunction` and analyzes the exported cmdlets from the module. It recognizes the [help comments](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_comment_based_help) that are generated into the scripts in the `..\exports` folder. Additionally, when writing custom cmdlets in the `..\custom` folder, you can use the help comments syntax, which decorate the exported scripts at build-time. The documentation examples are taken from the `..\examples` folder.

src/NetworkFunction/NetworkFunction/help/Remove-AzNetworkFunctionCollectorPolicy.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ Deletes a specified Collector Policy resource.
1616
```
1717
Remove-AzNetworkFunctionCollectorPolicy -AzureTrafficCollectorName <String> -Name <String>
1818
-ResourceGroupName <String> [-SubscriptionId <String>] [-DefaultProfile <PSObject>] [-AsJob] [-NoWait]
19-
[-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
19+
[-PassThru] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
2020
```
2121

2222
### DeleteViaIdentity
2323
```
2424
Remove-AzNetworkFunctionCollectorPolicy -InputObject <INetworkFunctionIdentity> [-DefaultProfile <PSObject>]
25-
[-AsJob] [-NoWait] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
25+
[-AsJob] [-NoWait] [-PassThru] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
2626
```
2727

2828
## DESCRIPTION
@@ -146,6 +146,21 @@ Accept pipeline input: False
146146
Accept wildcard characters: False
147147
```
148148
149+
### -ProgressAction
150+
{{ Fill ProgressAction Description }}
151+
152+
```yaml
153+
Type: System.Management.Automation.ActionPreference
154+
Parameter Sets: (All)
155+
Aliases: proga
156+
157+
Required: False
158+
Position: Named
159+
Default value: None
160+
Accept pipeline input: False
161+
Accept wildcard characters: False
162+
```
163+
149164
### -ResourceGroupName
150165
The name of the resource group.
151166

0 commit comments

Comments
 (0)