NetworkAcls Class

Network Access Setting for Workspace

Inheritance
azure.ai.ml.entities._mixins.RestTranslatableMixin
NetworkAcls

Constructor

NetworkAcls(*, default_action: str = 'Allow', ip_rules: List[IPRule] | None = None)

Parameters

Name Description
default_action
Required
str

Specifies the default action when no IP rules are matched.

ip_rules
Required

Rules governing the accessibility of a resource from a specific IP address or IP range.

Keyword-Only Parameters

Name Description
default_action
Default value: Allow
ip_rules
Required

Examples

Configuring one of the three public network access settings.


   from azure.ai.ml.entities import DefaultActionType, IPRule, NetworkAcls

   # Get existing workspace
   ws = ml_client.workspaces.get("test-ws1")

   # 1. Enabled from all networks
   # Note: default_action should be set to 'Allow', allowing all access.
   ws.public_network_access = "Enabled"
   ws.network_acls = NetworkAcls(default_action=DefaultActionType.ALLOW, ip_rules=[])
   updated_ws = ml_client.workspaces.begin_update(workspace=ws).result()

   # 2. Enabled from selected IP addresses
   # Note: default_action should be set to 'Deny', allowing only specified IPs/ranges
   ws.public_network_access = "Enabled"
   ws.network_acls = NetworkAcls(
       default_action=DefaultActionType.DENY,
       ip_rules=[IPRule(value="103.248.19.87/32"), IPRule(value="103.248.19.86/32")],
   )
   updated_ws = ml_client.workspaces.begin_update(workspace=ws).result()

   # 3. Disabled
   # NetworkAcls IP Rules will reset
   ws.public_network_access = "Disabled"
   updated_ws = ml_client.workspaces.begin_update(workspace=ws).result()