diff --git a/03-Azure/01-04-AI/08_Predictive_Maintenance/labautomation/lab-defaults.json b/03-Azure/01-04-AI/08_Predictive_Maintenance/labautomation/lab-defaults.json index 984780656..e8c1fe20e 100644 --- a/03-Azure/01-04-AI/08_Predictive_Maintenance/labautomation/lab-defaults.json +++ b/03-Azure/01-04-AI/08_Predictive_Maintenance/labautomation/lab-defaults.json @@ -3,7 +3,7 @@ "groups": ["GHCPUsers"], "deploymentType": "resourcegroup-with-subscriptionowner", "labsPerSubscription": 5, - "preferredLocation": "swedencentral, francecentral, eastus2, germanywestcentral", + "preferredLocation": "francecentral, germanywestcentral, eastus2, swedencentral", "estimatedDailyCostsUsd": 8.0, "estimatedSharedDeploymentDailyCostsUsd": 0.0 } diff --git a/03-Azure/01-04-AI/08_Predictive_Maintenance/labautomation/main.bicep b/03-Azure/01-04-AI/08_Predictive_Maintenance/labautomation/main.bicep index 946f7e250..4325f1562 100644 --- a/03-Azure/01-04-AI/08_Predictive_Maintenance/labautomation/main.bicep +++ b/03-Azure/01-04-AI/08_Predictive_Maintenance/labautomation/main.bicep @@ -33,6 +33,7 @@ var cognitiveServicesUserRoleId = subscriptionResourceId('Microsoft.Authorizatio var searchServiceContributorRoleId = subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '7ca78c08-252a-4471-8644-bb5ff32d4ba0') var searchIndexDataReaderRoleId = subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '1407120a-92aa-4202-b7e9-c0e197c71c8f') var monitoringReaderRoleId = subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '43d0d8ad-25c7-4714-9337-8ba259a9fe05') +var logAnalyticsReaderRoleId = subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '73c42c96-874c-492b-b04d-ab87d138a893') var foundryUserRoleId = subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '53ca6127-db72-4b80-b1b0-d745d6d5456d') var openAiContributorRoleId = subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'a001fd3d-188f-4b5d-821b-7da978bf7442') var storageBlobDataContributorRoleId = subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'ba92f5b4-2d11-453d-a403-e96b0029c9fe') @@ -256,6 +257,24 @@ resource aiProject 'Microsoft.CognitiveServices/accounts/projects@2025-04-01-pre ] } +resource aiProjectAppInsightsConnection 'Microsoft.CognitiveServices/accounts/projects/connections@2025-04-01-preview' = { + parent: aiProject + name: applicationInsightsName + properties: { + authType: 'ApiKey' + category: 'AppInsights' + target: applicationInsights.id + isSharedToAll: true + credentials: { + key: applicationInsights.properties.ConnectionString + } + metadata: { + ApiType: 'Azure' + ResourceId: applicationInsights.id + } + } +} + resource gpt5_4MiniDeployment 'Microsoft.CognitiveServices/accounts/deployments@2025-04-01-preview' = { parent: aiFoundry name: 'gpt-5.4-mini' @@ -360,6 +379,16 @@ resource appInsightsMonitoringReaderForProject 'Microsoft.Authorization/roleAssi } } +resource appInsightsLogAnalyticsReaderForProject 'Microsoft.Authorization/roleAssignments@2022-04-01' = { + scope: applicationInsights + name: guid(applicationInsights.id, aiProject.id, logAnalyticsReaderRoleId) + properties: { + roleDefinitionId: logAnalyticsReaderRoleId + principalId: aiProject.identity.principalId + principalType: 'ServicePrincipal' + } +} + resource searchCognitiveServicesUserForFoundry 'Microsoft.Authorization/roleAssignments@2022-04-01' = { scope: aiFoundry name: guid(searchService.id, aiFoundry.id, cognitiveServicesUserRoleId, 'search-to-cognitive') diff --git a/03-Azure/01-04-AI/08_Predictive_Maintenance/scripts/test-deploy.ps1 b/03-Azure/01-04-AI/08_Predictive_Maintenance/scripts/test-deploy.ps1 index 0705060c1..cf78f6e82 100755 --- a/03-Azure/01-04-AI/08_Predictive_Maintenance/scripts/test-deploy.ps1 +++ b/03-Azure/01-04-AI/08_Predictive_Maintenance/scripts/test-deploy.ps1 @@ -104,6 +104,9 @@ if (-not (Get-Command Invoke-MhhDeploymentWithRegionFallback -ErrorAction Silent } else { az group create --name $ResourceGroupName --location $chosenLocation --output none } + if ($LASTEXITCODE -ne 0) { + throw "Could not create or update resource group '$ResourceGroupName' (Azure CLI exit code $LASTEXITCODE)." + } # Build parameter arguments for az deployment $paramArgs = @() @@ -122,8 +125,16 @@ if (-not (Get-Command Invoke-MhhDeploymentWithRegionFallback -ErrorAction Silent --parameters $paramArgs ` --query "{outputs: properties.outputs}" ` --output json - + + if ($LASTEXITCODE -ne 0) { + throw "Deployment '$deploymentName' failed in resource group '$ResourceGroupName' (Azure CLI exit code $LASTEXITCODE). Data seeding will not run. See the Azure CLI error above." + } + $parsed = $jsonResult | ConvertFrom-Json + + if (-not $parsed.outputs) { + throw "Deployment '$deploymentName' returned no outputs. Data seeding will not run." + } # Flatten outputs: { "name": { "value": "val" } } -> { "name": "val" } $flatOutputs = @{}