Edit

New-AzKeyVaultManagedHsmNetworkRuleSetObject

Create an in‑memory Managed HSM network rule set object for use with New/Update cmdlets.

Syntax

Default (Default)

New-AzKeyVaultManagedHsmNetworkRuleSetObject
    [-DefaultAction <PSManagedHsmNetworkRuleDefaultActionEnum>]
    [-Bypass <PSManagedHsmNetworkRuleBypassEnum>]
    [-IpAddressRange <String[]>]
    [-VirtualNetworkResourceId <String[]>]
    [-DefaultProfile <IAzureContextContainer>]
    [-SubscriptionId <String>]
    [<CommonParameters>]

Description

Builds a PSManagedHsmNetworkRuleSet object that can be passed to New-AzKeyVaultManagedHsm via the -NetworkRuleSet parameter to configure the firewall at creation time. You can also supply the object to update cmdlets (or inspect it before applying). Virtual network rules are presently not supported for Managed HSM; supplying -VirtualNetworkResourceId has no effect and may be ignored in future.

If you specify any IP ranges you should set -DefaultAction Deny; the Managed HSM service will reject an Allow + IP combination.

Examples

Example 1: Create a rule set object with Deny and one IP

$ruleSet = New-AzKeyVaultManagedHsmNetworkRuleSetObject -DefaultAction Deny -IpAddressRange 203.0.113.0/24
New-AzKeyVaultManagedHsm -Name myHsm -ResourceGroupName myRg -Location eastus -Administrator $adminIds -SoftDeleteRetentionInDays 7 -NetworkRuleSet $ruleSet
$ruleset

DefaultAction        Bypass IpAddressRanges  VirtualNetworkResourceIds
-------------        ------ ---------------  -------------------------
         Deny AzureServices {203.0.113.0/24}


Name           Resource Group Name Location SKU        ProvisioningState Security Domain ActivationStatus
----           ------------------- -------- ---        ----------------- --------------------------------
mhsm1814428918 kv-mhsm-rg          eastus   StandardB1 Succeeded         NotActivated


$hsm.OriginalManagedHsm.Properties.NetworkAcls
Bypass              : AzureServices
DefaultAction       : Deny
IPRules             : {203.0.113.0/24}
ServiceTags         : {}
VirtualNetworkRules : {}

Creates a Managed HSM with firewall enabled and one allowed CIDR.

Example 2: Create an allow-all rule set (no IP rules)

$open = New-AzKeyVaultManagedHsmNetworkRuleSetObject -DefaultAction Allow
New-AzKeyVaultManagedHsm -Name myOpenHsm -ResourceGroupName myRg -Location eastus -Administrator $adminIds -SoftDeleteRetentionInDays 7 -NetworkRuleSet $open
DefaultAction        Bypass IpAddressRanges VirtualNetworkResourceIds
-------------        ------ --------------- -------------------------
        Allow AzureServices



Name           Resource Group Name Location SKU        ProvisioningState Security Domain ActivationStatus
----           ------------------- -------- ---        ----------------- --------------------------------
mhsm1814428918 kv-mhsm-rg          eastus   StandardB1 Succeeded         NotActivated


$hsm.OriginalManagedHsm.Properties.NetworkAcls
Bypass              : AzureServices
DefaultAction       : Allow
IPRules             : {}
ServiceTags         : {}
VirtualNetworkRules : {}

Creates an HSM with firewall open to public networks (subject to other settings like Private Endpoints or PublicNetworkAccess).

Example 3: Use AzureServices bypass while restricting IPs

$restricted = New-AzKeyVaultManagedHsmNetworkRuleSetObject -DefaultAction Deny -Bypass AzureServices -IpAddressRange 198.51.100.0/25,203.0.113.10/32
New-AzKeyVaultManagedHsm -Name mySecureHsm -ResourceGroupName myRg -Location eastus -Administrator $adminIds -SoftDeleteRetentionInDays 7 -NetworkRuleSet $restricted
DefaultAction        Bypass IpAddressRanges                    VirtualNetworkResourceIds
-------------        ------ ---------------                    -------------------------
         Deny AzureServices {198.51.100.0/25, 203.0.113.10/32}



Name           Resource Group Name Location SKU        ProvisioningState Security Domain ActivationStatus
----           ------------------- -------- ---        ----------------- --------------------------------
mhsm1814428918 kv-mhsm-rg          eastus   StandardB1 Succeeded         NotActivated


$hsm.OriginalManagedHsm.Properties.NetworkAcls
Bypass              : AzureServices
DefaultAction       : Deny
IPRules             : {198.51.100.0/25, 203.0.113.10/32}
ServiceTags         : {}
VirtualNetworkRules : {}

Allows only the listed IPs plus trusted Azure services.

Parameters

-Bypass

Specifies bypass of network rule.

Parameter properties

Type:PSManagedHsmNetworkRuleBypassEnum
Default value:None
Accepted values:None, AzureServices
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

-DefaultAction

Specifies default action of network rule.

Parameter properties

Type:PSManagedHsmNetworkRuleDefaultActionEnum
Default value:None
Accepted values:Allow, Deny
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

-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

-IpAddressRange

Optional array of CIDR IP ranges. When provided you should also set -DefaultAction Deny.

Parameter properties

Type:

String[]

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

-SubscriptionId

The ID of the subscription.

By default, cmdlets are executed in the subscription that is set in the current context. If the user specifies another subscription, the current cmdlet is executed in the subscription specified by the user.

Overriding subscriptions only take effect during the lifecycle of the current cmdlet. It does not change the subscription in the context, and does not affect subsequent cmdlets.

Parameter properties

Type:String
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:True
Value from remaining arguments:False

-VirtualNetworkResourceId

Specifies allowed virtual network resource identifier of network rule.

Parameter properties

Type:

String[]

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

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

Outputs

PSManagedHsmNetworkRuleSet