-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Azure App service Manage & Deploy Task Spec changes #4125
Changes from 11 commits
0cf2859
3f4a15f
6a8d626
360cca0
8c5c02a
9e87356
943e6a8
a4479fa
9f35e22
6415853
1340920
1f1e813
0bbfb17
73df314
86c9bf5
3500570
4f16b46
9ab7ef1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,26 @@ async function updateKuduDeploymentLog(endPoint, webAppName, resourceGroupName, | |
} | ||
} | ||
|
||
async function waitForAppServiceToStart(endPoint, resourceGroupName, webAppName, specifySlotFlag, slotName) { | ||
|
||
while(true) { | ||
var appServiceDetails = await azureRmUtil.getAppServiceDetails(endPoint, resourceGroupName, webAppName, specifySlotFlag, slotName); | ||
if(appServiceDetails.hasOwnProperty("properties") && appServiceDetails.properties.hasOwnProperty("state")) { | ||
tl.debug('App Service State : ' + appServiceDetails.properties.state); | ||
if(appServiceDetails.properties.state == "Running" || appServiceDetails.properties.state == "running") { | ||
tl.debug('App Service is in Running State'); | ||
break; | ||
} | ||
else { | ||
tl.debug('App Service State : ' + appServiceDetails.properties.state); | ||
continue; | ||
} | ||
} | ||
tl.debug('Unable to find state of the App Service.'); | ||
break; | ||
} | ||
} | ||
|
||
async function run() { | ||
try { | ||
tl.setResourcePath(path.join( __dirname, 'task.json')); | ||
|
@@ -42,6 +62,7 @@ async function run() { | |
var targetSlot: string = tl.getInput('TargetSlot', false); | ||
var preserveVnet: boolean = tl.getBoolInput('PreserveVnet', false); | ||
var extensionList = tl.getInput('ExtensionsList', false); | ||
var extensionOutputVariables = tl.getInput('OutputVariable').split(","); | ||
var endPointAuthCreds = tl.getEndpointAuthorization(connectedServiceName, true); | ||
var subscriptionId = tl.getEndpointDataParameter(connectedServiceName, 'subscriptionid', true); | ||
var taskResult = true; | ||
|
@@ -62,14 +83,7 @@ async function run() { | |
switch(action) { | ||
case "Start Azure App Service": { | ||
console.log(await azureRmUtil.startAppService(endPoint, resourceGroupName, webAppName, specifySlotFlag, slotName)); | ||
var appServiceDetails = await azureRmUtil.getAppServiceDetails(endPoint, resourceGroupName, webAppName, specifySlotFlag, slotName); | ||
if(appServiceDetails.hasOwnProperty("properties") && appServiceDetails.properties.hasOwnProperty("state")) | ||
{ | ||
while(!(appServiceDetails.properties.state == "Running" || appServiceDetails.properties.state == "running")) | ||
{ | ||
appServiceDetails = await azureRmUtil.getAppServiceDetails(endPoint, resourceGroupName, webAppName, specifySlotFlag, slotName); | ||
} | ||
} | ||
await waitForAppServiceToStart(endPoint, resourceGroupName, webAppName, specifySlotFlag, slotName); | ||
break; | ||
} | ||
case "Stop Azure App Service": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we wait for Stop as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stop actually stops the App Service to accept any request. We should be good here. |
||
|
@@ -80,14 +94,15 @@ async function run() { | |
resourceGroupName = (specifySlotFlag ? resourceGroupName : await azureRmUtil.getResourceGroupName(endPoint, webAppName)); | ||
var publishingProfile = await azureRmUtil.getAzureRMWebAppPublishProfile(endPoint, webAppName, resourceGroupName, specifySlotFlag, slotName); | ||
tl.debug('Retrieved publishing Profile'); | ||
var anyExtensionInstalled = await extensionManage.installExtensions(publishingProfile, extensionList.split(',')); | ||
var anyExtensionInstalled = await extensionManage.installExtensions(publishingProfile, extensionList.split(','), extensionOutputVariables); | ||
if(!anyExtensionInstalled) { | ||
tl.debug('No new extension installed. Skipping Restart App Service.'); | ||
break; | ||
} | ||
} | ||
case "Restart Azure App Service": { | ||
console.log(await azureRmUtil.restartAppService(endPoint, resourceGroupName, webAppName, specifySlotFlag, slotName)); | ||
await waitForAppServiceToStart(endPoint, resourceGroupName, webAppName, specifySlotFlag, slotName); | ||
break; | ||
} | ||
case "Swap Slots": { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ export async function getInstalledExtensions(publishingProfile) { | |
var extensionsList = JSON.parse(body); | ||
for(var extension of extensionsList) { | ||
tl.debug('* ' + extension['id']); | ||
installedExtensionsList[extension['id']] = extension['title']; | ||
installedExtensionsList[extension['id']] = extension; | ||
} | ||
defer.resolve(installedExtensionsList); | ||
} | ||
|
@@ -52,8 +52,9 @@ export async function installExtension(publishingProfile, extension: string) { | |
} | ||
else if(response.statusCode === 200) { | ||
tl.debug(body); | ||
console.log(tl.loc('ExtensionInstallSuccess', extension)); | ||
defer.resolve(JSON.parse(body)); | ||
var responseBody = JSON.parse(body); | ||
console.log(tl.loc('ExtensionInstallSuccess', responseBody['title'])); | ||
defer.resolve(responseBody); | ||
} | ||
else { | ||
console.log(body); | ||
|
@@ -64,19 +65,48 @@ export async function installExtension(publishingProfile, extension: string) { | |
return defer.promise; | ||
} | ||
|
||
export async function installExtensions(publishingProfile, extensions: Array<string>) { | ||
export async function installExtensions(publishingProfile, extensions: Array<string>, extensionOutputVariables: Array<string>) { | ||
|
||
var outputVariableCount = 0; | ||
var outputVariableSize = extensionOutputVariables.length; | ||
var InstalledExtensions = await getInstalledExtensions(publishingProfile); | ||
var extensionInfo = null; | ||
var anyExtensionInstalled = false; | ||
for(var extension of extensions) { | ||
extension = extension.trim(); | ||
if(InstalledExtensions[extension]) { | ||
console.log(tl.loc('ExtensionAlreadyAvaiable', InstalledExtensions[extension])); | ||
extensionInfo = InstalledExtensions[extension]; | ||
console.log(tl.loc('ExtensionAlreadyAvaiable', extensionInfo['title'])); | ||
} | ||
else { | ||
tl.debug("Extension '" + extension + "' not installed. Installing..."); | ||
await installExtension(publishingProfile, extension); | ||
extensionInfo = await installExtension(publishingProfile, extension); | ||
anyExtensionInstalled = true; | ||
} | ||
if(outputVariableCount < outputVariableSize) { | ||
var extensionLocalPath: string = getExtensionLocalPath(extensionInfo); | ||
tl.debug('Set Variable ' + extensionOutputVariables[outputVariableCount] + ' to value: ' + extensionLocalPath); | ||
tl.setVariable(extensionOutputVariables[outputVariableCount], extensionLocalPath); | ||
outputVariableCount += 1; | ||
} | ||
} | ||
return anyExtensionInstalled; | ||
} | ||
|
||
function getExtensionLocalPath(extensionInfo: JSON): string { | ||
var extensionId: string = extensionInfo['id']; | ||
var homeDir = "D:\\home\\"; | ||
|
||
if(extensionId.startsWith('python2')) { | ||
return homeDir + "Python27"; | ||
} | ||
else if(extensionId.startsWith('python351') || extensionId.startsWith('python352')) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this may not be required as we are not showing option to install 3.5 < python version < 3.5.3 ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Additional check, if we add them. |
||
return homeDir + "Python35"; | ||
} | ||
else if(extensionId.startsWith('python3')) { | ||
return homeDir + extensionId; | ||
} | ||
else { | ||
return extensionInfo['local_path']; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,5 +140,9 @@ | |
"loc.messages.ScriptStatusTimeout": "Unable to fetch script status due to timeout.", | ||
"loc.messages.PollingForFileTimeOut": "Unable to fetch script status due to timeout. You can increase the timeout limit by setting 'appservicedeploy.retrytimeout' variable to number of minutes required.", | ||
"loc.messages.InvalidPollOption": "Invalid polling option provided: %s.", | ||
"loc.messages.MissingWebConfigParameters": "Some web.config parameters are missing" | ||
"loc.messages.MissingAppTypeWebConfigParameters": "-appType attribute is missing in Web.config parameters.", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is apptype the only config param that can be missing? Should we also report if other required parameters are not present? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can override with default values. I ll update it in this PR. |
||
"loc.messages.AutoDetectDjangoSettingsFailed": "Unable to detect DJANGO_SETTINGS_MODULE (settings.py). Please ensure that the file exists or provide the correct path in Web.config parameters input in the following format '<folder_name>.settings'", | ||
"loc.messages.FailedToApplyTransformation": "Unable to apply transformation for the given package. Please follow below steps to debug the issue. \n1. Transformation is applied for MSBuild generated packge during build time. Remove <DependentUpon> Tag for each config file. \n2. Ensure that the config file and transformation file are present in the same folder inside the package.", | ||
"loc.messages.AutoParameterizationMessage": "ConnectionString attributes in Web.config is parameterized by default. Please be aware that transformation has no effect on connectioString attributes as the same value is overridden during deployment. You can disable the auto parameterization by setting /p:AutoParameterizationWebConfigConnectionStrings=False during MSBuild package generation.", | ||
"loc.messages.UnsupportedAppType": "App type '%s' not supported in Web.config generation." | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Provide the variable name for the local installation path for the selected extension.
Note: In case of multiple extensions selected for installation, provide comma separated list of variables that saves the local path for each of the selected extension in the order it appears in the Install Extension field"