public static void ScaleUpDown(IAppServicePlan appServicePlan)
        {
            WriteSection("Applying a possible scale up/down fix");
            PricingTier _default = appServicePlan.PricingTier;
            PricingTier _next    = GetNextTier(_default);

            Log("Scaling Up App Service Plan: " + _next.ToString());
            appServicePlan.Update().WithPricingTier(_next).Apply();
            LetsWaitALittle();
            Log("Scaling Down App Service Plan: " + _default.ToString());
            appServicePlan.Update().WithPricingTier(_default).Apply();
            LetsWaitALittle();
        }
示例#2
0
        // Creates a web app under a new app service plan and cleans up those resources when done
        public static void ConfigureAppService(IAzure azure)
        {
            string appName = "MyConfiguredApp";
            string rgName  = "MyConfiguredRG";

            Console.WriteLine("Creating resource group, app service plan and web app.");

            // Create Web app in a new resource group with a new app service plan
            var webApp = azure.WebApps.Define(appName).WithRegion(Region.USWest).WithNewResourceGroup(rgName).WithNewWindowsPlan(PricingTier.StandardS1).Create();
            var plan   = webApp.AppServicePlanId;

            Console.WriteLine("Resources created. Check portal.azure.com");
            Console.WriteLine("Press any key to scale up app service.");
            Console.ReadLine();
            Console.WriteLine("Scaling up the app service.");

            // Scale out the app service
            IAppServicePlan appPlan = azure.AppServices.AppServicePlans.GetById(plan);

            appPlan.Update().WithCapacity(appPlan.Capacity * 2).Apply();


            Console.WriteLine("App service scaled up.");
            Console.WriteLine("Press any key to clean up resources.");
            Console.ReadLine();
            Console.WriteLine("Cleaning up resources.");

            // Delete resources one-by-one
            // Note: might be most efficient to delete by resource group, but wanted to learn code for each piece. (This is a learning exercise afterall!)
            azure.WebApps.DeleteById(webApp.Id);

            azure.AppServices.AppServicePlans.DeleteById(plan);

            azure.ResourceGroups.DeleteByName(rgName);

            Console.WriteLine("Resources cleaned.");
        }