Skip to content

Commit

Permalink
Migrate NetworkFunction from generation to main (Azure#24850)
Browse files Browse the repository at this point in the history
* Move NetworkFunction to main

* update ChangeLog

---------

Co-authored-by: YanaXu <[email protected]>
  • Loading branch information
azure-powershell-bot and YanaXu authored May 8, 2024
1 parent 224655f commit 6d0c570
Show file tree
Hide file tree
Showing 17 changed files with 248 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,23 +167,33 @@ param(
)

process {
$rg = $PSBoundParameters.ResourceGroupName

$hasIngestionPolicyIngestionSource = $PSBoundParameters.Remove('IngestionPolicyIngestionSource')
# Ensure exr circuit bandwidth 1G or more
$cktname = $IngestionPolicyIngestionSource.ResourceId | Where {$IngestionPolicyIngestionSource.ResourceId -match "/*subscriptions/(?<subid>.*)/resourceGroups/(?<rgname>.*)/providers/Microsoft.Network/expressRouteCircuits/(?<circuitname>.*)"} | Foreach {$Matches['circuitname']}
Import-Module Az.Network -Force
$exrCircuit = Get-AzExpressRouteCircuit -Name $cktname -ResourceGroupName $rg
$bandwidthInGbps = $exrCircuit.BandwidthInGbps
$bandwidthInMbps = $exrCircuit.ServiceProviderProperties.BandwidthInMbps

if ($bandwidthInGbps -and ($bandwidthInGbps -lt 1)) {
throw "CollectorPolicy can not be updated because circuit has bandwidth less than 1G. Circuit size with a bandwidth of 1G or more is supported."
}

if ($bandwidthInMbps -and ($bandwidthInMbps -lt 1000)) {
throw "CollectorPolicy can not be updated because circuit has bandwidth less than 1G. Circuit size with a bandwidth of 1G or more is supported."
if ($hasIngestionPolicyIngestionSource) {
Import-Module Az.Network -Force
$ResourceIdSplit = $IngestionPolicyIngestionSource.ResourceId.Split(' ')
foreach ($ResourceId in $ResourceIdSplit)
{
$Splits = $ResourceId -split "/"
$cktsub = $Splits[2]
$cktrg = $Splits[4]
$cktname = $Splits[8]
Set-AzContext $cktsub -ErrorVariable notPresent -ErrorAction SilentlyContinue
$exrCircuit = Get-AzExpressRouteCircuit -Name $cktname -ResourceGroupName $cktrg
$bandwidthInGbps = $exrCircuit.BandwidthInGbps
$bandwidthInMbps = $exrCircuit.ServiceProviderProperties.BandwidthInMbps

if ($bandwidthInGbps -and ($bandwidthInGbps -lt 1)) {
throw "CollectorPolicy can not be created because circuit has bandwidth less than 1G. Circuit size with a bandwidth of 1G or more is supported."
}

if ($bandwidthInMbps -and ($bandwidthInMbps -lt 1000)) {
throw "CollectorPolicy can not be created because circuit has bandwidth less than 1G. Circuit size with a bandwidth of 1G or more is supported."
}
}
}

Set-AzContext $SubscriptionId -ErrorVariable notPresent -ErrorAction SilentlyContinue
$PSBoundParameters.Add('IngestionPolicyIngestionSource', $IngestionPolicyIngestionSource)
Az.NetworkFunction.internal\New-AzNetworkFunctionCollectorPolicy @PSBoundParameters
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -173,23 +173,33 @@ process {
$null = $PSBoundParameters.Remove('WhatIf')
$null = $PSBoundParameters.Remove('Confirm')
$null = $PSBoundParameters.Remove('Location')
$rg = $PSBoundParameters.ResourceGroupName

# 2. Ensure exr circuit bandwidth 1G or more
$cktname = $IngestionPolicyIngestionSource.ResourceId | Where {$IngestionPolicyIngestionSource.ResourceId -match "/*subscriptions/(?<subid>.*)/resourceGroups/(?<rgname>.*)/providers/Microsoft.Network/expressRouteCircuits/(?<circuitname>.*)"} | Foreach {$Matches['circuitname']}
Import-Module Az.Network -Force
$exrCircuit = Get-AzExpressRouteCircuit -Name $cktname -ResourceGroupName $rg
$bandwidthInGbps = $exrCircuit.BandwidthInGbps
$bandwidthInMbps = $exrCircuit.ServiceProviderProperties.BandwidthInMbps

if ($bandwidthInGbps -and ($bandwidthInGbps -lt 1)) {
throw "CollectorPolicy can not be updated because circuit has bandwidth less than 1G. Circuit size with a bandwidth of 1G or more is supported."
}

if ($bandwidthInMbps -and ($bandwidthInMbps -lt 1000)) {
throw "CollectorPolicy can not be updated because circuit has bandwidth less than 1G. Circuit size with a bandwidth of 1G or more is supported."
if ($hasIngestionPolicyIngestionSource) {
Import-Module Az.Network -Force
# Ensure exr circuit bandwidth 1G or more
$ResourceIdSplit = $IngestionPolicyIngestionSource.ResourceId.Split(' ')
foreach ($ResourceId in $ResourceIdSplit)
{
$Splits = $ResourceId -split "/"
$cktsub = $Splits[2]
$cktrg = $Splits[4]
$cktname = $Splits[8]
Set-AzContext $cktsub -ErrorVariable notPresent -ErrorAction SilentlyContinue
$exrCircuit = Get-AzExpressRouteCircuit -Name $cktname -ResourceGroupName $cktrg
$bandwidthInGbps = $exrCircuit.BandwidthInGbps
$bandwidthInMbps = $exrCircuit.ServiceProviderProperties.BandwidthInMbps

if ($bandwidthInGbps -and ($bandwidthInGbps -lt 1)) {
throw "CollectorPolicy can not be updated because circuit has bandwidth less than 1G. Circuit size with a bandwidth of 1G or more is supported."
}

if ($bandwidthInMbps -and ($bandwidthInMbps -lt 1000)) {
throw "CollectorPolicy can not be updated because circuit has bandwidth less than 1G. Circuit size with a bandwidth of 1G or more is supported."
}
}
}

Set-AzContext $SubscriptionId -ErrorVariable notPresent -ErrorAction SilentlyContinue
$cp = Get-AzNetworkFunctionCollectorPolicy @PSBoundParameters

# 3. PUT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ Describe 'New-AzNetworkFunctionCollectorPolicy' {
}
}

It 'CreateExpanded2' {
{
{ 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."
}
}

It 'Create' {
{
{ New-AzNetworkFunctionCollectorPolicy -collectorpolicyname $env.collectorPolicyName -azuretrafficcollectorname $env.azureTrafficCollectorName -resourcegroupname $env.resourceGroup -location $env.location -IngestionPolicyIngestionSource @{ResourceId = $env.ResourceId1G} -IngestionPolicyIngestionType $env.IngestionType } | Should -Not -Throw
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@ Describe 'Update-AzNetworkFunctionCollectorPolicy' {
{ 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."
}
}

It 'UpdateExpanded2' {
{
{ 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."
}
}
}
12 changes: 6 additions & 6 deletions src/NetworkFunction/NetworkFunction/Az.NetworkFunction.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: Microsoft Corporation
#
# Generated on: 23/04/2024
# Generated on: 5/8/2024
#

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

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

# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()
TypesToProcess = @()

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

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

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

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

} # End of PSData hashtable

} # End of PrivateData hashtable
} # End of PrivateData hashtable

# HelpInfo URI of this module
# HelpInfoURI = ''
Expand Down
1 change: 1 addition & 0 deletions src/NetworkFunction/NetworkFunction/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
* Changed parsing logic in ATC custom cmdlet

## Version 0.1.3
* Introduced secrets detection feature to safeguard sensitive data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ Gets the collector policy in a specified Traffic Collector
### List (Default)
```
Get-AzNetworkFunctionCollectorPolicy -AzureTrafficCollectorName <String> -ResourceGroupName <String>
[-SubscriptionId <String[]>] [-DefaultProfile <PSObject>]
[-SubscriptionId <String[]>] [-DefaultProfile <PSObject>] [-ProgressAction <ActionPreference>]
[<CommonParameters>]
```

### Get
```
Get-AzNetworkFunctionCollectorPolicy -AzureTrafficCollectorName <String> -Name <String>
-ResourceGroupName <String> [-SubscriptionId <String[]>] [-DefaultProfile <PSObject>]
[<CommonParameters>]
[-ProgressAction <ActionPreference>] [<CommonParameters>]
```

### GetViaIdentity
```
Get-AzNetworkFunctionCollectorPolicy -InputObject <INetworkFunctionIdentity> [-DefaultProfile <PSObject>]
[<CommonParameters>]
[-ProgressAction <ActionPreference>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -137,6 +137,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -ProgressAction
{{ Fill ProgressAction Description }}
```yaml
Type: System.Management.Automation.ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -ResourceGroupName
The name of the resource group.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ Gets the specified Azure Traffic Collector in a specified resource group
### List (Default)
```
Get-AzNetworkFunctionTrafficCollector [-SubscriptionId <String[]>] [-DefaultProfile <PSObject>]
[<CommonParameters>]
[-ProgressAction <ActionPreference>] [<CommonParameters>]
```

### Get
```
Get-AzNetworkFunctionTrafficCollector -Name <String> -ResourceGroupName <String> [-SubscriptionId <String[]>]
[-DefaultProfile <PSObject>] [<CommonParameters>]
[-DefaultProfile <PSObject>] [-ProgressAction <ActionPreference>] [<CommonParameters>]
```

### List1
```
Get-AzNetworkFunctionTrafficCollector -ResourceGroupName <String> [-SubscriptionId <String[]>]
[-DefaultProfile <PSObject>] [<CommonParameters>]
[-DefaultProfile <PSObject>] [-ProgressAction <ActionPreference>] [<CommonParameters>]
```

### GetViaIdentity
```
Get-AzNetworkFunctionTrafficCollector -InputObject <INetworkFunctionIdentity> [-DefaultProfile <PSObject>]
[<CommonParameters>]
[-ProgressAction <ActionPreference>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -153,6 +153,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -ProgressAction
{{ Fill ProgressAction Description }}
```yaml
Type: System.Management.Automation.ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -ResourceGroupName
The name of the resource group.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ New-AzNetworkFunctionCollectorPolicy -AzureTrafficCollectorName <String> -Name <
[-EmissionPolicy <IEmissionPoliciesPropertiesFormat[]>]
[-IngestionPolicyIngestionSource <IIngestionSourcesPropertiesFormat[]>]
[-IngestionPolicyIngestionType <IngestionType>] [-Tag <Hashtable>] [-DefaultProfile <PSObject>] [-AsJob]
[-NoWait] [-WhatIf] [-Confirm] [<CommonParameters>]
[-NoWait] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -201,6 +201,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -ProgressAction
{{ Fill ProgressAction Description }}
```yaml
Type: System.Management.Automation.ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -ResourceGroupName
The name of the resource group.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Creates or updates a Azure Traffic Collector resource
```
New-AzNetworkFunctionTrafficCollector -Name <String> -ResourceGroupName <String> [-SubscriptionId <String>]
-Location <String> [-Tag <Hashtable>] [-DefaultProfile <PSObject>] [-AsJob] [-NoWait]
[-WhatIf] [-Confirm] [<CommonParameters>]
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -119,6 +119,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -ProgressAction
{{ Fill ProgressAction Description }}
```yaml
Type: System.Management.Automation.ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -ResourceGroupName
The name of the resource group.
Expand Down
11 changes: 11 additions & 0 deletions src/NetworkFunction/NetworkFunction/help/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Docs
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.

## Info
- Modifiable: no
- Generated: all
- Committed: yes
- Packaged: yes

## Details
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.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ Deletes a specified Collector Policy resource.
```
Remove-AzNetworkFunctionCollectorPolicy -AzureTrafficCollectorName <String> -Name <String>
-ResourceGroupName <String> [-SubscriptionId <String>] [-DefaultProfile <PSObject>] [-AsJob] [-NoWait]
[-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
[-PassThru] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### DeleteViaIdentity
```
Remove-AzNetworkFunctionCollectorPolicy -InputObject <INetworkFunctionIdentity> [-DefaultProfile <PSObject>]
[-AsJob] [-NoWait] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
[-AsJob] [-NoWait] [-PassThru] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -146,6 +146,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -ProgressAction
{{ Fill ProgressAction Description }}
```yaml
Type: System.Management.Automation.ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -ResourceGroupName
The name of the resource group.
Expand Down
Loading

0 comments on commit 6d0c570

Please sign in to comment.