public void CreateAutoscalePolicies(ICloudAppConfig appConfig, string resourceUrl, string appName, string resGroupName) { Logger.Info("CreateAutoscalePolicies - Creating"); var autoscaleconfig = (ICloudAppConfigAutoScaling)appConfig; var emailForScaling = autoscaleconfig.AutoScaleNotificationMailAddress; var capacity = CreateScaleCapacity(); var rules = CreateRulesForAutoScaling(resourceUrl); var profiles = CreateAutoScaleProfile(capacity, rules); var notifications = CreateAutoscaleNotifications(emailForScaling); var autoscalesettingName = autoscaleconfig.AutoScaleSettingName; var asr = new AutoscaleSettingResource { Name = autoscalesettingName, AutoscaleSettingResourceName = autoscalesettingName, TargetResourceUri = resourceUrl, Enabled = true, Profiles = profiles, Notifications = notifications, Location = autoscaleconfig.AutoScaleResourceLocation }; using (var imc = new InsightsManagementClient(appConfig.Creds) { SubscriptionId = appConfig.SubscriptionId }) { imc.AutoscaleSettings.CreateOrUpdate(resGroupName, autoscalesettingName, asr); } Logger.Info("CreateAutoscalePolicies - Created"); }
public string CreateApplicationInsights(ICloudAppConfig appConfig) { using (var rmc = new ResourceManagementClient(appConfig.Creds)) { rmc.SubscriptionId = appConfig.SubscriptionId; var myparams = new GenericResourceInner(appConfig.AppInsightsLocation, name: appConfig.AppInsightsName, properties: new { ApplicationId = appConfig.AppInsightsName }); var appinsights = rmc.Resources.CreateOrUpdate(appConfig.ResGrpName, resourceProviderNamespace: "microsoft.insights", resourceType: "components", resourceName: appConfig.AppInsightsName, parentResourcePath: "", apiVersion: "2015-05-01", parameters: myparams); var key = JObject.Parse(appinsights.Properties.ToString())["InstrumentationKey"]; Logger.Info($"AppInsightKey={key}"); return(key.ToString()); } }
public IAppServicePlan CreateAppServicePlan(ICloudAppConfig appconfig, IResourceGroup resgrp) { Logger.Info("App Plan - Creating"); var appPlan = Program.Cloud.AppServices.AppServicePlans.Define(appconfig.AppServicePlanName) .WithRegion(resgrp.Region) .WithExistingResourceGroup(resgrp) .WithPricingTier(appconfig.DefaultPricingTier) .WithOperatingSystem(appconfig.DefaultOperatingSystem) .WithCapacity(1) .Create(); Logger.Info("App Plan - Created"); return(appPlan); }
public IWebApp CreateWebAppProcess(ICloudAppConfig appconfig, IResourceGroup resgrp, IAppServicePlan plan) { Logger.Info("WebApp Creating"); var webapp = Program.Cloud.WebApps.Define(appconfig.FullName) .WithExistingWindowsPlan(plan) .WithExistingResourceGroup(resgrp.Name.ToLower()) .WithClientAffinityEnabled(false) .WithoutPhp() .WithPhpVersion(PhpVersion.Off) .WithPythonVersion(PythonVersion.Off) .WithPlatformArchitecture(PlatformArchitecture.X64) .WithWebSocketsEnabled(false) .WithWebAppAlwaysOn(false) .Create(); Logger.Info("WebApp Created"); CreateDeploymentSlot(webapp, appconfig.DeploymentSlotName); Logger.Info($"OutBound IP Range: {string.Join(",", webapp.OutboundIPAddresses)}"); return(webapp); }
//public AlertRules(ILogger logger, ICloudAppConfig appconfig, IAlertRuleConfiguration alertRuleConfig) //{ // Logger = logger; // _appconfig = appconfig; // AzureManagementClientConfiguration = (IAzureManagementClientConfiguration)appconfig; // AlertRuleConfig = alertRuleConfig; //} public AlertRules(ILogger logger, ICloudAppConfig appconfig) { _logger = logger; _appconfig = appconfig; }