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

adding example for web app log analytics #874

Merged
merged 6 commits into from
Nov 11, 2020
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
formatting changes post baseline
  • Loading branch information
JFolberth committed Nov 11, 2020
commit 615d10294d467fdef6af54aae113e0f9e7882d19
221 changes: 108 additions & 113 deletions docs/examples/201/web-app-loganalytics/main.bicep
Original file line number Diff line number Diff line change
@@ -1,113 +1,108 @@
param skuName string = 'S1'
param skuCapacity int = 1
param location string = resourceGroup().location
param appName string = uniqueString(resourceGroup().id)


var appServicePlanName = toLower('asp-${appName}')
var webSiteName= toLower('wapp-${appName}')
var appInsightName = toLower('appi-${appName}')
var logAnalyticsName = toLower('la-${appName}')


resource appServicePlan 'Microsoft.Web/serverfarms@2020-06-01' = {
name: appServicePlanName // Globally unique storage account name
location: location// Azure Region
sku:{
name:skuName
capacity:skuCapacity
}
tags:{
displayName: 'HostingPlan'
ProjectName: appName
}
}

resource appService 'Microsoft.Web/sites@2020-06-01' ={
name:webSiteName
location:location
identity:{
type:'SystemAssigned'
}
tags:{
displayName: 'Website'
ProjectName: appName
}
properties:{
serverFarmId: appServicePlan.id
httpsOnly:true
siteConfig:{
minTlsVersion: '1.2'
}

}

}
resource appServiceLogging 'Microsoft.Web/sites/config@2020-06-01' ={
name: '${appService.name}/logs'
properties:{
applicationLogs:{
fileSystem:{
level:'Warning'
}
}
httpLogs:{
fileSystem:{
retentionInMb:40
enabled:true
}
}
failedRequestsTracing:{
enabled:true
}
detailedErrorMessages:{
enabled:true
}
}
}

resource appServiceAppSettings'Microsoft.Web/sites/config@2020-06-01' ={
name: '${appService.name}/appsettings'
properties:{
APPINSIGHTS_INSTRUMENTATIONKEY: appInsights.properties.InstrumentationKey
}
dependsOn:[
appInsights
appServiceSiteExtension
]
}
resource appServiceSiteExtension 'Microsoft.Web/sites/siteextensions@2020-06-01' ={
name: '${appService.name}/Microsoft.ApplicationInsights.AzureWebsites'
dependsOn:[
appInsights
]

}
resource appInsights 'microsoft.insights/components@2020-02-02-preview' = {
name:appInsightName
location:location
kind: 'string'
tags:{
displayName:'AppInsight'
ProjectName:appName
}
properties:{
Application_Type:'web'
WorkspaceResourceId: logAnalyticsWorkspace.id
}
}

resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-03-01-preview'={
name: logAnalyticsName
location:location
tags:{
displayName:'Log Analytics'
ProjectName: appName
}
properties:{
sku:{
name:'PerGB2018'
}
retentionInDays: 120
}
}
param skuName string = 'S1'
param skuCapacity int = 1
param location string = resourceGroup().location
param appName string = uniqueString(resourceGroup().id)

var appServicePlanName = toLower('asp-${appName}')
var webSiteName = toLower('wapp-${appName}')
var appInsightName = toLower('appi-${appName}')
var logAnalyticsName = toLower('la-${appName}')

resource appServicePlan 'Microsoft.Web/serverfarms@2020-06-01' = {
name: appServicePlanName // Globally unique storage account name
location: location // Azure Region
sku: {
name: skuName
capacity: skuCapacity
}
tags: {
displayName: 'HostingPlan'
ProjectName: appName
}
}

resource appService 'Microsoft.Web/sites@2020-06-01' = {
name: webSiteName
location: location
identity: {
type: 'SystemAssigned'
}
tags: {
displayName: 'Website'
ProjectName: appName
}
properties: {
serverFarmId: appServicePlan.id
httpsOnly: true
siteConfig: {
minTlsVersion: '1.2'
}
}
}
resource appServiceLogging 'Microsoft.Web/sites/config@2020-06-01' = {
name: '${appService.name}/logs'
properties: {
applicationLogs: {
fileSystem: {
level: 'Warning'
}
}
httpLogs: {
fileSystem: {
retentionInMb: 40
enabled: true
}
}
failedRequestsTracing: {
enabled: true
}
detailedErrorMessages: {
enabled: true
}
}
}

resource appServiceAppSettings 'Microsoft.Web/sites/config@2020-06-01' = {
name: '${appService.name}/appsettings'
properties: {
APPINSIGHTS_INSTRUMENTATIONKEY: appInsights.properties.InstrumentationKey
}
dependsOn: [
appInsights
appServiceSiteExtension
]
}
resource appServiceSiteExtension 'Microsoft.Web/sites/siteextensions@2020-06-01' = {
name: '${appService.name}/Microsoft.ApplicationInsights.AzureWebsites'
dependsOn: [
appInsights
]
}
resource appInsights 'microsoft.insights/components@2020-02-02-preview' = {
name: appInsightName
location: location
kind: 'string'
tags: {
displayName: 'AppInsight'
ProjectName: appName
}
properties: {
Application_Type: 'web'
WorkspaceResourceId: logAnalyticsWorkspace.id
}
}

resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-03-01-preview' = {
name: logAnalyticsName
location: location
tags: {
displayName: 'Log Analytics'
ProjectName: appName
}
properties: {
sku: {
name: 'PerGB2018'
}
retentionInDays: 120
}
}