Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Log Analytics workspace resource & migrate from the classic Application Insights #14

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
33 changes: 31 additions & 2 deletions templates/function-app/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,31 @@ param logAnalyticsWorkspaceResourceId string
var functionName = 'PolicyMonitor'
var functionAppKeySecretName = 'FunctionAppHostKey'
var logAnalyticsAPIVersion = '2021-06-01'

var workspaceId = logAnalyticsWorkspace.properties.customerId
var primaryKey = listKeys(logAnalyticsWorkspace.id, logAnalyticsWorkspace.apiVersion).primarySharedKey


resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2021-12-01-preview' = {
name: logAnalyticsWorkspaceResourceId
location: location
properties: {
sku: {
name: 'PerGB2018'
}
retentionInDays: 30
features: {
enableLogAccessUsingOnlyResourcePermissions: true
}
workspaceCapping: {
dailyQuotaGb: -1
}
publicNetworkAccessForIngestion: 'Enabled'
publicNetworkAccessForQuery: 'Enabled'
}
}


resource storageAccount 'Microsoft.Storage/storageAccounts@2021-06-01' = {
name: storageAccountName
location: location
Expand Down Expand Up @@ -66,6 +91,7 @@ resource appInsights 'Microsoft.Insights/components@2020-02-02' = {
Application_Type: 'web'
publicNetworkAccessForIngestion: 'Enabled'
publicNetworkAccessForQuery: 'Enabled'
WorkspaceResourceId: logAnalyticsWorkspace.id
}
}

Expand Down Expand Up @@ -124,18 +150,21 @@ resource functionApp 'Microsoft.Web/sites@2021-02-01' = {
}
{
name: 'WORKSPACE_ID'
value: '${reference(logAnalyticsWorkspaceResourceId, logAnalyticsAPIVersion).customerId}'
value: '${workspaceId}'
}
{
name: 'WORKSPACE_KEY'
value: '${listKeys(logAnalyticsWorkspaceResourceId, logAnalyticsAPIVersion).primarySharedKey}'
value: '${primaryKey}'
}
]
numberOfWorkers: 1
linuxFxVersion: 'PYTHON|3.9'
}
keyVaultReferenceIdentity: 'SystemAssigned'
}
dependsOn: [
logAnalyticsWorkspace
]
}


Expand Down