Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion infra/core/ai/ai-project.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ module applicationInsights '../monitor/applicationinsights.bicep' = if (shouldCr
tags: tags
name: 'appi-${resourceToken}'
logAnalyticsWorkspaceId: logAnalytics.outputs.id
projectMIPrincipalId: aiAccount::project.identity.principalId
}
}

Expand Down Expand Up @@ -202,6 +201,21 @@ module aiConnections './connection.bicep' = [for (connection, index) in connecti
}
}]

// Log Analytics Reader for the Foundry Project managed identity.
// Required for continuous evaluation to query Application Insights traces.
// This must NOT be gated on shouldCreateAppInsights, because after first deploy
// the App Insights outputs get saved as azd env vars, making shouldCreateAppInsights=false
// on subsequent provisions and skipping the entire applicationInsights module.
resource projectLogAnalyticsReaderRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (enableMonitoring) {
name: guid(subscription().id, resourceGroup().id, aiAccount::project.name, '73c42c96-874c-492b-b04d-ab87d138a893')
properties: {
principalId: aiAccount::project.identity.principalId
principalType: 'ServicePrincipal'
// Log Analytics Reader
roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', '73c42c96-874c-492b-b04d-ab87d138a893')
}
}

// Azure AI User for the developer, scoped to the Foundry Project.
// Project scope is sufficient for creating/running agents and calling models via the project endpoint.
resource localUserAzureAIUserRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
Expand Down
16 changes: 0 additions & 16 deletions infra/core/monitor/applicationinsights.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ param location string = resourceGroup().location
param tags object = {}
param logAnalyticsWorkspaceId string

@description('Optional. Principal ID of the Foundry Project managed identity to grant Log Analytics Reader.')
param projectMIPrincipalId string = ''

resource applicationInsights 'Microsoft.Insights/components@2020-02-02' = {
name: name
location: location
Expand All @@ -28,19 +25,6 @@ module applicationInsightsDashboard 'applicationinsights-dashboard.bicep' = if (
}
}

// Log Analytics Reader for the Foundry Project managed identity.
// Required for running evaluations on traces generated by agents.
resource logAnalyticsReaderRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (!empty(projectMIPrincipalId)) {
scope: applicationInsights
name: guid(applicationInsights.id, projectMIPrincipalId, '73c42c96-874c-492b-b04d-ab87d138a893')
properties: {
principalId: projectMIPrincipalId
principalType: 'ServicePrincipal'
// Log Analytics Reader
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '73c42c96-874c-492b-b04d-ab87d138a893')
}
}

output connectionString string = applicationInsights.properties.ConnectionString
output id string = applicationInsights.id
output instrumentationKey string = applicationInsights.properties.InstrumentationKey
Expand Down