Skip to content

Commit 6bf46ae

Browse files
authored
re-add workspace default app insights, fix project ARM template (#36325) (#36336)
* re-add workspace default app insights, fix project ARM template * move cl lines to right place * cl wording
1 parent ab52135 commit 6bf46ae

File tree

7 files changed

+81
-9
lines changed

7 files changed

+81
-9
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Expose `public_ip_address` in `AmlComputeNodeInfo`, to get the public ip address
99
### Bugs Fixed
1010
- InputTypes exported in constants module
1111
- WorkspaceConnection tags are now listed as deprecated, and the erroneously-deprecated metadata field has been un-deprecated and added as a initialization field. These two fields still point to the same underlying object property, and actual API usage of this value is unchanged.
12+
- Workspace Create operation works without an application insights being provided, and creates a default appIn resource for normal workspaces in that case.
13+
- Project create operations works in general.
1214

1315
### Other Changes
1416
- WorkspaceConnections are officially GA'd and no longer experimental. But its much newer subclasses remain experimental.

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

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,11 @@
119119
},
120120
"applicationInsightsOption": {
121121
"type": "string",
122-
"defaultValue": "none",
122+
"defaultValue": "new",
123123
"allowedValues": [
124-
"none",
125-
"existing"
124+
"new",
125+
"existing",
126+
"none"
126127
],
127128
"metadata": {
128129
"description": "Determines whether or not new ApplicationInsights should be provisioned."
@@ -795,6 +796,34 @@
795796
"networkAcls": "[if(equals(parameters('keyVaultBehindVNet'), 'true'), variables('networkRuleSetBehindVNet'), json('null'))]"
796797
}
797798
},
799+
{
800+
"condition": "[and(variables('enablePE'), equals(parameters('applicationInsightsOption'), 'new'))]",
801+
"type": "Microsoft.OperationalInsights/workspaces",
802+
"tags": "[parameters('tagValues')]",
803+
"apiVersion": "2020-08-01",
804+
"name": "[parameters('logAnalyticsName')]",
805+
"location": "[if(or(equals(toLower(parameters('applicationInsightsLocation')),'westcentralus'), equals(toLower(parameters('applicationInsightsLocation')),'eastus2euap'), equals(toLower(parameters('applicationInsightsLocation')),'centraluseuap')),'southcentralus', parameters('applicationInsightsLocation'))]",
806+
"kind": "web",
807+
"properties": {
808+
"Application_Type": "web"
809+
}
810+
},
811+
{
812+
"condition": "[and(variables('enablePE'), equals(parameters('applicationInsightsOption'), 'new'))]",
813+
"type": "Microsoft.Insights/components",
814+
"tags": "[parameters('tagValues')]",
815+
"apiVersion": "2020-02-02-preview",
816+
"name": "[parameters('applicationInsightsName')]",
817+
"location": "[if(or(equals(toLower(parameters('applicationInsightsLocation')),'westcentralus'), equals(toLower(parameters('applicationInsightsLocation')),'eastus2euap'), equals(toLower(parameters('applicationInsightsLocation')),'centraluseuap')),'southcentralus', parameters('applicationInsightsLocation'))]",
818+
"kind": "web",
819+
"dependsOn": [
820+
"[resourceId('Microsoft.OperationalInsights/workspaces', parameters('logAnalyticsName'))]"
821+
],
822+
"properties": {
823+
"Application_Type": "web",
824+
"WorkspaceResourceId": "[parameters('logAnalyticsArmId')]"
825+
}
826+
},
798827
{
799828
"condition": "[variables('enablePE')]",
800829
"type": "Microsoft.MachineLearningServices/workspaces",
@@ -805,7 +834,8 @@
805834
"location": "[parameters('location')]",
806835
"dependsOn": [
807836
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]",
808-
"[resourceId('Microsoft.KeyVault/vaults', parameters('keyVaultName'))]"
837+
"[resourceId('Microsoft.KeyVault/vaults', parameters('keyVaultName'))]",
838+
"[resourceId('Microsoft.Insights/components', parameters('applicationInsightsName'))]"
809839
],
810840
"identity": "[parameters('identity')]",
811841
"properties": {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"value": ""
4040
},
4141
"applicationInsightsOption": {
42-
"value": "none"
42+
"value": "new"
4343
},
4444
"applicationInsightsName": {
4545
"value": ""

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

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,11 @@
119119
},
120120
"applicationInsightsOption": {
121121
"type": "string",
122-
"defaultValue": "none",
122+
"defaultValue": "new",
123123
"allowedValues": [
124-
"none",
125-
"existing"
124+
"new",
125+
"existing",
126+
"none"
126127
],
127128
"metadata": {
128129
"description": "Determines whether or not new ApplicationInsights should be provisioned."
@@ -161,7 +162,7 @@
161162
"type": "string",
162163
"defaultValue": "none",
163164
"allowedValues": [
164-
"existing",
165+
"new",
165166
"none"
166167
],
167168
"metadata": {
@@ -622,6 +623,25 @@
622623
"metadata": {
623624
"description": "Whether to grant materialization identity permissions"
624625
}
626+
},
627+
"allowRoleAssignmentOnRG": {
628+
"type": "string",
629+
"defaultValue": "true",
630+
"allowedValues": [
631+
"true",
632+
"false"
633+
],
634+
"metadata": {
635+
"description": "Unused for projects, but required due to interdependency of normal and project ARM templates."
636+
}
637+
},
638+
639+
"systemDatastoresAuthMode": {
640+
"type": "string",
641+
"defaultValue": "",
642+
"metadata": {
643+
"description": "Unused for projects, but required due to interdependency of normal and project ARM templates"
644+
}
625645
}
626646
},
627647
"variables": {

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,14 @@ def _populate_arm_parameters(self, workspace: Workspace, **kwargs: Any) -> Tuple
589589
param["applicationInsightsResourceGroupName"],
590590
group_name,
591591
)
592+
elif workspace._kind and workspace._kind.lower() in {WorkspaceKind.HUB, WorkspaceKind.PROJECT}:
593+
_set_val(param["applicationInsightsOption"], "none")
594+
# Set empty values because arm templates whine over unset values.
595+
_set_val(param["applicationInsightsName"], "ignoredButCantBeEmpty")
596+
_set_val(
597+
param["applicationInsightsResourceGroupName"],
598+
"ignoredButCantBeEmpty",
599+
)
592600
else:
593601
log_analytics = _generate_log_analytics(workspace.name, resources_being_deployed)
594602
_set_val(param["logAnalyticsName"], log_analytics)

sdk/ml/azure-ai-ml/tests/workspace/ai_workspaces/e2etests/test_ai_workspace_operations.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def test_ai_workspace_operations(self, client: MLClient, randstr: Callable[[], s
6464
)
6565
created_hub = client.workspaces.begin_create(workspace=local_hub).result()
6666
assert created_hub.associated_workspaces == []
67+
assert created_hub.application_insights is None
6768

6869
local_project1 = Project(
6970
name=f"test_proj_1_{randstr('project_1_name')}",
@@ -73,6 +74,7 @@ def test_ai_workspace_operations(self, client: MLClient, randstr: Callable[[], s
7374
# don't set project location, make sure it gets copied via value injection
7475
)
7576
created_project1 = client.workspaces.begin_create(workspace=local_project1).result()
77+
assert created_project1.application_insights is None
7678

7779
local_project2 = Project(
7880
name=f"test_proj_2_{randstr('project_2_name')}",
@@ -81,6 +83,7 @@ def test_ai_workspace_operations(self, client: MLClient, randstr: Callable[[], s
8183
display_name="project2 display name",
8284
)
8385
created_project2 = client.workspaces.begin_create(workspace=local_project2).result()
86+
assert created_project2.application_insights is None
8487

8588
project_ids = [created_project1.id, created_project2.id]
8689

@@ -144,6 +147,14 @@ def test_ai_workspace_operations(self, client: MLClient, randstr: Callable[[], s
144147
poller.wait() # Need to wait for projects to be cleaned before deleting parent hub.
145148

146149
if created_hub is not None:
150+
if is_live():
151+
from time import sleep
152+
153+
sleep(60)
147154
poller = client.workspaces.begin_delete(created_hub.name, delete_dependent_resources=True)
148155
assert poller
149156
assert isinstance(poller, LROPoller)
157+
# Double check that we didn't fail out of main code block before creating resources.
158+
assert created_hub is not None
159+
assert created_project1 is not None
160+
assert created_project2 is not None

sdk/ml/azure-ai-ml/tests/workspace/e2etests/test_workspace.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ def workspace_validation(wps):
125125
workspace = client.workspaces.get(wps_name)
126126
assert isinstance(workspace, Workspace)
127127
assert workspace.name == wps_name
128+
assert workspace.application_insights is not None
128129

129130
param_image_build_compute = "compute"
130131
param_display_name = "Test display name"

0 commit comments

Comments
 (0)