0
0

Bicepで クラシック Application Insightsは2024年2月29日に廃止されました と出力されたことに対応したメモ

Last updated at Posted at 2024-08-24

概要

一番シンプルな形でApplication Insightsを作成したら下記の警告が出た。

image.png

bicepに追記をおこなったら警告が消えたのでメモをしておく。

ソースコード

Bicep

infra/biceps/core/host/appplications.bicep
param location string
param applicationInsightsName string
+ param logAnalyticsName string

+ resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2023-+ 09-01' = {
+   name: logAnalyticsName
+   location: location
+ }

resource applicationInsights 'Microsoft.Insights/components@2020-02-02' = {
  name: applicationInsightsName
  location: location
  kind: 'web'
  properties: {
    Application_Type: 'web'
    Request_Source: 'rest'
    WorkspaceResourceId: logAnalytics.id
  }
}
output applicationInsightsInstrumentationKey string = applicationInsights.properties.InstrumentationKey

infra/biceps/main.bicep
param location string = resourceGroup().location
param allowedOrigin string
param keyVaultName string
@description('The runtime version of the Azure Functions app.')
param functionsRuntime object

var storageAccountName = '${uniqueString(resourceGroup().id)}azfunctions'
var applicationInsightsName = '${uniqueString(resourceGroup().id)}applicationinsights'
+ var logAnalyticsName = '${uniqueString(resourceGroup().id)}logAnalytics'


resource keyVault 'Microsoft.KeyVault/vaults@2023-07-01' existing = {
  name: keyVaultName
}

module myFunctionsApplicationInsights 'core/host/applications.bicep' = {
  name: 'myFunctionsApplicationInsights'
  params: {
    location: location
    applicationInsightsName: applicationInsightsName
+    logAnalyticsName: logAnalyticsName
  }
}


module myFunctionsStorage 'core/storage/storage-account.bicep' = {
  name: 'myFunctionsStorage'
  params: {
    location: location
    storageAccountName: storageAccountName
  }
}

module myFunctions 'core/host/functions.bicep' = {
  name: 'myFunctions'
  params: {
    location: location
    allowedOrigin: allowedOrigin
    databaseUrl: keyVault.getSecret('AsyncTrpgDatabaseURL')
    storageAccountName: storageAccountName
    kind: functionsRuntime.kind
    linuxFxVersion: functionsRuntime.linuxFxVersion
    applicationInsightsInstrumentationKey: myFunctionsApplicationInsights.outputs.applicationInsightsInstrumentationKey
    extensionVersion: functionsRuntime.extensionVersion
    connectionString: keyVault.getSecret('AsyncTrpgConnectionString')
  }
}

output appServiceAppHostName string = myFunctions.outputs.appServiceAppHostName

参考

Microsoft.Insights コンポーネント
Quickstart: Create and deploy Azure Functions resources using Bicep
Workspace

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0