怎么使用Azure CLI脚本将Azure应用程序洞察正确连接到App Service Spring应用程序?

原学程将引见若何应用Azure CLI剧本将Azure运用法式洞悉准确衔接到App Service Spring运用法式?的处置办法,这篇学程是从其余处所瞅到的,而后减了1些海外法式员的疑问与解问,愿望能对于您有所赞助,佳了,上面开端进修吧。

怎么使用Azure CLI脚本将Azure应用程序洞察正确连接到App Service Spring应用程序? 教程 第1张

成绩描写

我经由过程Azure运用法式办事以及Azure CLI剧本托管了我的Spring Boot运用法式。别的,我借应用Azure CLI剧本在统一定阅上安排了Azure运用法式洞悉。我的下1步是仅应用az敕令以及弥补文件将App Insights与App Service衔接。

我曾经浏览了this文档,懂得怎样以无代码方法衔接App Insights。但是瞅起去我依然缺乏许多目标,如要求、依附项、异常等(虽然我在类途径中有微目标)。运用法式洞悉|搜刮只要陈迹,所以我测验考试从Azure流派网站衔接它,它起感化了。这个散成从新开动了我的运用法式,并发生了1些我没有晓得的魔力:

以下是我从Azure流派衔接App Insights之前以及以后的图象:

检查App Service的设置装备摆设时,我发明了文档中出有描写的多少个新值:

{
  "XDT_MicrosoftApplicationInsights_PreemptSdk": "disabled",
  "XDT_MicrosoftApplicationInsights_Mode": "reco妹妹ended",
  "XDT_MicrosoftApplicationInsights_BaseExtensions": "disabled",
  "SnapshotDebugger_EXTENSION_VERSION": "disabled",
  "InstrumentationEngine_EXTENSION_VERSION": "disabled",
  "DiagnosticServices_EXTENSION_VERSION": "~三",
  "APPINSIGHTS_PROFILERFEATURE_VERSION": "一.0.0",
  "APPINSIGHTS_INSTRUMENTATIONKEY": "key",
  "APPINSIGHTS_SNAPSHOTFEATURE_VERSION": "一.0.0",
  "ApplicationInsightsAgent_EXTENSION_VERSION": "~二"
}

是以我的成绩是,我怎样应用Azure CLI剧本模仿此按钮,以就它对于我的日记以及目标发生完整雷同的影响?&q;

推举谜底

在将JAR文件安排到App Services之前,请保证您在类途径中具备与AI SDK的最新依附闭系。供给我的Gradle导进的依附项散:

// Application Insights
 implementation "com.microsoft.azure:applicationinsights-spring-boot-starter:$appInsightsVersion"
 implementation "com.microsoft.azure:applicationinsights-logging-logback:$appInsightsVersion"
 implementation 'com.microsoft.azure:azure-spring-boot-metrics-starter'

如今,在编译运用法式后,不妨应用此Azure CLI剧本将Application Insights衔接到App Service:

az webapp config appsettings set 
  -n ${APP_NAME} 
  -g ${GROUP_NAME} 
  --settings 
APPINSIGHTS_INSTRUMENTATIONKEY=${APPINSIGHTS_INSTRUMENTATIONKEY} 
JAVA_OPTS="${APP_SERVICE_JAVA_OPTS}"

以下是我的VM情况变质:APP_SERVICE_JAVA_OPTS="-javaagent:/home/site/wwwroot/applicationinsights-agent.jar -Dserver.port=80"

如您所睹,我有1个指向Applationinsights-agent.jar的途径,这是我在安排进程中应用设置装备摆设紧缩安排复制的JAR:

cp ./build/libs/app-0.0.一-SNAPSHOT.jar ./deploymentrepo/app.jar
cp ./build/resources/main/applicationinsights-agent*.jar ./deploymentrepo/applicationinsights-agent.jar
cp ./build/resources/main/ApplicationInsights.json ./deploymentrepo/ApplicationInsights.json
cd ./deploymentrepo
zip target.zip -r ./*
az webapp deployment source config-zip 
  --src target.zip 
  -n ${ANALYTICS_APP_NAME} 
  -g ${ANALYTICS_GROUP_NAME}

我的ApplicationInsights.json瞅起去是如许:

{
  "instrumentationSettings": {
 "preview": {
"roleName": "ApplicationName",
"heartbeat": {
  "intervalSeconds": 六0
},
"instrumentation": {
  "logging": {
 "threshold": "INFO"
  },
  "micrometer": {
 "enabled": true
  }
},
"selfDiagnostics": {
  "destination": "file",
  "directory": "/var/log/applicationinsights",
  "level": "INFO",
  "maxSizeMB": 一0
}
 }
  }
}

佳了闭于怎样应用Azure CLI剧本将Azure运用法式洞悉准确衔接到App Service Spring运用法式?的学程便到这里便停止了,愿望趣模板源码网找到的这篇技巧文章能赞助到年夜野,更多技巧学程不妨在站内搜刮。