Bicep makes us human again. After all Json ARM templates, we can now write something with less brackets. I have written a few articles on Bicep and some templates related to APIM before as well. In this article, I will explain how to setup a Log Analytics workspace and bind App Insights instances to it.
Log Analytics Workspace
Log Analytics Workspace allow to stream logs coming from multiple sources. It is part of Azure Monitor and lets us query all in one.
Bicep syntax is as follows:
resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-08-01' = {
name: logAnalyticsNamespaceName
location: region
properties: {
sku: {
name: 'PerGB2018'
}
retentionInDays: 120
features: {
searchVersion: 1
legacy: 0
enableLogAccessUsingOnlyResourcePermissions: true
}
}
}
Application Insights
Application Insights is an Application Performance Management tool that lets you monitor requests, log custom messages. It used to work alone, but now it can be streamed to a Log Analytics Workspace with the simplest configurations.
resource appInsights 'Microsoft.Insights/components@2020-02-02' = {
name: appInsightsName
location: region
kind: 'string'
tags: {
displayName: 'AppInsight'
ProjectName: appName
}
properties: {
Application_Type: 'web'
WorkspaceResourceId: '/subscriptions/${subscription().subscriptionId}/resourceGroups/${resourceGroup().name}/providers/Microsoft.OperationalInsights/workspaces/${logAnalyticsNamespaceName}'
}
}
As you can see, the WorkspaceResourceId parameter has to be configured. This can be used with reference as well.
No comments:
Post a Comment