public SoftwareUpdateConfiguration CreateSoftwareUpdateConfiguration(string resourceGroupName, string automationAccountName, SoftwareUpdateConfiguration configuration) { using (var request = new RequestSettings(this.automationManagementClient)) { var updateConfig = configuration.UpdateConfiguration; var sucParameters = new Sdk.SoftwareUpdateConfiguration() { ScheduleInfo = new Sdk.ScheduleProperties() { StartTime = configuration.ScheduleConfiguration.StartTime.ToUniversalTime(), ExpiryTime = configuration.ScheduleConfiguration.ExpiryTime.ToUniversalTime(), Frequency = configuration.ScheduleConfiguration.Frequency.ToString(), Interval = configuration.ScheduleConfiguration.Interval, IsEnabled = configuration.ScheduleConfiguration.IsEnabled, TimeZone = configuration.ScheduleConfiguration.TimeZone, AdvancedSchedule = configuration.ScheduleConfiguration.GetAdvancedSchedule() }, UpdateConfiguration = new Sdk.UpdateConfiguration() { OperatingSystem = updateConfig.OperatingSystem == OperatingSystemType.Windows ? Sdk.OperatingSystemType.Windows : Sdk.OperatingSystemType.Linux, Windows = updateConfig.OperatingSystem == OperatingSystemType.Linux ? null : new Sdk.WindowsProperties() { IncludedUpdateClassifications = updateConfig.Windows != null && updateConfig.Windows.IncludedUpdateClassifications != null ? string.Join(",", updateConfig.Windows.IncludedUpdateClassifications.Select(c => c.ToString())) : null, ExcludedKbNumbers = updateConfig.Windows != null ? updateConfig.Windows.ExcludedKbNumbers : null }, Linux = updateConfig.OperatingSystem == OperatingSystemType.Windows ? null : new Sdk.LinuxProperties() { IncludedPackageClassifications = updateConfig.Linux != null && updateConfig.Linux.IncludedPackageClassifications != null ? string.Join(",", updateConfig.Linux.IncludedPackageClassifications.Select(c => c.ToString())) : null, ExcludedPackageNameMasks = updateConfig.Linux != null ? updateConfig.Linux.ExcludedPackageNameMasks : null }, Duration = updateConfig.Duration, AzureVirtualMachines = updateConfig.AzureVirtualMachines, NonAzureComputerNames = updateConfig.NonAzureComputers } }; var suc = this.automationManagementClient.SoftwareUpdateConfigurations.Create(resourceGroupName, automationAccountName, configuration.Name, sucParameters); return(new SoftwareUpdateConfiguration(resourceGroupName, automationAccountName, suc)); } }
public SoftwareUpdateConfiguration CreateSoftwareUpdateConfiguration(string resourceGroupName, string automationAccountName, SoftwareUpdateConfiguration configuration) { using (var request = new RequestSettings(this.automationManagementClient)) { var updateConfig = configuration.UpdateConfiguration; IList <Sdk.AzureQueryProperties> azureQueries = null; if (updateConfig.Targets != null && updateConfig.Targets.AzureQueries != null && updateConfig.Targets.AzureQueries.Count > 0) { azureQueries = new List <Sdk.AzureQueryProperties>(); foreach (var query in updateConfig.Targets.AzureQueries) { var tags = new Dictionary <string, IList <string> >(); foreach (var tag in query.TagSettings.Tags) { tags.Add(tag.Key, tag.Value); } var azureQueryProperty = new Sdk.AzureQueryProperties { Locations = query.Locations, Scope = query.Scope, TagSettings = new Sdk.TagSettingsProperties { Tags = tags, FilterOperator = (Sdk.TagOperators)query.TagSettings.FilterOperator } }; azureQueries.Add(azureQueryProperty); } } IList <Sdk.NonAzureQueryProperties> nonAzureQueries = null; if (updateConfig.Targets != null && updateConfig.Targets.NonAzureQueries != null && updateConfig.Targets.NonAzureQueries.Count > 0) { nonAzureQueries = new List <Sdk.NonAzureQueryProperties>(); foreach (var query in updateConfig.Targets.NonAzureQueries) { var nonAzureQueryProperty = new Sdk.NonAzureQueryProperties { FunctionAlias = query.FunctionAlias, WorkspaceId = query.WorkspaceResourceId }; nonAzureQueries.Add(nonAzureQueryProperty); } } var sucParameters = new Sdk.SoftwareUpdateConfiguration() { ScheduleInfo = new Sdk.ScheduleProperties() { StartTime = configuration.ScheduleConfiguration.StartTime.ToUniversalTime(), ExpiryTime = configuration.ScheduleConfiguration.ExpiryTime.ToUniversalTime(), Frequency = configuration.ScheduleConfiguration.Frequency.ToString(), Interval = configuration.ScheduleConfiguration.Interval, IsEnabled = configuration.ScheduleConfiguration.IsEnabled, TimeZone = configuration.ScheduleConfiguration.TimeZone, AdvancedSchedule = configuration.ScheduleConfiguration.GetAdvancedSchedule() }, UpdateConfiguration = new Sdk.UpdateConfiguration() { OperatingSystem = updateConfig.OperatingSystem == OperatingSystemType.Windows ? Sdk.OperatingSystemType.Windows : Sdk.OperatingSystemType.Linux, Windows = updateConfig.OperatingSystem == OperatingSystemType.Linux ? null : new Sdk.WindowsProperties() { IncludedUpdateClassifications = updateConfig.Windows != null && updateConfig.Windows.IncludedUpdateClassifications != null ? string.Join(",", updateConfig.Windows.IncludedUpdateClassifications.Select(c => c.ToString())) : null, ExcludedKbNumbers = updateConfig.Windows != null ? updateConfig.Windows.ExcludedKbNumbers : null, RebootSetting = updateConfig.Windows != null?updateConfig.Windows.rebootSetting.ToString() : RebootSetting.IfRequired.ToString(), }, Linux = updateConfig.OperatingSystem == OperatingSystemType.Windows ? null : new Sdk.LinuxProperties() { IncludedPackageClassifications = updateConfig.Linux != null && updateConfig.Linux.IncludedPackageClassifications != null ? string.Join(",", updateConfig.Linux.IncludedPackageClassifications.Select(c => c.ToString())) : null, ExcludedPackageNameMasks = updateConfig.Linux != null ? updateConfig.Linux.ExcludedPackageNameMasks : null, RebootSetting = updateConfig.Windows != null?updateConfig.Windows.rebootSetting.ToString() : RebootSetting.IfRequired.ToString(), }, Duration = updateConfig.Duration, AzureVirtualMachines = updateConfig.AzureVirtualMachines, NonAzureComputerNames = updateConfig.NonAzureComputers, Targets = updateConfig.Targets == null ? null : new Sdk.TargetProperties { AzureQueries = azureQueries, NonAzureQueries = nonAzureQueries } }, Tasks = configuration.Tasks == null ? null : new Sdk.SoftwareUpdateConfigurationTasks { PreTask = configuration.Tasks.PreTask == null ? null : new Sdk.TaskProperties { Source = configuration.Tasks.PreTask.source, Parameters = configuration.Tasks.PreTask.parameters }, PostTask = configuration.Tasks.PostTask == null ? null : new Sdk.TaskProperties { Source = configuration.Tasks.PostTask.source, Parameters = configuration.Tasks.PostTask.parameters } } }; var suc = this.automationManagementClient.SoftwareUpdateConfigurations.Create(resourceGroupName, automationAccountName, configuration.Name, sucParameters); return(new SoftwareUpdateConfiguration(resourceGroupName, automationAccountName, suc)); } }