Add-AzCognitiveServicesAccountNetworkRule

Add IpRules or VirtualNetworkRules to the NetworkRule property of a Cognitive Services account

Syntax

Add-AzCognitiveServicesAccountNetworkRule
   [-ResourceGroupName] <String>
   [-Name] <String>
   -VirtualNetworkResourceId <String[]>
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Add-AzCognitiveServicesAccountNetworkRule
   [-ResourceGroupName] <String>
   [-Name] <String>
   -IpRule <PSIpRule[]>
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Add-AzCognitiveServicesAccountNetworkRule
   [-ResourceGroupName] <String>
   [-Name] <String>
   -VirtualNetworkRule <PSVirtualNetworkRule[]>
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Add-AzCognitiveServicesAccountNetworkRule
   [-ResourceGroupName] <String>
   [-Name] <String>
   -IpAddressOrRange <String[]>
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

The Add-AzCognitiveServicesAccountNetworkRule cmdlet adds IpRules or VirtualNetworkRules to the NetworkRule property of a Cognitive Services account

Examples

Example 1: Add several IpRules with IpAddressOrRange

PS C:\>Add-AzCognitiveServicesAccountNetworkRule -ResourceGroupName "myResourceGroup" -Name "myaccount" -IpAddressOrRange "200.0.0.0/24","28.2.0.0/16"

This command add several IpRules with IpAddressOrRange.

Example 2: Add a VirtualNetworkRule with VirtualNetworkResourceID

PS C:\>$subnet = Get-AzVirtualNetwork -ResourceGroupName "myResourceGroup" -Name "myvirtualnetwork" | Get-AzVirtualNetworkSubnetConfig
PS C:\>Add-AzCognitiveServicesAccountNetworkRule -ResourceGroupName "myResourceGroup" -Name "myaccount" -VirtualNetworkResourceId $subnet[0].Id

This command add a VirtualNetworkRule with VirtualNetworkResourceID.

Example 3: Add VirtualNetworkRules with VirtualNetworkRule Objects from another account

PS C:\> $networkrule = Get-AzCognitiveServicesAccountNetworkRuleSet -ResourceGroupName "myResourceGroup" -Name "myaccount1"
PS C:\> Add-AzCognitiveServicesAccountNetworkRule -ResourceGroupName "myResourceGroup" -Name "myaccount2" -VirtualNetworkRule $networkrule.VirtualNetworkRules

This command add VirtualNetworkRules with VirtualNetworkRule Objects from another account.

Example 4: Add several IpRule with IpRule objects, input with JSON

PS C:\>Add-AzCognitiveServicesAccountNetworkRule -ResourceGroupName "myResourceGroup" -Name "myaccount" -IpRule (@{IpAddressOrRange="200.0.0.0/24"},@{IpAddressOrRange="28.2.0.0/16"})

This command add several IpRule with IpRule objects, input with JSON.

Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-DefaultProfile

The credentials, account, tenant, and subscription used for communication with Azure.

Type:Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-IpAddressOrRange

Cognitive Services Account NetworkRule IpRules IpAddressOrRange in string.

Type:System.String[]
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-IpRule

Cognitive Services Account NetworkRule IpRules.

Type:Microsoft.Azure.Commands.Management.CognitiveServices.Models.PSIpRule[]
Position:Named
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-Name

Cognitive Services Account Name.

Type:String
Aliases:CognitiveServicesAccountName, AccountName
Position:1
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-ResourceGroupName

Resource Group Name.

Type:String
Position:0
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-VirtualNetworkResourceId

Cognitive Services Account NetworkRule VirtualNetworkRules VirtualNetworkResourceId in string.

Type:System.String[]
Aliases:SubnetId, VirtualNetworkId
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-VirtualNetworkRule

Cognitive Services Account NetworkRule VirtualNetworkRules.

Type:Microsoft.Azure.Commands.Management.CognitiveServices.Models.PSVirtualNetworkRule[]
Position:Named
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Inputs

String

Microsoft.Azure.Commands.Management.CognitiveServices.Models.PSIpRule[]

Microsoft.Azure.Commands.Management.CognitiveServices.Models.PSVirtualNetworkRule[]

Outputs

Microsoft.Azure.Commands.Management.CognitiveServices.Models.PSVirtualNetworkRule

Microsoft.Azure.Commands.Management.CognitiveServices.Models.PSIpRule