Add-AzureRmStorageAccountNetworkRule

Add IpRules or VirtualNetworkRules to the NetworkRule property of a Storage account

Warning

The AzureRM PowerShell module has been officially deprecated as of February 29, 2024. Users are advised to migrate from AzureRM to the Az PowerShell module to ensure continued support and updates.

Although the AzureRM module may still function, it's no longer maintained or supported, placing any continued use at the user's discretion and risk. Please refer to our migration resources for guidance on transitioning to the Az module.

Syntax

Add-AzureRmStorageAccountNetworkRule
   [-ResourceGroupName] <String>
   [-Name] <String>
   -VirtualNetworkResourceId <String[]>
   [-AsJob]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Add-AzureRmStorageAccountNetworkRule
   [-ResourceGroupName] <String>
   [-Name] <String>
   -IPRule <PSIpRule[]>
   [-AsJob]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Add-AzureRmStorageAccountNetworkRule
   [-ResourceGroupName] <String>
   [-Name] <String>
   -VirtualNetworkRule <PSVirtualNetworkRule[]>
   [-AsJob]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Add-AzureRmStorageAccountNetworkRule
   [-ResourceGroupName] <String>
   [-Name] <String>
   -IPAddressOrRange <String[]>
   [-AsJob]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

The Add-AzureRmStorageAccountNetworkRule cmdlet adds IpRules or VirtualNetworkRules to the NetworkRule property of a Storage account

Examples

Example 1: Add several IpRules with IPAddressOrRange

PS C:\>Add-AzureRMStorageAccountNetworkRule -ResourceGroupName "myResourceGroup" -Name "mystorageaccount" -IPAddressOrRange "10.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-AzureRmVirtualNetwork -ResourceGroupName "myResourceGroup" -Name "myvirtualnetwork" | Get-AzureRmVirtualNetworkSubnetConfig
PS C:\>Add-AzureRMStorageAccountNetworkRule -ResourceGroupName "myResourceGroup" -Name "mystorageaccount" -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-AzureRMStorageAccountNetworkRuleSet -ResourceGroupName "myResourceGroup" -Name "mystorageaccount1"
PS C:\> Add-AzureRMStorageAccountNetworkRule -ResourceGroupName "myResourceGroup" -Name "mystorageaccount2" -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-AzureRMStorageAccountNetworkRule -ResourceGroupName "myResourceGroup" -Name "mystorageaccount" -IPRule (@{IPAddressOrRange="10.0.0.0/24";Action="allow"},@{IPAddressOrRange="28.2.0.0/16";Action="allow"})

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

Parameters

-AsJob

Run cmdlet in the background

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

-Confirm

Prompts you for confirmation before running the cmdlet.

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

-DefaultProfile

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

Type:IAzureContextContainer
Aliases:AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-IPAddressOrRange

The Array of IpAddressOrRange, add IpRules with the input IpAddressOrRange and default Action Allow to NetworkRule Property.

Type:String[]
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-IPRule

The Array of IpRule objects to add to the NetworkRule Property.

Type:PSIpRule[]
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Name

Specifies the name of the Storage account.

Type:String
Aliases:StorageAccountName, AccountName
Position:1
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-ResourceGroupName

Specifies the name of the resource group contains the Storage account.

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-VirtualNetworkResourceId

The Array of VirtualNetworkResourceId, will add VirtualNetworkRule with input VirtualNetworkResourceId and default Action Allow to NetworkRule Property.

Type:String[]
Aliases:SubnetId, VirtualNetworkId
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-VirtualNetworkRule

The Array of VirtualNetworkRule objects to add to the NetworkRule Property.

Type:PSVirtualNetworkRule[]
Position:Named
Default value:None
Required:True
Accept pipeline input:True
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
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

String

PSIpRule[]

Parameters: IPRule (ByValue)

PSVirtualNetworkRule[]

Parameters: VirtualNetworkRule (ByValue)

Outputs

PSVirtualNetworkRule

PSIpRule