Skip to content

Commit 61e0fce

Browse files
joshharrinJosh Harrington
andauthored
[ml] secure defaults for managed network and pna disabled (#36965)
* if user specifies managed network or pna disabled, associated resources should match * update changelog --------- Co-authored-by: Josh Harrington <[email protected]>
1 parent 523ee25 commit 61e0fce

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
lines changed

sdk/ml/azure-ai-ml/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## 1.20.0 (unreleased)
44

5+
### Features Added
6+
- When a workspace is created with `managed_network` enabled or has `public_network_access` set to disabled, the resources created with the workspace (Key Vault, Storage Account) will be set to have restricted network access settings. This is only applicable when the user does not specify existing resources.
7+
58
## 1.19.0 (2024-07-29)
69

710
### Feature Added

sdk/ml/azure-ai-ml/azure/ai/ml/_arm_deployments/arm_templates/workspace_base.json

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@
3939
"description": "Specifies the resource group name of the Azure Machine Learning workspace."
4040
}
4141
},
42+
"associatedResourcePNA": {
43+
"type": "string",
44+
"defaultValue": "Enabled",
45+
"allowedValues": [
46+
"Enabled",
47+
"Disabled"
48+
],
49+
"metadata": {
50+
"description": "Determines the PublicNetworkAccess mode of new workspace-associated resources provisioned alongside with workspace."
51+
}
52+
},
4253
"storageAccountOption": {
4354
"type": "string",
4455
"defaultValue": "new",
@@ -640,6 +651,10 @@
640651
}
641652
]
642653
},
654+
"networkAclsForManagedNetworkDependencies": {
655+
"defaultAction": "deny",
656+
"bypass": "AzureServices"
657+
},
643658
"privateEndpointSettings": {
644659
"name": "[concat(parameters('workspaceName'), '-PrivateEndpoint')]",
645660
"properties": {
@@ -706,7 +721,7 @@
706721
{
707722
"condition": "[and(variables('enablePE'), equals(parameters('storageAccountOption'), 'new'))]",
708723
"type": "Microsoft.Storage/storageAccounts",
709-
"apiVersion": "2019-04-01",
724+
"apiVersion": "2023-04-01",
710725
"name": "[parameters('storageAccountName')]",
711726
"tags": "[parameters('tagValues')]",
712727
"dependsOn": [
@@ -731,7 +746,8 @@
731746
},
732747
"supportsHttpsTrafficOnly": true,
733748
"allowBlobPublicAccess": false,
734-
"networkAcls": "[if(equals(parameters('storageAccountBehindVNet'), 'true'), variables('networkRuleSetBehindVNet'), json('null'))]",
749+
"networkAcls": "[if(equals(parameters('associatedResourcePNA'), 'Disabled'), variables('networkAclsForManagedNetworkDependencies'), if(equals(parameters('storageAccountBehindVNet'), 'true'), variables('networkRuleSetBehindVNet'), json('null')))]",
750+
"publicNetworkAccess": "[parameters('associatedResourcePNA')]",
735751
"isHnsEnabled": "[equals(parameters('kind'), 'featurestore')]",
736752
"minimumTlsVersion": "[if(equals(parameters('kind'), 'featurestore'), 'TLS1_2', 'TLS1_0')]"
737753
}
@@ -778,7 +794,7 @@
778794
{
779795
"condition": "[and(variables('enablePE'), equals(parameters('keyVaultOption'), 'new'))]",
780796
"type": "Microsoft.KeyVault/vaults",
781-
"apiVersion": "2019-09-01",
797+
"apiVersion": "2023-07-01",
782798
"tags": "[parameters('tagValues')]",
783799
"dependsOn": [
784800
"[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vnetName'), parameters('subnetName'))]"
@@ -793,7 +809,8 @@
793809
},
794810
"accessPolicies": [],
795811
"enableRbacAuthorization": true,
796-
"networkAcls": "[if(equals(parameters('keyVaultBehindVNet'), 'true'), variables('networkRuleSetBehindVNet'), json('null'))]"
812+
"networkAcls": "[if(equals(parameters('associatedResourcePNA'), 'Disabled'), variables('networkAclsForManagedNetworkDependencies'), if(equals(parameters('keyVaultBehindVNet'), 'true'), variables('networkRuleSetBehindVNet'), json('null')))]",
813+
"publicNetworkAccess": "[parameters('associatedResourcePNA')]"
797814
}
798815
},
799816
{

sdk/ml/azure-ai-ml/azure/ai/ml/_arm_deployments/arm_templates/workspace_param.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
"keyVaultResourceGroupName": {
3030
"value": ""
3131
},
32+
"associatedResourcePNA": {
33+
"value": "Enabled"
34+
},
3235
"storageAccountOption": {
3336
"value": "new"
3437
},

sdk/ml/azure-ai-ml/azure/ai/ml/operations/_workspace_operations_base.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,7 @@ def _populate_arm_parameters(self, workspace: Workspace, **kwargs: Any) -> Tuple
654654

655655
if workspace.public_network_access:
656656
_set_val(param["publicNetworkAccess"], workspace.public_network_access)
657+
_set_val(param["associatedResourcePNA"], workspace.public_network_access)
657658

658659
if workspace.system_datastores_auth_mode:
659660
_set_val(param["systemDatastoresAuthMode"], workspace.system_datastores_auth_mode)
@@ -756,6 +757,11 @@ def _populate_arm_parameters(self, workspace: Workspace, **kwargs: Any) -> Tuple
756757
managed_network = None
757758
if workspace.managed_network:
758759
managed_network = workspace.managed_network._to_rest_object()
760+
if workspace.managed_network.isolation_mode in [
761+
IsolationMode.ALLOW_INTERNET_OUTBOUND,
762+
IsolationMode.ALLOW_ONLY_APPROVED_OUTBOUND,
763+
]:
764+
_set_val(param["associatedResourcePNA"], "Disabled")
759765
else:
760766
managed_network = ManagedNetwork(isolation_mode=IsolationMode.DISABLED)._to_rest_object()
761767
_set_obj_val(param["managedNetwork"], managed_network)

0 commit comments

Comments
 (0)