我注意到release annotations现在,当我们执行发布管道时,为几个 Application Insights 实例添加了这些内容。我们没有做文章中提到的任何事情。这些注释从哪里来?
这似乎只发生在我们的应用程序发布管道上,而不是基础设施上。我们的大多数应用程序都运行在App Service上,但并非所有应用程序都有发布注释。
最佳答案
Azure App Service Deploy Task自动创建发布注释。
唯一的先决条件是应用服务在其 AppSettings 中具有有效的 APPINSIGHTS_INSTRUMENTATIONKEY
。
这是相关的代码块:
export async function addReleaseAnnotation(endpoint: AzureEndpoint, azureAppService: AzureAppService, isDeploymentSuccess: boolean): Promise<void> {
try {
var appSettings = await azureAppService.getApplicationSettings();
var instrumentationKey = appSettings && appSettings.properties && appSettings.properties.APPINSIGHTS_INSTRUMENTATIONKEY;
if(instrumentationKey) {
let appinsightsResources: ApplicationInsightsResources = new ApplicationInsightsResources(endpoint);
var appInsightsResources = await appinsightsResources.list(null, [`$filter=InstrumentationKey eq '${instrumentationKey}'`]);
if(appInsightsResources.length > 0) {
var appInsights: AzureApplicationInsights = new AzureApplicationInsights(endpoint, appInsightsResources[0].id.split('/')[4], appInsightsResources[0].name);
var releaseAnnotationData = getReleaseAnnotation(isDeploymentSuccess);
await appInsights.addReleaseAnnotation(releaseAnnotationData);
console.log(tl.loc("SuccessfullyAddedReleaseAnnotation", appInsightsResources[0].name));
}
关于azure - 为什么在我的发布管道中自动创建发布注释?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67217760/