azure - 为什么在我的发布管道中自动创建发布注释?

标签 azure azure-devops azure-web-app-service azure-application-insights

我注意到release annotations现在,当我们执行发布管道时,为几个 Application Insights 实例添加了这些内容。我们没有做文章中提到的任何事情。这些注释从哪里来?

这似乎只发生在我们的应用程序发布管道上,而不是基础设施上。我们的大多数应用程序都运行在App Service上,但并非所有应用程序都有发布注释。

最佳答案

Azure App Service Deploy Task自动创建发布注释。

唯一的先决条件是应用服务在其 AppSettings 中具有有效的 APPINSIGHTS_INSTRUMENTATIONKEY

AppService Deploy Logs

这是相关的代码块:

https://github.com/microsoft/azure-pipelines-tasks/blob/master/Tasks/Common/AzureRmDeploy-common/operations/ReleaseAnnotationUtility.ts

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/

相关文章:

c# - 如何从 Azure 角色内部检测当前订阅 ID?

.net - 如何在 Azure Pipeline 期间创建包含 build.* 变量的文件

azure - 如何延迟和安排一个阶段以仅在 Azure Devops yaml 管道中运行最新版本?

c# - Azure 错误,找不到 Internet Explorer

azure - HTTP 响应是 404 而不是 401 与authorization.json 我错过了什么吗?

sql-server - Azure 混合连接不适用于 SQL Server 命名实例

azure - Azure WebJob 内的 EventHub 注册处理器无法正常工作

java - 如何使用java在资源组中创建IoTHub资源?

azure - 自动启动/停止现有 Azure VM 作为 VSTS 中的构建代理

azure - 单租户逻辑应用如何为每个工作流设置初始状态