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/arjgupta/wait for app to start #4058

Merged
merged 4 commits into from
Apr 19, 2017
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -57,5 +57,6 @@
"loc.messages.ExtensionAlreadyAvaiable": "Extension '%s' already available in Azure App Service.",
"loc.messages.ExtensionListFailedError": "Failed to retrieve list of extensions installed in Azure App Service. Error %s.",
"loc.messages.ExtensionListFailedResponseError": "Failed to retrieve list of extensions installed in Azure App Service. Status Code: %s (%s)",
"loc.messages.InstallingSiteExtension": "Installing site extension '%s' in Azure App Service."
"loc.messages.InstallingSiteExtension": "Installing site extension '%s' in Azure App Service.",
"loc.messages.FailedToFetchAppServiceState": "Failed to fetch App Service State for App Service: %s, Error Code: %s, Error Message: %s"
}
5 changes: 5 additions & 0 deletions Tasks/AzureAppServiceManage/azureappservicemanage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ 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);
while(!(appServiceDetails.properties.state == "Running" || appServiceDetails.properties.state == "running"))
{
appServiceDetails = await azureRmUtil.getAppServiceDetails(endPoint, resourceGroupName, webAppName, specifySlotFlag, slotName);
}
break;
}
case "Stop Azure App Service": {
Expand Down
5 changes: 3 additions & 2 deletions Tasks/AzureAppServiceManage/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"version": {
"Major": 0,
"Minor": 2,
"Patch": 6
"Patch": 7
},
"minimumAgentVersion": "1.102.0",
"instanceNameFormat": "$(Action): $(WebAppName)",
Expand Down Expand Up @@ -242,6 +242,7 @@
"ExtensionAlreadyAvaiable": "Extension '%s' already available in Azure App Service.",
"ExtensionListFailedError": "Failed to retrieve list of extensions installed in Azure App Service. Error %s.",
"ExtensionListFailedResponseError": "Failed to retrieve list of extensions installed in Azure App Service. Status Code: %s (%s)",
"InstallingSiteExtension": "Installing site extension '%s' in Azure App Service."
"InstallingSiteExtension": "Installing site extension '%s' in Azure App Service.",
"FailedToFetchAppServiceState": "Failed to fetch App Service State for App Service: %s, Error Code: %s, Error Message: %s"
}
}
5 changes: 3 additions & 2 deletions Tasks/AzureAppServiceManage/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"version": {
"Major": 0,
"Minor": 2,
"Patch": 6
"Patch": 7
},
"minimumAgentVersion": "1.102.0",
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
Expand Down Expand Up @@ -242,6 +242,7 @@
"ExtensionAlreadyAvaiable": "ms-resource:loc.messages.ExtensionAlreadyAvaiable",
"ExtensionListFailedError": "ms-resource:loc.messages.ExtensionListFailedError",
"ExtensionListFailedResponseError": "ms-resource:loc.messages.ExtensionListFailedResponseError",
"InstallingSiteExtension": "ms-resource:loc.messages.InstallingSiteExtension"
"InstallingSiteExtension": "ms-resource:loc.messages.InstallingSiteExtension",
"FailedToFetchAppServiceState": "ms-resource:loc.messages.FailedToFetchAppServiceState"
}
}
29 changes: 29 additions & 0 deletions Tasks/Common/azurerest-common/azurerestutility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,35 @@ export async function testAzureWebAppAvailability(webAppUrl, availabilityTimeout
return deferred.promise;
}

export async function getAppServiceDetails(endpoint, resourceGroupName: string, webAppName: string, specifySlotFlag: boolean, slotName: string) {

var deferred = Q.defer<any>();
var slotUrl = (specifySlotFlag) ? "/slots/" + slotName : "";
var url = endpoint.url + 'subscriptions/' + endpoint.subscriptionId + '/resourceGroups/' + resourceGroupName +
'/providers/Microsoft.Web/sites/' + webAppName + slotUrl + "?" + azureApiVersion;

var accessToken = await getAuthorizationToken(endpoint);
var headers = {
'Authorization': 'Bearer '+ accessToken
};
var webAppNameWithSlot = (specifySlotFlag) ? webAppName + '-' + slotName : webAppName;
tl.debug('Request to get App State: ' + webAppNameWithSlot);
httpObj.send('GET', url, null, headers, (error, response, body) => {
if(error) {
console.log(body);
deferred.reject(error);
}
if(response.statusCode === 200 || response.statusCode === 204) {
deferred.resolve(JSON.parse(body));
}
else {
console.log(body);
deferred.reject(tl.loc("FailedToFetchAppServiceState", webAppNameWithSlot, response.statusCode, response.statusMessage));
}
});
return deferred.promise;
}

function sleep(timeInMilliSecond) {
return new Promise(resolve => setTimeout(resolve,timeInMilliSecond));
}