Skip to content

Commit 9e83b9a

Browse files
authored
Adding release annotation using connection string (#20895)
* adding release annotation using connection string * adding release ann using connection string
1 parent c68bd26 commit 9e83b9a

File tree

6 files changed

+44
-10
lines changed

6 files changed

+44
-10
lines changed

Tasks/AzureRmWebAppDeploymentV4/operations/ReleaseAnnotationUtility.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var uuidV4 = require("uuid/v4");
88
export async function addReleaseAnnotation(endpoint: AzureEndpoint, azureAppService: AzureAppService, isDeploymentSuccess: boolean): Promise<void> {
99
try {
1010
var appSettings = await azureAppService.getApplicationSettings();
11-
var instrumentationKey = appSettings && appSettings.properties && appSettings.properties.APPINSIGHTS_INSTRUMENTATIONKEY;
11+
var instrumentationKey = getInstrumentationKey(appSettings);
1212
if(instrumentationKey) {
1313
let appinsightsResources: ApplicationInsightsResources = new ApplicationInsightsResources(endpoint);
1414
var appInsightsResources = await appinsightsResources.list(null, [`$filter=InstrumentationKey eq '${instrumentationKey}'`]);
@@ -90,4 +90,21 @@ function getPipelineVariable(variableName: string): string | undefined {
9090
let variable = tl.getVariable(variableName);
9191
//we dont want to set a variable to be empty string
9292
return !!variable ? variable : undefined;
93+
}
94+
95+
function getInstrumentationKey(appSettings: any): string | undefined {
96+
let connectionString = appSettings?.properties?.APPLICATIONINSIGHTS_CONNECTION_STRING;
97+
if (connectionString) {
98+
const FIELDS_SEPARATOR = ";";
99+
const FIELD_KEY_VALUE_SEPARATOR = "=";
100+
101+
const kvPairs = connectionString.split(FIELDS_SEPARATOR);
102+
for (const kvPair of kvPairs) {
103+
const pair = kvPair.split(FIELD_KEY_VALUE_SEPARATOR);
104+
if (pair.length === 2 && pair[0].trim().toLowerCase() === "instrumentationkey") {
105+
return pair[1].trim();
106+
}
107+
}
108+
}
109+
return appSettings?.properties?.APPINSIGHTS_INSTRUMENTATIONKEY;
93110
}

Tasks/AzureRmWebAppDeploymentV4/task.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
"author": "Microsoft Corporation",
1818
"version": {
1919
"Major": 4,
20-
"Minor": 247,
21-
"Patch": 1
20+
"Minor": 254,
21+
"Patch": 0
2222
},
2323
"releaseNotes": "What's new in version 4.*<br />Supports Zip Deploy, Run From Package, War Deploy [Details here](https://aka.ms/appServiceDeploymentMethods)<br />Supports App Service Environments<br />Improved UI for discovering different App service types supported by the task<br/>Run From Package is the preferred deployment method, which makes files in wwwroot folder read-only<br/>Click [here](https://aka.ms/azurermwebdeployreadme) for more information.",
2424
"minimumAgentVersion": "2.104.1",

Tasks/AzureRmWebAppDeploymentV4/task.loc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
"author": "Microsoft Corporation",
1818
"version": {
1919
"Major": 4,
20-
"Minor": 247,
21-
"Patch": 1
20+
"Minor": 254,
21+
"Patch": 0
2222
},
2323
"releaseNotes": "ms-resource:loc.releaseNotes",
2424
"minimumAgentVersion": "2.104.1",

Tasks/AzureRmWebAppDeploymentV5/operations/ReleaseAnnotationUtility.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var uuidV4 = require("uuid/v4");
88
export async function addReleaseAnnotation(endpoint: AzureEndpoint, azureAppService: AzureAppService, isDeploymentSuccess: boolean): Promise<void> {
99
try {
1010
var appSettings = await azureAppService.getApplicationSettings();
11-
var instrumentationKey = appSettings && appSettings.properties && appSettings.properties.APPINSIGHTS_INSTRUMENTATIONKEY;
11+
var instrumentationKey = getInstrumentationKey(appSettings);
1212
if(instrumentationKey) {
1313
let appinsightsResources: ApplicationInsightsResources = new ApplicationInsightsResources(endpoint);
1414
var appInsightsResources = await appinsightsResources.list(null, [`$filter=InstrumentationKey eq '${instrumentationKey}'`]);
@@ -90,4 +90,21 @@ function getPipelineVariable(variableName: string): string | undefined {
9090
let variable = tl.getVariable(variableName);
9191
//we dont want to set a variable to be empty string
9292
return !!variable ? variable : undefined;
93+
}
94+
95+
function getInstrumentationKey(appSettings: any): string | undefined {
96+
let connectionString = appSettings?.properties?.APPLICATIONINSIGHTS_CONNECTION_STRING;
97+
if (connectionString) {
98+
const FIELDS_SEPARATOR = ";";
99+
const FIELD_KEY_VALUE_SEPARATOR = "=";
100+
101+
const kvPairs = connectionString.split(FIELDS_SEPARATOR);
102+
for (const kvPair of kvPairs) {
103+
const pair = kvPair.split(FIELD_KEY_VALUE_SEPARATOR);
104+
if (pair.length === 2 && pair[0].trim().toLowerCase() === "instrumentationkey") {
105+
return pair[1].trim();
106+
}
107+
}
108+
}
109+
return appSettings?.properties?.APPINSIGHTS_INSTRUMENTATIONKEY;
93110
}

Tasks/AzureRmWebAppDeploymentV5/task.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
"author": "Microsoft Corporation",
1818
"version": {
1919
"Major": 5,
20-
"Minor": 252,
21-
"Patch": 5
20+
"Minor": 254,
21+
"Patch": 0
2222
},
2323
"releaseNotes": "What's new in version 4.*<br />Supports Zip Deploy, Run From Package, War Deploy [Details here](https://aka.ms/appServiceDeploymentMethods)<br />Supports App Service Environments<br />Improved UI for discovering different App service types supported by the task<br/>Run From Package is the preferred deployment method, which makes files in wwwroot folder read-only<br/>Click [here](https://aka.ms/azurermwebdeployreadme) for more information.",
2424
"minimumAgentVersion": "2.104.1",

Tasks/AzureRmWebAppDeploymentV5/task.loc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
"author": "Microsoft Corporation",
1818
"version": {
1919
"Major": 5,
20-
"Minor": 252,
21-
"Patch": 5
20+
"Minor": 254,
21+
"Patch": 0
2222
},
2323
"releaseNotes": "ms-resource:loc.releaseNotes",
2424
"minimumAgentVersion": "2.104.1",

0 commit comments

Comments
 (0)