public WebHostingPlanCreateOrUpdateResponse CreateAppServicePlan(string resourceGroupName, string whpName, string location, string adminSiteName, int numberOfWorkers, SkuOptions sku, WorkerSizeOptions workerSize) { WebHostingPlanProperties webHostingPlanProperties = new WebHostingPlanProperties(); webHostingPlanProperties.Sku = sku; webHostingPlanProperties.AdminSiteName = adminSiteName; webHostingPlanProperties.NumberOfWorkers = numberOfWorkers; webHostingPlanProperties.WorkerSize = workerSize; WebHostingPlan webHostingPlan = new WebHostingPlan(); WebHostingPlanCreateOrUpdateParameters webHostingPlanCreateOrUpdateParameters = new WebHostingPlanCreateOrUpdateParameters(webHostingPlan); webHostingPlanCreateOrUpdateParameters.WebHostingPlan.Location = location; webHostingPlanCreateOrUpdateParameters.WebHostingPlan.Name = whpName; webHostingPlanCreateOrUpdateParameters.WebHostingPlan.Properties = webHostingPlanProperties; var createdWHP = WrappedWebsitesClient.WebHostingPlans.CreateOrUpdate(resourceGroupName, webHostingPlanCreateOrUpdateParameters); //proper return type need to be discussed return(createdWHP); }
private void RunWebsiteTestScenario(WebsiteTestDelegate testAction, SkuOptions sku = SkuOptions.Shared) { var handler = new RecordedDelegatingHandler() { StatusCodeToReturn = HttpStatusCode.OK }; using (UndoContext context = UndoContext.Current) { context.Start(4); WebSiteManagementClient webSitesClient = ResourceGroupHelper.GetWebSitesClient(handler); ResourceManagementClient resourcesClient = ResourceGroupHelper.GetResourcesClient(handler); string webSiteName = TestUtilities.GenerateName("csmws"); string resourceGroupName = TestUtilities.GenerateName("csmrg"); string webHostingPlanName = TestUtilities.GenerateName("csmwhp"); string location = ResourceGroupHelper.GetResourceLocation(resourcesClient, "Microsoft.Web/sites"); resourcesClient.ResourceGroups.CreateOrUpdate(resourceGroupName, new ResourceGroup { Location = location }); webSitesClient.WebHostingPlans.CreateOrUpdate(resourceGroupName, new WebHostingPlanCreateOrUpdateParameters { WebHostingPlan = new WebHostingPlan { Name = webHostingPlanName, Location = location, Properties = new WebHostingPlanProperties() { Sku = sku } } }); var webSite = webSitesClient.WebSites.CreateOrUpdate(resourceGroupName, webSiteName, null, new WebSiteCreateOrUpdateParameters { WebSite = new WebSiteBase { Name = webSiteName, Location = location, Tags = new Dictionary <string, string> { { "tag1", "value1" }, { "tag2", "" } }, Properties = new WebSiteBaseProperties { ServerFarm = webHostingPlanName } } }); Assert.Equal(webSiteName, webSite.WebSite.Name); Assert.Equal(webSite.WebSite.Properties.ServerFarm, webHostingPlanName); Assert.Equal("value1", webSite.WebSite.Tags["tag1"]); Assert.Equal("", webSite.WebSite.Tags["tag2"]); testAction(webSiteName, resourceGroupName, webHostingPlanName, location, webSitesClient, resourcesClient); } }
public WebHostingPlanCreateOrUpdateResponse CreateAppServicePlan(string resourceGroupName, string whpName, string location, string adminSiteName, int numberOfWorkers, SkuOptions sku, WorkerSizeOptions workerSize) { WebHostingPlanProperties webHostingPlanProperties = new WebHostingPlanProperties(); webHostingPlanProperties.Sku = sku; webHostingPlanProperties.AdminSiteName = adminSiteName; webHostingPlanProperties.NumberOfWorkers = numberOfWorkers; webHostingPlanProperties.WorkerSize = workerSize; WebHostingPlan webHostingPlan = new WebHostingPlan(); WebHostingPlanCreateOrUpdateParameters webHostingPlanCreateOrUpdateParameters = new WebHostingPlanCreateOrUpdateParameters(webHostingPlan); webHostingPlanCreateOrUpdateParameters.WebHostingPlan.Location = location; webHostingPlanCreateOrUpdateParameters.WebHostingPlan.Name = whpName; webHostingPlanCreateOrUpdateParameters.WebHostingPlan.Properties = webHostingPlanProperties; var createdWHP = WrappedWebsitesClient.WebHostingPlans.CreateOrUpdate(resourceGroupName, webHostingPlanCreateOrUpdateParameters); //proper return type need to be discussed return createdWHP; }
private void RunWebsiteTestScenario(WebsiteTestDelegate testAction, SkuOptions sku = SkuOptions.Shared) { var handler = new RecordedDelegatingHandler() { StatusCodeToReturn = HttpStatusCode.OK }; using (UndoContext context = UndoContext.Current) { context.Start(4); WebSiteManagementClient webSitesClient = ResourceGroupHelper.GetWebSitesClient(handler); ResourceManagementClient resourcesClient = ResourceGroupHelper.GetResourcesClient(handler); string webSiteName = TestUtilities.GenerateName("csmws"); string resourceGroupName = TestUtilities.GenerateName("csmrg"); string webHostingPlanName = TestUtilities.GenerateName("csmwhp"); string location = ResourceGroupHelper.GetResourceLocation(resourcesClient, "Microsoft.Web/sites"); resourcesClient.ResourceGroups.CreateOrUpdate(resourceGroupName, new ResourceGroup { Location = location }); webSitesClient.WebHostingPlans.CreateOrUpdate(resourceGroupName, new WebHostingPlanCreateOrUpdateParameters { WebHostingPlan = new WebHostingPlan { Name = webHostingPlanName, Location = location, Properties = new WebHostingPlanProperties() { Sku = sku } } }); var webSite = webSitesClient.WebSites.CreateOrUpdate(resourceGroupName, webSiteName, null, new WebSiteCreateOrUpdateParameters { WebSite = new WebSiteBase { Name = webSiteName, Location = location, Tags = new Dictionary<string, string> { { "tag1", "value1" }, { "tag2", "" } }, Properties = new WebSiteBaseProperties { ServerFarm = webHostingPlanName } } }); Assert.Equal(webSiteName, webSite.WebSite.Name); Assert.Equal(webSite.WebSite.Properties.ServerFarm, webHostingPlanName); Assert.Equal("value1", webSite.WebSite.Tags["tag1"]); Assert.Equal("", webSite.WebSite.Tags["tag2"]); testAction(webSiteName, resourceGroupName, webHostingPlanName, location, webSitesClient, resourcesClient); } }
public override void ExecuteCmdlet() { //for now not asking admin site name need to implement in future string adminSiteName = null; //if Sku is not specified assume default to be Standard SkuOptions skuInput = SkuOptions.Standard; //if workerSize is not specified assume default to be small WorkerSizeOptions workerSizeInput = WorkerSizeOptions.Small; //if NumberofWorkers is not specified assume default to be 1 if (NumberofWorkers == 0) { NumberofWorkers = 1; } if (WorkerSize != null) { switch (WorkerSize.ToUpper()) { case "SMALL": workerSizeInput = WorkerSizeOptions.Small; break; case "MEDIUM": workerSizeInput = WorkerSizeOptions.Medium; break; case "LARGE": workerSizeInput = WorkerSizeOptions.Large; break; default: workerSizeInput = WorkerSizeOptions.Large; break; } } if (Sku != null) { switch (Sku.ToUpper()) { case "FREE": skuInput = SkuOptions.Free; break; case "SHARED": skuInput = SkuOptions.Shared; break; case "BASIC": skuInput = SkuOptions.Basic; break; case "PREMIUM": skuInput = SkuOptions.Premium; break; default: skuInput = SkuOptions.Standard; break; } } WriteObject(WebsitesClient.CreateAppServicePlan(ResourceGroupName, Name, Location, adminSiteName, NumberofWorkers, skuInput, workerSizeInput)); }