Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Users/ajya/create physical path for va #3294

Merged
merged 3 commits into from
Dec 22, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,11 @@
"loc.messages.UnknownFileEncodeError": "Unable to detect encoding of the file %s (typeCode: %s). Supported encodings are UTF-8 and UTF-16 LE.",
"loc.messages.ShortFileBufferError": "File buffer is too short to detect encoding type : %s",
"loc.messages.FailedToUpdateAzureRMWebAppConfigDetails": "Failed to update Web App config details. Error: %s",
"loc.messages.SuccessfullyUpdatedAzureRMWebAppConfigDetails": "Successfully updated Web App config details"
"loc.messages.SuccessfullyUpdatedAzureRMWebAppConfigDetails": "Successfully updated Web App config details",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

App service configuration

"loc.messages.RequestedURLforkuduphysicalpath": "Requested URL for kudu physical path : %s",
"loc.messages.Physicalpathalreadyexists": "Physical path '%s' already exists",
"loc.messages.KuduPhysicalpathCreatedSuccessfully": "Kudu physical path created successfully : %s",
"loc.messages.FailedtocreateKuduPhysicalPath": "Failed to create kudu physical path. %s: %s",
"loc.messages.FailedtocheckphysicalPath": "Failed to check kudu physical path. %s: %s",
"loc.messages.VirtualApplicationDoesNotExist": "Virtual application doesn't exists : %s"
}
16 changes: 15 additions & 1 deletion Tasks/AzureRmWebAppDeployment/azurermwebappdeployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ async function run() {
tl.setVariable(webAppUri, publishingProfile.destinationAppUrl);
}

var azureWebAppDetails = null;
if(virtualApplication) {
azureWebAppDetails = await azureRESTUtility.getAzureRMWebAppConfigDetails(endPoint, webAppName, resourceGroupName, deployToSlotFlag, slotName);
var virtualApplicationMappings = azureWebAppDetails.properties.virtualApplications;
var pathMappings = kuduUtility.getVirtualAndPhysicalPaths(virtualApplication, virtualApplicationMappings);
if("/site/wwwroot" != pathMappings[1]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compare with value when path is not created

await kuduUtility.ensurePhysicalPathExists(publishingProfile, pathMappings[1]);
} else {
throw Error(tl.loc("VirtualApplicationDoesNotExist", virtualApplication));
}
}

if(utility.canUseWebDeploy(useWebDeploy)) {
if(!tl.osType().match(/^Win/)){
throw Error(tl.loc("PublishusingwebdeployoptionsaresupportedonlywhenusingWindowsagent"));
Expand All @@ -137,7 +149,9 @@ async function run() {
additionalArguments, isFolderBasedDeployment, useWebDeploy);
} else {
tl.debug("Initiated deployment via kudu service for webapp package : " + webDeployPkg);
var azureWebAppDetails = await azureRESTUtility.getAzureRMWebAppConfigDetails(endPoint, webAppName, resourceGroupName, deployToSlotFlag, slotName);
if(azureWebAppDetails == null) {
azureWebAppDetails = await azureRESTUtility.getAzureRMWebAppConfigDetails(endPoint, webAppName, resourceGroupName, deployToSlotFlag, slotName);
}
await DeployUsingKuduDeploy(webDeployPkg, azureWebAppDetails, publishingProfile, virtualApplication, isFolderBasedDeployment, takeAppOfflineFlag);

}
Expand Down
8 changes: 7 additions & 1 deletion Tasks/AzureRmWebAppDeployment/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,12 @@
"UnknownFileEncodeError": "Unable to detect encoding of the file %s (typeCode: %s). Supported encodings are UTF-8 and UTF-16 LE.",
"ShortFileBufferError": "File buffer is too short to detect encoding type : %s",
"FailedToUpdateAzureRMWebAppConfigDetails": "Failed to update Web App config details. Error: %s",
"SuccessfullyUpdatedAzureRMWebAppConfigDetails": "Successfully updated Web App config details"
"SuccessfullyUpdatedAzureRMWebAppConfigDetails": "Successfully updated Web App config details",
"RequestedURLforkuduphysicalpath": "Requested URL for kudu physical path : %s",
"Physicalpathalreadyexists": "Physical path '%s' already exists",
"KuduPhysicalpathCreatedSuccessfully": "Kudu physical path created successfully : %s",
"FailedtocreateKuduPhysicalPath" : "Failed to create kudu physical path. %s: %s",
"FailedtocheckphysicalPath" : "Failed to check kudu physical path. %s: %s",
"VirtualApplicationDoesNotExist" : "Virtual application doesn't exists : %s"
}
}
8 changes: 7 additions & 1 deletion Tasks/AzureRmWebAppDeployment/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,12 @@
"UnknownFileEncodeError": "ms-resource:loc.messages.UnknownFileEncodeError",
"ShortFileBufferError": "ms-resource:loc.messages.ShortFileBufferError",
"FailedToUpdateAzureRMWebAppConfigDetails": "ms-resource:loc.messages.FailedToUpdateAzureRMWebAppConfigDetails",
"SuccessfullyUpdatedAzureRMWebAppConfigDetails": "ms-resource:loc.messages.SuccessfullyUpdatedAzureRMWebAppConfigDetails"
"SuccessfullyUpdatedAzureRMWebAppConfigDetails": "ms-resource:loc.messages.SuccessfullyUpdatedAzureRMWebAppConfigDetails",
"RequestedURLforkuduphysicalpath": "ms-resource:loc.messages.RequestedURLforkuduphysicalpath",
"Physicalpathalreadyexists": "ms-resource:loc.messages.Physicalpathalreadyexists",
"KuduPhysicalpathCreatedSuccessfully": "ms-resource:loc.messages.KuduPhysicalpathCreatedSuccessfully",
"FailedtocreateKuduPhysicalPath": "ms-resource:loc.messages.FailedtocreateKuduPhysicalPath",
"FailedtocheckphysicalPath": "ms-resource:loc.messages.FailedtocheckphysicalPath",
"VirtualApplicationDoesNotExist": "ms-resource:loc.messages.VirtualApplicationDoesNotExist"
}
}
56 changes: 55 additions & 1 deletion Tasks/Common/webdeployment-common/kuduutility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,58 @@ export async function containsParamFile(webAppPackage: string ) {
}
tl.debug("Is parameter file present in web package : " + isParamFilePresent);
return isParamFilePresent;
}
}

export async function ensurePhysicalPathExists(publishingProfile, physicalPath: string) {
var defer = Q.defer<string>();
physicalPath = physicalPath.replace(/[\\]/g, "/");
var kuduPhysicalpathUrl = "https://" + publishingProfile.publishUrl + "/api/vfs/" + physicalPath + "/";
var basicAuthToken = 'Basic ' + new Buffer(publishingProfile.userName + ':' + publishingProfile.userPWD).toString('base64');
var headers = {
'Authorization': basicAuthToken,
'If-Match': "*"
};
tl.debug("Requested URL for kudu physical path : " + kuduPhysicalpathUrl);

httpObj.send('GET', kuduPhysicalpathUrl, null, headers, async (error, response, body) => {
if (error) {
defer.reject(error);
}
else if (response.statusCode === 200 || response.statusCode === 201 || response.statusCode === 204) {
tl.debug("Physical path '" + physicalPath + "' already exists ");
defer.resolve(tl.loc('Physicalpathalreadyexists'));
}
else if(response.statusCode === 404) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can u add a debug log as, physical path doesn't exist, creating the path ?

defer.resolve(await createPhysicalPath(publishingProfile, physicalPath));
} else {
tl.debug(body);
defer.reject(tl.loc('FailedtocheckphysicalPath', response.statusCode, response.statusMessage));
}
});
return defer.promise;
}

async function createPhysicalPath(publishingProfile, physicalPath: string) {
var defer = Q.defer<string>();
var kuduPhysicalpathUrl = "https://" + publishingProfile.publishUrl + "/api/vfs/" + physicalPath + "/";
var basicAuthToken = 'Basic ' + new Buffer(publishingProfile.userName + ':' + publishingProfile.userPWD).toString('base64');
var headers = {
'Authorization': basicAuthToken,
'If-Match': "*"
};
tl.debug("Requested URL for kudu physical path : " + kuduPhysicalpathUrl);
httpObj.send('PUT', kuduPhysicalpathUrl, null, headers, (error, response, body) => {
if (error) {
defer.reject(error);
}
else if (response.statusCode === 200 || response.statusCode === 201 || response.statusCode === 204) {
tl.debug("Kudu physical path : '" + physicalPath + "' created successfully ");
defer.resolve(tl.loc('KuduPhysicalpathCreatedSuccessfully', physicalPath));
}
else {
tl.error(response.statusMessage);
defer.reject(tl.loc('FailedtocreateKuduPhysicalPath', response.statusCode, response.statusMessage));
}
});
return defer.promise;
}