Added list and update in webapp sample
This commit is contained in:
Родитель
fa5e117030
Коммит
8f3efa6674
|
@ -38,9 +38,11 @@ var webSiteClient = new WebSiteManagement(credentials, subscriptionId);
|
|||
// 1. create a resource group
|
||||
// 2. create a hosting plan
|
||||
// 3. create a website
|
||||
// 4. get website detials info
|
||||
// 5. delete website
|
||||
// 6. delete resource group
|
||||
// 4. list websites for given subscription
|
||||
// 5. get details for a given website
|
||||
// 6. update site config(number of workers and phpversion) for a website
|
||||
// 7. delete a website
|
||||
// 8. delete the resource group
|
||||
async.series([
|
||||
function(callback) {
|
||||
createResourceGroup(function(err, result, request, response) {
|
||||
|
@ -66,6 +68,16 @@ async.series([
|
|||
callback(null, result);
|
||||
});
|
||||
},
|
||||
function(callback) {
|
||||
listWebsites(function(err, result, request, response) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
console.log(util.format('\nWebsites in subscription %s : \n%s',
|
||||
subscriptionId, util.inspect(result, { depth: null })));
|
||||
callback(null, result);
|
||||
});
|
||||
},
|
||||
function(callback) {
|
||||
getWebSite(function(err, result, request, response) {
|
||||
if (err) {
|
||||
|
@ -76,6 +88,16 @@ async.series([
|
|||
callback(null, result);
|
||||
});
|
||||
},
|
||||
function(callback) {
|
||||
updateWebisteConfig(function(err, result, request, response) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
console.log(util.format('\nWeb site details: \n%s',
|
||||
util.inspect(result, { depth: null })));
|
||||
callback(null, result);
|
||||
});
|
||||
},
|
||||
function(callback) {
|
||||
deleteWebSite(function(err, result, request, response) {
|
||||
if (err) {
|
||||
|
@ -91,11 +113,11 @@ async.series([
|
|||
console.log(util.format('\n??????Error occurred in one of the operations.\n%s',
|
||||
util.inspect(err, { depth: null })));
|
||||
} else {
|
||||
console.log(util.format('\n######All the operations have completed successfully. ' +
|
||||
'The final set of results are as follows:\n%s', util.inspect(results, { depth: null })));
|
||||
console.log(util.format('\n######All the operations have completed successfully. ' ));
|
||||
}
|
||||
// clean up
|
||||
deleteResourceGroup(function(err, result, request, response) {
|
||||
console.log('\n###### Exit ######')
|
||||
process.exit();
|
||||
});
|
||||
}
|
||||
|
@ -138,23 +160,33 @@ function createHostingPlan(callback) {
|
|||
function createWebSite(callback) {
|
||||
var parameters = {
|
||||
location: location,
|
||||
serverFarmId: hostingPlanName,
|
||||
webSite: {
|
||||
properties: {
|
||||
serverFarm: hostingPlanName
|
||||
}
|
||||
}
|
||||
serverFarmId: hostingPlanName
|
||||
};
|
||||
var siteEnvelope = { "location": location };
|
||||
console.log('\nCreating web site: ' + webSiteName);
|
||||
return webSiteClient.sites.createOrUpdateSite(resourceGroupName, webSiteName, parameters, null, callback);
|
||||
}
|
||||
|
||||
function getWebSite(callback) {
|
||||
console.log('\nGeting info of : ' + webSiteName);
|
||||
console.log('\nGetting info of : ' + webSiteName);
|
||||
return webSiteClient.sites.getSite(resourceGroupName, webSiteName, callback);
|
||||
}
|
||||
|
||||
function listWebsites(callback) {
|
||||
console.log('\nListing websits in subscription : ' + subscriptionId);
|
||||
return webSiteClient.sites.getSites(resourceGroupName, null, callback);
|
||||
}
|
||||
|
||||
function updateWebisteConfig(callback) {
|
||||
var siteConfig = {
|
||||
location: location,
|
||||
serverFarmId: hostingPlanName,
|
||||
numberOfWorkers: 2,
|
||||
phpVersion: '5.5'
|
||||
};
|
||||
console.log('\nUpdating config for website : ' + webSiteName);
|
||||
return webSiteClient.sites.createOrUpdateSiteConfig(resourceGroupName, webSiteName, siteConfig, null, callback);
|
||||
}
|
||||
|
||||
function deleteWebSite(callback) {
|
||||
console.log('\nDeleting web site : ' + webSiteName);
|
||||
return webSiteClient.sites.deleteSite(resourceGroupName, webSiteName, callback);
|
||||
|
|
Загрузка…
Ссылка в новой задаче