Skip to content

Commit a7cb46a

Browse files
authored
set storage account access to identity-based for feature store creation (#35941)
* set storage account access to identity-based for feature store creation * revert * add workspace default storage role assignment
1 parent 984542f commit a7cb46a

File tree

4 files changed

+49
-1
lines changed

4 files changed

+49
-1
lines changed

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

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,13 @@
599599
"description": "Serverless compute settings to be used for the workspace."
600600
}
601601
},
602+
"system_datastore_auth_mode": {
603+
"type": "string",
604+
"defaultValue": "",
605+
"metadata": {
606+
"description": "Settings to control workspace storage account access auth type"
607+
}
608+
},
602609
"endpoint_resource_id": {
603610
"type": "string",
604611
"defaultValue": "null",
@@ -831,6 +838,7 @@
831838
"SearchAccountArmId": "[parameters('encryption_search_resourceid')]"
832839
},
833840
"primaryUserAssignedIdentity": "[parameters('primaryUserAssignedIdentity')]",
841+
"systemDatastoresAuthMode": "[parameters('system_datastore_auth_mode')]",
834842
"managedNetwork": "[parameters('managedNetwork')]",
835843
"featureStoreSettings": {
836844
"computeruntime": {
@@ -895,7 +903,7 @@
895903
{
896904
"condition":"[equals(parameters('kind'), 'featurestore')]",
897905
"type": "Microsoft.Resources/deployments",
898-
"apiVersion": "2022-05-01",
906+
"apiVersion": "2024-03-01",
899907
"name": "[concat(parameters('workspaceName'), '-deploy-feature-store')]",
900908
"dependsOn": [
901909
"[resourceId('Microsoft.MachineLearningServices/workspaces', parameters('workspaceName'))]",
@@ -945,6 +953,7 @@
945953
"SearchAccountArmId": "[parameters('encryption_search_resourceid')]"
946954
},
947955
"primaryUserAssignedIdentity": "[parameters('primaryUserAssignedIdentity')]",
956+
"systemDatastoresAuthMode": "[parameters('system_datastore_auth_mode')]",
948957
"managedNetwork": "[parameters('managedNetwork')]",
949958
"featureStoreSettings": {
950959
"computeruntime": {
@@ -1056,6 +1065,38 @@
10561065
}
10571066
}
10581067
},
1068+
{
1069+
"condition": "[and(equals(parameters('kind'), 'featurestore'), equals(parameters('grant_materialization_permissions'), 'true'), not(equals(parameters('materializationIdentityOption'), 'none')))]",
1070+
"type": "Microsoft.Resources/deployments",
1071+
"name": "[concat('ws-storage-role-assign-', guid(variables('materializationIdentity'), variables('storageAccount'), 'storage blob data contributor'))]",
1072+
"apiVersion": "2020-06-01",
1073+
"dependsOn": [
1074+
"[resourceId('Microsoft.MachineLearningServices/workspaces', parameters('workspaceName'))]",
1075+
"[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('materialization_identity_name'))]"
1076+
],
1077+
"resourceGroup": "[parameters('storageAccountResourceGroupName')]",
1078+
"properties": {
1079+
"mode": "Incremental",
1080+
"template": {
1081+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
1082+
"contentVersion": "1.0.0.0",
1083+
"resources": [
1084+
{
1085+
"type": "Microsoft.Authorization/roleAssignments",
1086+
"apiVersion": "2022-04-01",
1087+
"name": "[guid(variables('materializationIdentity'), variables('storageAccount'), 'storage blob data contributor')]",
1088+
"scope": "[variables('storageAccount')]",
1089+
"location": "[parameters('location')]",
1090+
"properties": {
1091+
"roleDefinitionId": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'ba92f5b4-2d11-453d-a403-e96b0029c9fe')]",
1092+
"principalId": "[if(not(equals(parameters('materializationIdentityOption'), 'none')), reference(variables('materializationIdentity'), '2023-01-31').principalId, '')]",
1093+
"principalType": "ServicePrincipal"
1094+
}
1095+
}
1096+
]
1097+
}
1098+
}
1099+
},
10591100
{
10601101
"condition": "[and(variables('enablePE'), not(equals(parameters('privateEndpointType'), 'none')))]",
10611102
"type": "Microsoft.Resources/deployments",

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
@@ -197,6 +197,9 @@
197197
"serverless_compute_settings": {
198198
"value": {}
199199
},
200+
"system_datastore_auth_mode": {
201+
"value": ""
202+
},
200203
"endpoint_resource_id": {
201204
"value": "null"
202205
},

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

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

685685
from azure.ai.ml._utils._arm_id_utils import AzureResourceId, AzureStorageContainerResourceId
686686

687+
# set workspace storage account access auth type to identity-based
688+
_set_val(param["system_datastore_auth_mode"], "identity")
689+
687690
if offline_store_target:
688691
arm_id = AzureStorageContainerResourceId(offline_store_target)
689692
_set_val(param["offlineStoreStorageAccountOption"], "existing")

sdk/ml/azure-ai-ml/tests/workspace/unittests/test_workspace_operations_base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ def test_populate_feature_store_arm_parameters(
380380
assert param["online_store_resource_group_name"]["value"] is None
381381
assert param["online_store_subscription_id"]["value"] is None
382382
assert param["online_store_connection_name"]["value"] is None
383+
assert param["system_datastore_auth_mode"]["value"] == "identity"
383384

384385
# test create feature store with materialization identity
385386
mock_materialization_identity_resource_id = (

0 commit comments

Comments
 (0)