Application Insights and Log Analytics Workspace Bicep Template

According to a message in the Azure Portal “Classic Application Insights is deprecated and will be retired in February 2024”. That means it’s time to think about how to configure Application Insights to store it’s data in a Log Analytics Workspace. You can do it manually in the Portal, but I prefer doing these things in Bicep so it can be replicated across all environments automatically.

Luckily despite the lack of documentation it’s quite straight forward as you can see from the Bicep file below. As an extra bonus I’ve included how you can limit the maximum daily ingestion on the Workspace by providing a value for dailyQuotaGb. Note: Bicep expects an integer, however in order to set the minimum possible value of 0.023 GB you need to pass it as a string which will work just fine.

resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2021-12-01-preview' = {
name: resourceBaseName
location: resourceGroup().location
properties: {
sku: {
name: 'PerGB2018'
}
retentionInDays: 90
workspaceCapping: {
dailyQuotaGb: '0.023'
}
}
}
resource applicationInsights 'Microsoft.Insights/components@2020-02-02' = {
name: resourceBaseName
location: resourceGroup().location
kind: 'web'
properties: {
Application_Type: 'web'
WorkspaceResourceId: logAnalyticsWorkspace.id
}
}

Photo by Marjan Taghipour on Unsplash

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.