Skip to content

Commit 0206ae1

Browse files
authored
Check msdeploy version (#19170)
* Check msdeploy version * Fix resource files
1 parent 6a8e801 commit 0206ae1

File tree

27 files changed

+223
-81
lines changed

27 files changed

+223
-81
lines changed

Tasks/AzureRmWebAppDeploymentV3/Strings/resources.resjson/en-US/resources.resjson

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,5 +223,6 @@
223223
"loc.messages.ASE_WebDeploySSLIssueRecommendation": "To use a certificate in App Service, the certificate must be signed by a trusted certificate authority. If your web app gives you certificate validation errors, you're probably using a self-signed certificate and to resolve them you need to pass -allowUntrusted in additional arguments of web deploy option.",
224224
"loc.messages.FailedToUpdateApplicationInsightsResource": "Failed to update Application Insights '%s' Resource. Error: %s",
225225
"loc.messages.JarNotSupported": "Jar deployment is not supported in this version. Change the task version to '4.*' which is in preview mode",
226-
"loc.messages.CorrelationIdForARM": "Correlation ID from ARM api call response : %s"
226+
"loc.messages.CorrelationIdForARM": "Correlation ID from ARM api call response : %s",
227+
"loc.messages.MSDeployNotSupportTokenAuth": "App Service is configured to not use basic authentication. This requires Web Deploy msdeploy.exe version 7.1.7225 or higher. You need a version of Visual Studio that includes an updated version of msdeploy.exe. For more information, visit https://aka.ms/azdo-webapp-msdeploy ."
227228
}

Tasks/AzureRmWebAppDeploymentV3/azurermwebappdeployment.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { addReleaseAnnotation } from './operations/ReleaseAnnotationUtility';
2020
import { PackageUtility } from 'azure-pipelines-tasks-webdeployment-common/packageUtility';
2121
import { isInputPkgIsFolder, canUseWebDeploy } from 'azure-pipelines-tasks-webdeployment-common/utility';
2222
import { DeployUsingMSDeploy } from 'azure-pipelines-tasks-webdeployment-common/deployusingmsdeploy';
23-
import { shouldUseMSDeployTokenAuth} from 'azure-pipelines-tasks-webdeployment-common/msdeployutility';
23+
import { shouldUseMSDeployTokenAuth, installedMSDeployVersionSupportsTokenAuth} from 'azure-pipelines-tasks-webdeployment-common/msdeployutility';
2424

2525
async function main() {
2626
let zipDeploymentID: string;
@@ -98,21 +98,22 @@ async function main() {
9898
var msDeployPublishingProfile = await appServiceUtility.getWebDeployPublishingProfile();
9999
let authType = "Basic";
100100

101-
if (await appServiceUtility.isSitePublishingCredentialsEnabled())
102-
{
101+
if (await appServiceUtility.isSitePublishingCredentialsEnabled()) {
103102
tl.debug("Using Basic authentication.")
104103
}
105-
else if (shouldUseMSDeployTokenAuth())
106-
{
104+
else if (!shouldUseMSDeployTokenAuth()) {
105+
//deployment would fail in this case
106+
throw new Error(tl.loc("BasicAuthNotSupported"));
107+
}
108+
else if (await installedMSDeployVersionSupportsTokenAuth() === false) {
109+
//deployment would fail in this case
110+
throw new Error(tl.loc("MSDeployNotSupportTokenAuth"));
111+
}
112+
else {
107113
tl.debug("Basic authentication is disabled, using token based authentication.");
108114
authType = "Bearer";
109115
msDeployPublishingProfile.userPWD = await appServiceUtility.getAuthToken();
110116
msDeployPublishingProfile.userName = "user"; // arbitrary but not empty
111-
}
112-
else
113-
{
114-
//deployment would fail in this case
115-
throw new Error(tl.loc("BasicAuthNotSupported"));
116117
}
117118

118119
if (webPackage.toString().toLowerCase().endsWith('.war')) {

Tasks/AzureRmWebAppDeploymentV3/package-lock.json

Lines changed: 25 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tasks/AzureRmWebAppDeploymentV3/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"azure-pipelines-task-lib": "^4.4.0",
2525
"agent-base": "^6.0.2",
2626
"azure-pipelines-tasks-azure-arm-rest": "3.223.3",
27-
"azure-pipelines-tasks-webdeployment-common": "4.230.3",
27+
"azure-pipelines-tasks-webdeployment-common": "4.230.4",
2828
"decompress-zip": "^0.3.3",
2929
"ltx": "2.8.0",
3030
"moment": "^2.29.4",

Tasks/AzureRmWebAppDeploymentV3/task.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"version": {
1919
"Major": 3,
2020
"Minor": 230,
21-
"Patch": 3
21+
"Patch": 4
2222
},
2323
"releaseNotes": "What's new in Version 3.0: <br/>&nbsp;&nbsp;Supports File Transformations (XDT) <br/>&nbsp;&nbsp;Supports Variable Substitutions(XML, JSON) <br/>Click [here](https://aka.ms/azurermwebdeployreadme) for more information.",
2424
"minimumAgentVersion": "2.104.1",
@@ -765,6 +765,7 @@
765765
"ASE_WebDeploySSLIssueRecommendation": "To use a certificate in App Service, the certificate must be signed by a trusted certificate authority. If your web app gives you certificate validation errors, you're probably using a self-signed certificate and to resolve them you need to pass -allowUntrusted in additional arguments of web deploy option.",
766766
"FailedToUpdateApplicationInsightsResource": "Failed to update Application Insights '%s' Resource. Error: %s",
767767
"JarNotSupported": "Jar deployment is not supported in this version. Change the task version to '4.*' which is in preview mode",
768-
"CorrelationIdForARM": "Correlation ID from ARM api call response : %s"
768+
"CorrelationIdForARM": "Correlation ID from ARM api call response : %s",
769+
"MSDeployNotSupportTokenAuth": "App Service is configured to not use basic authentication. This requires Web Deploy msdeploy.exe version 7.1.7225 or higher. You need a version of Visual Studio that includes an updated version of msdeploy.exe. For more information, visit https://aka.ms/azdo-webapp-msdeploy ."
769770
}
770771
}

Tasks/AzureRmWebAppDeploymentV3/task.loc.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"version": {
1919
"Major": 3,
2020
"Minor": 230,
21-
"Patch": 3
21+
"Patch": 4
2222
},
2323
"releaseNotes": "ms-resource:loc.releaseNotes",
2424
"minimumAgentVersion": "2.104.1",
@@ -765,6 +765,7 @@
765765
"ASE_WebDeploySSLIssueRecommendation": "ms-resource:loc.messages.ASE_WebDeploySSLIssueRecommendation",
766766
"FailedToUpdateApplicationInsightsResource": "ms-resource:loc.messages.FailedToUpdateApplicationInsightsResource",
767767
"JarNotSupported": "ms-resource:loc.messages.JarNotSupported",
768-
"CorrelationIdForARM": "ms-resource:loc.messages.CorrelationIdForARM"
768+
"CorrelationIdForARM": "ms-resource:loc.messages.CorrelationIdForARM",
769+
"MSDeployNotSupportTokenAuth": "ms-resource:loc.messages.MSDeployNotSupportTokenAuth"
769770
}
770771
}

Tasks/AzureRmWebAppDeploymentV4/Strings/resources.resjson/en-US/resources.resjson

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,5 +225,6 @@
225225
"loc.messages.FailedToGetResourceID": "Failed to get resource ID for resource type '%s' and resource name '%s'. Error: %s",
226226
"loc.messages.JarPathNotPresent": "Java jar path is not present",
227227
"loc.messages.FailedToUpdateApplicationInsightsResource": "Failed to update Application Insights '%s' Resource. Error: %s",
228-
"loc.messages.RunFromZipPreventsFileInUseError": "Move from Web Deploy to RunFrom Package, which helps in avoiding FILE_IN_USE error. Note that Run From Package does not support msBuild package type. Please change your package format to use this deployment method."
228+
"loc.messages.RunFromZipPreventsFileInUseError": "Move from Web Deploy to RunFrom Package, which helps in avoiding FILE_IN_USE error. Note that Run From Package does not support msBuild package type. Please change your package format to use this deployment method.",
229+
"loc.messages.MSDeployNotSupportTokenAuth": "App Service is configured to not use basic authentication. This requires Web Deploy msdeploy.exe version 7.1.7225 or higher. You need a version of Visual Studio that includes an updated version of msdeploy.exe. For more information, visit https://aka.ms/azdo-webapp-msdeploy ."
229230
}

Tasks/AzureRmWebAppDeploymentV4/_buildConfigs/Node16/package-lock.json

Lines changed: 25 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tasks/AzureRmWebAppDeploymentV4/_buildConfigs/Node16/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"@types/q": "1.0.7",
2323
"azure-pipelines-task-lib": "4.4.0",
2424
"azure-pipelines-tasks-azure-arm-rest": "3.223.5",
25-
"azure-pipelines-tasks-webdeployment-common": "4.230.3",
25+
"azure-pipelines-tasks-webdeployment-common": "4.230.4",
2626
"moment": "^2.29.4",
2727
"q": "1.4.1",
2828
"uuid": "3.1.0",

Tasks/AzureRmWebAppDeploymentV4/operations/WebDeployUtility.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import tl = require('azure-pipelines-task-lib/task');
22

3-
import { TaskParameters } from './TaskParameters';
4-
import { WebDeployArguments, WebDeployResult } from 'azure-pipelines-tasks-webdeployment-common/msdeployutility';
3+
import { WebDeployArguments, WebDeployResult, shouldUseMSDeployTokenAuth, installedMSDeployVersionSupportsTokenAuth } from 'azure-pipelines-tasks-webdeployment-common/msdeployutility';
54
import { executeWebDeploy } from 'azure-pipelines-tasks-webdeployment-common/deployusingmsdeploy';
65
import { copySetParamFileIfItExists } from 'azure-pipelines-tasks-webdeployment-common/utility';
6+
7+
import { TaskParameters } from './TaskParameters';
78
import { AzureAppServiceUtility } from './AzureAppServiceUtility';
8-
import { shouldUseMSDeployTokenAuth } from 'azure-pipelines-tasks-webdeployment-common/msdeployutility'
99

1010
const DEFAULT_RETRY_COUNT = 3;
1111

@@ -61,14 +61,17 @@ export class WebDeployUtility {
6161
webDeployArguments.userName = publishProfile.userName;
6262
webDeployArguments.password = publishProfile.userPWD;
6363
}
64-
else if (shouldUseMSDeployTokenAuth()) {
64+
else if (!shouldUseMSDeployTokenAuth()) {
65+
throw new Error(tl.loc("BasicAuthNotSupported"));
66+
}
67+
else if (await installedMSDeployVersionSupportsTokenAuth() === false) {
68+
throw new Error(tl.loc("MSDeployNotSupportTokenAuth"));
69+
}
70+
else {
6571
tl.debug("Basic authentication is disabled, using token based authentication.");
6672
webDeployArguments.authType = "Bearer";
6773
webDeployArguments.password = await this._azureAppServiceUtility.getAuthToken();
6874
webDeployArguments.userName = "user"; // arbitrary but not empty
69-
}
70-
else {
71-
throw new Error(tl.loc("BasicAuthNotSupported"));
7275
}
7376

7477
webDeployArguments.publishUrl = publishProfile.publishUrl;

0 commit comments

Comments
 (0)