Edit

Share via


Add-AzStorageAccountNetworkRule

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

Syntax

NetWorkRuleString (Default)

Add-AzStorageAccountNetworkRule
    [-ResourceGroupName] <String>
    [-Name] <String>
    -VirtualNetworkResourceId <String[]>
    [-AsJob]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

IpRuleObject

Add-AzStorageAccountNetworkRule
    [-ResourceGroupName] <String>
    [-Name] <String>
    -IPRule <PSIpRule[]>
    [-AsJob]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

NetworkRuleObject

Add-AzStorageAccountNetworkRule
    [-ResourceGroupName] <String>
    [-Name] <String>
    -VirtualNetworkRule <PSVirtualNetworkRule[]>
    [-AsJob]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ResourceAccessRuleObject

Add-AzStorageAccountNetworkRule
    [-ResourceGroupName] <String>
    [-Name] <String>
    -ResourceAccessRule <PSResourceAccessRule[]>
    [-AsJob]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

IpRuleString

Add-AzStorageAccountNetworkRule
    [-ResourceGroupName] <String>
    [-Name] <String>
    -IPAddressOrRange <String[]>
    [-AsJob]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ResourceAccessRuleString

Add-AzStorageAccountNetworkRule
    [-ResourceGroupName] <String>
    [-Name] <String>
    -TenantId <String>
    -ResourceId <String>
    [-AsJob]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

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

Examples

Example 1: Add several IpRules with IPAddressOrRange

Add-AzStorageAccountNetworkRule -ResourceGroupName "myResourceGroup" -Name "mystorageaccount" -IPAddressOrRange "10.0.0.0/7","28.2.0.0/16"

This command add several IpRules with IPAddressOrRange.

Example 2: Add a VirtualNetworkRule with VirtualNetworkResourceID

$subnet = Get-AzVirtualNetwork -ResourceGroupName "myResourceGroup" -Name "myvirtualnetwork" | Get-AzVirtualNetworkSubnetConfig
Add-AzStorageAccountNetworkRule -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

$networkrule = Get-AzStorageAccountNetworkRuleSet -ResourceGroupName "myResourceGroup" -Name "mystorageaccount1"
Add-AzStorageAccountNetworkRule -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

Add-AzStorageAccountNetworkRule -ResourceGroupName "myResourceGroup" -Name "mystorageaccount" -IPRule (@{IPAddressOrRange="10.0.0.0/7";Action="allow"},@{IPAddressOrRange="28.2.0.0/16";Action="allow"})

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

Example 5: Add a resource access rule

Add-AzStorageAccountNetworkRule -ResourceGroupName "myResourceGroup" -Name "mystorageaccount" -TenantId $tenantId -ResourceId $ResourceId

This command adds a resource access rule with TenantId and ResourceId.

Example 6: Add all resource access rules of one storage account to another storage account

(Get-AzStorageAccountNetworkRuleSet -ResourceGroupName "myResourceGroup" -Name "mystorageaccount1").ResourceAccessRules | Add-AzStorageAccountNetworkRule -ResourceGroupName "myResourceGroup" -Name "mystorageaccount2"

This command gets all resource access rules from one storage account, and adds them to another storage account.

Parameters

-AsJob

Run cmdlet in the background

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DefaultProfile

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

Parameter properties

Type:IAzureContextContainer
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzContext, AzureRmContext, AzureCredential

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-IPAddressOrRange

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

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

IpRuleString
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-IPRule

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

Parameter properties

Type:

PSIpRule[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

IpRuleObject
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-Name

Specifies the name of the Storage account.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:StorageAccountName, AccountName

Parameter sets

(All)
Position:1
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-ResourceAccessRule

Storage Account NetworkRule ResourceAccessRules.

Parameter properties

Type:

PSResourceAccessRule[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ResourceAccessRuleObject
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-ResourceGroupName

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

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:0
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-ResourceId

Storage Account ResourceAccessRule ResourceId in string.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ResourceAccessRuleString
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-TenantId

Storage Account ResourceAccessRule TenantId in string.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ResourceAccessRuleString
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-VirtualNetworkResourceId

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

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:False
DontShow:False
Aliases:SubnetId, VirtualNetworkId

Parameter sets

NetWorkRuleString
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-VirtualNetworkRule

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

Parameter properties

Type:

PSVirtualNetworkRule[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

NetworkRuleObject
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-WhatIf

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

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

String

PSIpRule

PSVirtualNetworkRule

Outputs

PSVirtualNetworkRule

PSIpRule