move bicep to corresponding example
This commit is contained in:
58
GrafanaBlazor/.bicep/main.bicep
Normal file
58
GrafanaBlazor/.bicep/main.bicep
Normal file
@@ -0,0 +1,58 @@
|
||||
targetScope = 'subscription'
|
||||
|
||||
@description('The name of the resource group')
|
||||
param resourceGroupName string = 'rg-blazor-grafana'
|
||||
|
||||
@description('The location for all resources')
|
||||
param location string = 'eastus'
|
||||
|
||||
@description('The name of the App Service Plan')
|
||||
param appServicePlanName string = 'asp-blazor-app'
|
||||
|
||||
@description('The name of the Web App')
|
||||
param webAppName string = 'webapp-blazor-${uniqueString(resourceGroupName)}'
|
||||
|
||||
@description('The name of the Application Insights instance')
|
||||
param appInsightsName string = 'ai-blazor-app'
|
||||
|
||||
@description('The name of the Log Analytics Workspace')
|
||||
param logAnalyticsWorkspaceName string = 'law-blazor-app'
|
||||
|
||||
// Create the resource group
|
||||
resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
|
||||
name: resourceGroupName
|
||||
location: location
|
||||
}
|
||||
|
||||
// Deploy the logging and monitoring infrastructure
|
||||
module monitoring 'modules/monitoring.bicep' = {
|
||||
scope: resourceGroup
|
||||
name: 'monitoring-deployment'
|
||||
params: {
|
||||
location: location
|
||||
appInsightsName: appInsightsName
|
||||
logAnalyticsWorkspaceName: logAnalyticsWorkspaceName
|
||||
}
|
||||
}
|
||||
|
||||
// Deploy the App Service infrastructure
|
||||
module appService 'modules/appService.bicep' = {
|
||||
scope: resourceGroup
|
||||
name: 'appservice-deployment'
|
||||
params: {
|
||||
location: location
|
||||
appServicePlanName: appServicePlanName
|
||||
webAppName: webAppName
|
||||
appInsightsInstrumentationKey: monitoring.outputs.instrumentationKey
|
||||
appInsightsConnectionString: monitoring.outputs.connectionString
|
||||
}
|
||||
}
|
||||
|
||||
// Outputs
|
||||
output resourceGroupName string = resourceGroup.name
|
||||
output webAppName string = appService.outputs.webAppName
|
||||
output webAppUrl string = appService.outputs.webAppUrl
|
||||
output appInsightsName string = monitoring.outputs.appInsightsName
|
||||
output logAnalyticsWorkspaceId string = monitoring.outputs.workspaceId
|
||||
output grafanaName string = monitoring.outputs.grafanaName
|
||||
output grafanaEndpoint string = monitoring.outputs.grafanaEndpoint
|
||||
124
GrafanaBlazor/.bicep/modules/appService.bicep
Normal file
124
GrafanaBlazor/.bicep/modules/appService.bicep
Normal file
@@ -0,0 +1,124 @@
|
||||
@description('The location for all resources')
|
||||
param location string
|
||||
|
||||
@description('The name of the App Service Plan')
|
||||
param appServicePlanName string
|
||||
|
||||
@description('The name of the Web App')
|
||||
param webAppName string
|
||||
|
||||
@description('Application Insights Instrumentation Key')
|
||||
param appInsightsInstrumentationKey string
|
||||
|
||||
@description('Application Insights Connection String')
|
||||
param appInsightsConnectionString string
|
||||
|
||||
// Create App Service Plan
|
||||
resource appServicePlan 'Microsoft.Web/serverfarms@2022-09-01' = {
|
||||
name: appServicePlanName
|
||||
location: location
|
||||
sku: {
|
||||
name: 'B1'
|
||||
tier: 'Basic'
|
||||
size: 'B1'
|
||||
family: 'B'
|
||||
capacity: 1
|
||||
}
|
||||
kind: 'linux'
|
||||
properties: {
|
||||
reserved: true
|
||||
}
|
||||
}
|
||||
|
||||
// Create Web App
|
||||
resource webApp 'Microsoft.Web/sites@2022-09-01' = {
|
||||
name: webAppName
|
||||
location: location
|
||||
kind: 'app,linux'
|
||||
properties: {
|
||||
serverFarmId: appServicePlan.id
|
||||
httpsOnly: true
|
||||
siteConfig: {
|
||||
linuxFxVersion: 'DOTNETCORE|8.0'
|
||||
alwaysOn: true
|
||||
minTlsVersion: '1.2'
|
||||
ftpsState: 'Disabled'
|
||||
http20Enabled: true
|
||||
appSettings: [
|
||||
{
|
||||
name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
|
||||
value: appInsightsConnectionString
|
||||
}
|
||||
{
|
||||
name: 'ApplicationInsightsAgent_EXTENSION_VERSION'
|
||||
value: '~3'
|
||||
}
|
||||
{
|
||||
name: 'XDT_MicrosoftApplicationInsights_Mode'
|
||||
value: 'recommended'
|
||||
}
|
||||
{
|
||||
name: 'APPINSIGHTS_INSTRUMENTATIONKEY'
|
||||
value: appInsightsInstrumentationKey
|
||||
}
|
||||
{
|
||||
name: 'ASPNETCORE_ENVIRONMENT'
|
||||
value: 'Production'
|
||||
}
|
||||
{
|
||||
name: 'OTEL_SDK_DISABLED'
|
||||
value: 'false'
|
||||
}
|
||||
{
|
||||
name: 'OTEL_TRACES_SAMPLER'
|
||||
value: 'always_on'
|
||||
}
|
||||
{
|
||||
name: 'OTEL_METRICS_EXPORTER'
|
||||
value: 'otlp'
|
||||
}
|
||||
{
|
||||
name: 'OTEL_EXPORTER_OTLP_ENDPOINT'
|
||||
value: 'http://localhost:4317'
|
||||
}
|
||||
]
|
||||
metadata: [
|
||||
{
|
||||
name: 'CURRENT_STACK'
|
||||
value: 'dotnet'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Enable detailed error messages and logging
|
||||
resource webAppLogs 'Microsoft.Web/sites/config@2022-09-01' = {
|
||||
parent: webApp
|
||||
name: 'logs'
|
||||
properties: {
|
||||
applicationLogs: {
|
||||
fileSystem: {
|
||||
level: 'Information'
|
||||
}
|
||||
}
|
||||
httpLogs: {
|
||||
fileSystem: {
|
||||
retentionInMb: 35
|
||||
retentionInDays: 7
|
||||
enabled: true
|
||||
}
|
||||
}
|
||||
failedRequestsTracing: {
|
||||
enabled: true
|
||||
}
|
||||
detailedErrorMessages: {
|
||||
enabled: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Outputs
|
||||
output webAppName string = webApp.name
|
||||
output webAppUrl string = 'https://${webApp.properties.defaultHostName}'
|
||||
output webAppId string = webApp.id
|
||||
108
GrafanaBlazor/.bicep/modules/appService2.bicep
Normal file
108
GrafanaBlazor/.bicep/modules/appService2.bicep
Normal file
@@ -0,0 +1,108 @@
|
||||
@description('The location for all resources')
|
||||
param location string
|
||||
|
||||
@description('The name of the App Service Plan')
|
||||
param appServicePlanName string
|
||||
|
||||
@description('The name of the Web App')
|
||||
param webAppName string
|
||||
|
||||
@description('Application Insights Instrumentation Key')
|
||||
param appInsightsInstrumentationKey string
|
||||
|
||||
@description('Application Insights Connection String')
|
||||
param appInsightsConnectionString string
|
||||
|
||||
// Create App Service Plan
|
||||
resource appServicePlan 'Microsoft.Web/serverfarms@2022-09-01' = {
|
||||
name: appServicePlanName
|
||||
location: location
|
||||
sku: {
|
||||
name: 'B1'
|
||||
tier: 'Basic'
|
||||
size: 'B1'
|
||||
family: 'B'
|
||||
capacity: 1
|
||||
}
|
||||
kind: 'linux'
|
||||
properties: {
|
||||
reserved: true
|
||||
}
|
||||
}
|
||||
|
||||
// Create Web App
|
||||
resource webApp 'Microsoft.Web/sites@2022-09-01' = {
|
||||
name: webAppName
|
||||
location: location
|
||||
kind: 'app,linux'
|
||||
properties: {
|
||||
serverFarmId: appServicePlan.id
|
||||
httpsOnly: true
|
||||
siteConfig: {
|
||||
linuxFxVersion: 'DOTNETCORE|8.0'
|
||||
alwaysOn: true
|
||||
minTlsVersion: '1.2'
|
||||
ftpsState: 'Disabled'
|
||||
http20Enabled: true
|
||||
appSettings: [
|
||||
{
|
||||
name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
|
||||
value: appInsightsConnectionString
|
||||
}
|
||||
{
|
||||
name: 'ApplicationInsightsAgent_EXTENSION_VERSION'
|
||||
value: '~3'
|
||||
}
|
||||
{
|
||||
name: 'XDT_MicrosoftApplicationInsights_Mode'
|
||||
value: 'recommended'
|
||||
}
|
||||
{
|
||||
name: 'APPINSIGHTS_INSTRUMENTATIONKEY'
|
||||
value: appInsightsInstrumentationKey
|
||||
}
|
||||
{
|
||||
name: 'ASPNETCORE_ENVIRONMENT'
|
||||
value: 'Production'
|
||||
}
|
||||
]
|
||||
metadata: [
|
||||
{
|
||||
name: 'CURRENT_STACK'
|
||||
value: 'dotnet'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Enable detailed error messages and logging
|
||||
resource webAppLogs 'Microsoft.Web/sites/config@2022-09-01' = {
|
||||
parent: webApp
|
||||
name: 'logs'
|
||||
properties: {
|
||||
applicationLogs: {
|
||||
fileSystem: {
|
||||
level: 'Information'
|
||||
}
|
||||
}
|
||||
httpLogs: {
|
||||
fileSystem: {
|
||||
retentionInMb: 35
|
||||
retentionInDays: 7
|
||||
enabled: true
|
||||
}
|
||||
}
|
||||
failedRequestsTracing: {
|
||||
enabled: true
|
||||
}
|
||||
detailedErrorMessages: {
|
||||
enabled: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Outputs
|
||||
output webAppName string = webApp.name
|
||||
output webAppUrl string = 'https://${webApp.properties.defaultHostName}'
|
||||
output webAppId string = webApp.id
|
||||
100
GrafanaBlazor/.bicep/modules/monitoring.bicep
Normal file
100
GrafanaBlazor/.bicep/modules/monitoring.bicep
Normal file
@@ -0,0 +1,100 @@
|
||||
@description('The location for all resources')
|
||||
param location string
|
||||
|
||||
@description('The name of the Application Insights instance')
|
||||
param appInsightsName string
|
||||
|
||||
@description('The name of the Log Analytics Workspace')
|
||||
param logAnalyticsWorkspaceName string
|
||||
|
||||
@description('The name of the Grafana instance')
|
||||
param grafanaName string = 'grafana-${uniqueString(resourceGroupId())}'
|
||||
|
||||
// Create Log Analytics Workspace
|
||||
resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2022-10-01' = {
|
||||
name: logAnalyticsWorkspaceName
|
||||
location: location
|
||||
properties: {
|
||||
sku: {
|
||||
name: 'PerGB2018'
|
||||
}
|
||||
retentionInDays: 30
|
||||
features: {
|
||||
enableLogAccessUsingOnlyResourcePermissions: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create Application Insights
|
||||
resource applicationInsights 'Microsoft.Insights/components@2020-02-02' = {
|
||||
name: appInsightsName
|
||||
location: location
|
||||
kind: 'web'
|
||||
properties: {
|
||||
Application_Type: 'web'
|
||||
WorkspaceResourceId: logAnalyticsWorkspace.id
|
||||
IngestionMode: 'LogAnalytics'
|
||||
publicNetworkAccessForIngestion: 'Enabled'
|
||||
publicNetworkAccessForQuery: 'Enabled'
|
||||
}
|
||||
}
|
||||
|
||||
// Create Grafana Instance - Standard SKU (lowest cost managed option)
|
||||
resource grafana 'Microsoft.Dashboard/grafana@2023-09-01' = {
|
||||
name: grafanaName
|
||||
location: location
|
||||
sku: {
|
||||
name: 'Standard'
|
||||
}
|
||||
identity: {
|
||||
type: 'SystemAssigned'
|
||||
}
|
||||
properties: {
|
||||
apiKey: 'Enabled'
|
||||
autoLogoutMinutes: 0
|
||||
azureMonitorWorkspaceIntegrations: [
|
||||
{
|
||||
azureMonitorWorkspaceResourceId: logAnalyticsWorkspace.id
|
||||
}
|
||||
]
|
||||
grafanaIntegrations: {
|
||||
azureMonitorWorkspaceIntegrations: [
|
||||
{
|
||||
azureMonitorWorkspaceResourceId: logAnalyticsWorkspace.id
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Assign Monitoring Data Reader role to Grafana for Log Analytics Workspace
|
||||
resource grafanaLogAnalyticsRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
|
||||
scope: logAnalyticsWorkspace
|
||||
name: guid(logAnalyticsWorkspace.id, grafana.id, 'b24988ac-6180-42a0-ab88-20f7382dd24c')
|
||||
properties: {
|
||||
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')
|
||||
principalId: grafana.identity.principalId
|
||||
principalType: 'ServicePrincipal'
|
||||
}
|
||||
}
|
||||
|
||||
// Assign Monitoring Data Reader role to Grafana for Application Insights
|
||||
resource grafanaAppInsightsRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
|
||||
scope: applicationInsights
|
||||
name: guid(applicationInsights.id, grafana.id, 'b24988ac-6180-42a0-ab88-20f7382dd24c')
|
||||
properties: {
|
||||
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')
|
||||
principalId: grafana.identity.principalId
|
||||
principalType: 'ServicePrincipal'
|
||||
}
|
||||
}
|
||||
|
||||
// Outputs
|
||||
output appInsightsName string = applicationInsights.name
|
||||
output instrumentationKey string = applicationInsights.properties.InstrumentationKey
|
||||
output connectionString string = applicationInsights.properties.ConnectionString
|
||||
output workspaceId string = logAnalyticsWorkspace.id
|
||||
output workspaceName string = logAnalyticsWorkspace.name
|
||||
output grafanaName string = grafana.name
|
||||
output grafanaId string = grafana.id
|
||||
output grafanaEndpoint string = grafana.properties.endpoint
|
||||
44
GrafanaBlazor/.bicep/modules/monitoring2.bicep
Normal file
44
GrafanaBlazor/.bicep/modules/monitoring2.bicep
Normal file
@@ -0,0 +1,44 @@
|
||||
@description('The location for all resources')
|
||||
param location string
|
||||
|
||||
@description('The name of the Application Insights instance')
|
||||
param appInsightsName string
|
||||
|
||||
@description('The name of the Log Analytics Workspace')
|
||||
param logAnalyticsWorkspaceName string
|
||||
|
||||
// Create Log Analytics Workspace
|
||||
resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2022-10-01' = {
|
||||
name: logAnalyticsWorkspaceName
|
||||
location: location
|
||||
properties: {
|
||||
sku: {
|
||||
name: 'PerGB2018'
|
||||
}
|
||||
retentionInDays: 30
|
||||
features: {
|
||||
enableLogAccessUsingOnlyResourcePermissions: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create Application Insights
|
||||
resource applicationInsights 'Microsoft.Insights/components@2020-02-02' = {
|
||||
name: appInsightsName
|
||||
location: location
|
||||
kind: 'web'
|
||||
properties: {
|
||||
Application_Type: 'web'
|
||||
WorkspaceResourceId: logAnalyticsWorkspace.id
|
||||
IngestionMode: 'LogAnalytics'
|
||||
publicNetworkAccessForIngestion: 'Enabled'
|
||||
publicNetworkAccessForQuery: 'Enabled'
|
||||
}
|
||||
}
|
||||
|
||||
// Outputs
|
||||
output appInsightsName string = applicationInsights.name
|
||||
output instrumentationKey string = applicationInsights.properties.InstrumentationKey
|
||||
output connectionString string = applicationInsights.properties.ConnectionString
|
||||
output workspaceId string = logAnalyticsWorkspace.id
|
||||
output workspaceName string = logAnalyticsWorkspace.name
|
||||
Reference in New Issue
Block a user