protected override void AutomationProcessRecord()
        {
            if ((this.AzureVMResourceId == null || !this.AzureVMResourceId.Any()) && (this.NonAzureComputer == null || !this.NonAzureComputer.Any()))
            {
                throw new PSArgumentException(Resources.SoftwareUpdateConfigurationHasNoTargetComputers);
            }

            var resource = string.Format(CultureInfo.CurrentCulture, Resources.SoftwareUpdateConfigurationCreateOperation);

            if (ShouldProcess(this.Schedule.Name, resource))
            {
                var suc = new SoftwareUpdateConfiguration()
                {
                    Name                  = this.Schedule.Name,
                    Description           = this.Schedule.Description,
                    ScheduleConfiguration = this.Schedule,
                    UpdateConfiguration   = new UpdateConfiguration
                    {
                        OperatingSystem = this.IsWindows ? OperatingSystemType.Windows : OperatingSystemType.Linux,
                        Windows         = !this.IsWindows
                            ? null
                            : new WindowsConfiguration
                        {
                            ExcludedKbNumbers             = this.ExcludedKbNumber,
                            IncludedKbNumbers             = this.IncludedKbNumber,
                            IncludedUpdateClassifications = this.IncludedUpdateClassification
                        },
                        Linux = this.IsWindows
                            ? null
                            : new LinuxConfiguration
                        {
                            ExcludedPackageNameMasks       = this.ExcludedPackageNameMask,
                            IncludedPackageClassifications = this.IncludedPackageClassification,
                            IncludedPackageNameMasks       = this.IncludedPackageNameMask
                        },
                        Duration             = this.Duration,
                        AzureVirtualMachines = this.AzureVMResourceId,
                        NonAzureComputers    = this.NonAzureComputer
                    }
                };
                suc = this.AutomationClient.CreateSoftwareUpdateConfiguration(this.ResourceGroupName,
                                                                              this.AutomationAccountName, suc);
                this.WriteObject(suc);
            }
        }
Exemplo n.º 2
0
        protected override void AutomationProcessRecord()
        {
            IEnumerable <SoftwareUpdateConfiguration> result = null;

            switch (this.ParameterSetName)
            {
            case AutomationCmdletParameterSets.ByName:
                result = new SoftwareUpdateConfiguration[] {
                    this.AutomationClient.GetSoftwareUpdateConfigurationByName(this.ResourceGroupName, this.AutomationAccountName, this.Name)
                };
                break;

            case AutomationCmdletParameterSets.ByVMId:
                result = this.AutomationClient.ListSoftwareUpdateConfigurations(this.ResourceGroupName, this.AutomationAccountName, this.AzureVMResourceId);
                break;

            default:
                result = this.AutomationClient.ListSoftwareUpdateConfigurations(this.ResourceGroupName, this.AutomationAccountName);
                break;
            }
            this.GenerateCmdletOutput(result);
        }
Exemplo n.º 3
0
        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));
            }
        }
Exemplo n.º 5
0
        protected override void AutomationProcessRecord()
        {
            if ((this.AzureVMResourceId == null || !this.AzureVMResourceId.Any()) &&
                (this.NonAzureComputer == null || !this.NonAzureComputer.Any()) &&
                (this.AzureQuery == null || !this.AzureQuery.Any()) &&
                (this.NonAzureQuery == null || !this.NonAzureQuery.Any()))
            {
                throw new PSArgumentException(Resources.SoftwareUpdateConfigurationHasNoTargetComputers);
            }
            var target = (this.AzureQuery == null && this.NonAzureQuery == null) ? null : new UpdateTargets
            {
                AzureQueries    = this.AzureQuery == null ? null : this.AzureQuery.ToList(),
                NonAzureQueries = this.NonAzureQuery == null ? null : this.NonAzureQuery.ToList()
            };

            var resource = string.Format(CultureInfo.CurrentCulture, Resources.SoftwareUpdateConfigurationCreateOperation);

            if (ShouldProcess(this.Schedule.Name, resource))
            {
                var suc = new SoftwareUpdateConfiguration()
                {
                    Name                  = this.Schedule.Name,
                    Description           = this.Schedule.Description,
                    ScheduleConfiguration = this.Schedule,
                    UpdateConfiguration   = new UpdateConfiguration
                    {
                        OperatingSystem = this.IsWindows ? OperatingSystemType.Windows : OperatingSystemType.Linux,
                        Windows         = !this.IsWindows
                            ? null
                            : new WindowsConfiguration
                        {
                            ExcludedKbNumbers             = this.ExcludedKbNumber,
                            IncludedKbNumbers             = this.IncludedKbNumber,
                            IncludedUpdateClassifications = this.IncludedUpdateClassification,
                            rebootSetting = this.RebootOnly.IsPresent ? RebootSetting.RebootOnly : this.RebootSetting
                        },
                        Linux = this.IsWindows
                            ? null
                            : new LinuxConfiguration
                        {
                            ExcludedPackageNameMasks       = this.ExcludedPackageNameMask,
                            IncludedPackageClassifications = this.IncludedPackageClassification,
                            IncludedPackageNameMasks       = this.IncludedPackageNameMask,
                            rebootSetting = this.RebootOnly.IsPresent ? RebootSetting.RebootOnly : this.RebootSetting
                        },
                        Duration             = this.Duration,
                        AzureVirtualMachines = this.AzureVMResourceId,
                        NonAzureComputers    = this.NonAzureComputer,
                        Targets = target
                    },
                    Tasks = new Tasks
                    {
                        PreTask = this.PreTaskRunbookName == null ? null : new Task
                        {
                            source     = this.PreTaskRunbookName,
                            parameters = TagsConversionHelper.CreateTagDictionary(this.PreTaskRunbookParameter, true)
                        },
                        PostTask = this.PostTaskRunbookName == null ? null : new Task
                        {
                            source     = this.PostTaskRunbookName,
                            parameters = TagsConversionHelper.CreateTagDictionary(this.PostTaskRunbookParameter, true)
                        },
                    }
                };
                suc = this.AutomationClient.CreateSoftwareUpdateConfiguration(this.ResourceGroupName,
                                                                              this.AutomationAccountName, suc);
                this.WriteObject(suc);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Create a new software update configuration with the name given in the URI.
        /// <see href="http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations" />
        /// </summary>
        /// <param name='resourceGroupName'>
        /// Name of an Azure Resource group.
        /// </param>
        /// <param name='automationAccountName'>
        /// The name of the automation account.
        /// </param>
        /// <param name='softwareUpdateConfigurationName'>
        /// The name of the software update configuration to be created.
        /// </param>
        /// <param name='parameters'>
        /// Request body.
        /// </param>
        /// <param name='clientRequestId'>
        /// Identifies this specific client request.
        /// </param>
        /// <param name='customHeaders'>
        /// Headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="ErrorResponseException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="SerializationException">
        /// Thrown when unable to deserialize the response
        /// </exception>
        /// <exception cref="ValidationException">
        /// Thrown when a required parameter is null
        /// </exception>
        /// <exception cref="System.ArgumentNullException">
        /// Thrown when a required parameter is null
        /// </exception>
        /// <return>
        /// A response object containing the response body and response headers.
        /// </return>
        public async Task <AzureOperationResponse <SoftwareUpdateConfiguration> > CreateWithHttpMessagesAsync(string resourceGroupName, string automationAccountName, string softwareUpdateConfigurationName, SoftwareUpdateConfiguration parameters, string clientRequestId = default(string), Dictionary <string, List <string> > customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (Client.SubscriptionId == null)
            {
                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
            }
            if (resourceGroupName == null)
            {
                throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName");
            }
            if (resourceGroupName != null)
            {
                if (resourceGroupName.Length > 90)
                {
                    throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90);
                }
                if (resourceGroupName.Length < 1)
                {
                    throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1);
                }
                if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$"))
                {
                    throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._]+$");
                }
            }
            if (automationAccountName == null)
            {
                throw new ValidationException(ValidationRules.CannotBeNull, "automationAccountName");
            }
            if (softwareUpdateConfigurationName == null)
            {
                throw new ValidationException(ValidationRules.CannotBeNull, "softwareUpdateConfigurationName");
            }
            if (parameters == null)
            {
                throw new ValidationException(ValidationRules.CannotBeNull, "parameters");
            }
            if (parameters != null)
            {
                parameters.Validate();
            }
            string apiVersion = "2017-05-15-preview";
            // Tracing
            bool   _shouldTrace  = ServiceClientTracing.IsEnabled;
            string _invocationId = null;

            if (_shouldTrace)
            {
                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
                Dictionary <string, object> tracingParameters = new Dictionary <string, object>();
                tracingParameters.Add("resourceGroupName", resourceGroupName);
                tracingParameters.Add("automationAccountName", automationAccountName);
                tracingParameters.Add("softwareUpdateConfigurationName", softwareUpdateConfigurationName);
                tracingParameters.Add("apiVersion", apiVersion);
                tracingParameters.Add("clientRequestId", clientRequestId);
                tracingParameters.Add("parameters", parameters);
                tracingParameters.Add("cancellationToken", cancellationToken);
                ServiceClientTracing.Enter(_invocationId, this, "Create", tracingParameters);
            }
            // Construct URL
            var _baseUrl = Client.BaseUri.AbsoluteUri;
            var _url     = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}").ToString();

            _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
            _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName));
            _url = _url.Replace("{automationAccountName}", System.Uri.EscapeDataString(automationAccountName));
            _url = _url.Replace("{softwareUpdateConfigurationName}", System.Uri.EscapeDataString(softwareUpdateConfigurationName));
            List <string> _queryParameters = new List <string>();

            if (apiVersion != null)
            {
                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion)));
            }
            if (_queryParameters.Count > 0)
            {
                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
            }
            // Create HTTP transport objects
            var _httpRequest = new HttpRequestMessage();
            HttpResponseMessage _httpResponse = null;

            _httpRequest.Method     = new HttpMethod("PUT");
            _httpRequest.RequestUri = new System.Uri(_url);
            // Set Headers
            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
            {
                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
            }
            if (clientRequestId != null)
            {
                if (_httpRequest.Headers.Contains("clientRequestId"))
                {
                    _httpRequest.Headers.Remove("clientRequestId");
                }
                _httpRequest.Headers.TryAddWithoutValidation("clientRequestId", clientRequestId);
            }
            if (Client.AcceptLanguage != null)
            {
                if (_httpRequest.Headers.Contains("accept-language"))
                {
                    _httpRequest.Headers.Remove("accept-language");
                }
                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
            }


            if (customHeaders != null)
            {
                foreach (var _header in customHeaders)
                {
                    if (_httpRequest.Headers.Contains(_header.Key))
                    {
                        _httpRequest.Headers.Remove(_header.Key);
                    }
                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
                }
            }

            // Serialize Request
            string _requestContent = null;

            if (parameters != null)
            {
                _requestContent      = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings);
                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
                _httpRequest.Content.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
            }
            // Set Credentials
            if (Client.Credentials != null)
            {
                cancellationToken.ThrowIfCancellationRequested();
                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
            }
            // Send Request
            if (_shouldTrace)
            {
                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
            }
            cancellationToken.ThrowIfCancellationRequested();
            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);

            if (_shouldTrace)
            {
                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
            }
            System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode;
            cancellationToken.ThrowIfCancellationRequested();
            string _responseContent = null;

            if ((int)_statusCode != 200 && (int)_statusCode != 201)
            {
                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
                try
                {
                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

                    ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject <ErrorResponse>(_responseContent, Client.DeserializationSettings);
                    if (_errorBody != null)
                    {
                        ex.Body = _errorBody;
                    }
                }
                catch (JsonException)
                {
                    // Ignore the exception
                }
                ex.Request  = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
                if (_shouldTrace)
                {
                    ServiceClientTracing.Error(_invocationId, ex);
                }
                _httpRequest.Dispose();
                if (_httpResponse != null)
                {
                    _httpResponse.Dispose();
                }
                throw ex;
            }
            // Create Result
            var _result = new AzureOperationResponse <SoftwareUpdateConfiguration>();

            _result.Request  = _httpRequest;
            _result.Response = _httpResponse;
            if (_httpResponse.Headers.Contains("x-ms-request-id"))
            {
                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
            }
            // Deserialize Response
            if ((int)_statusCode == 200)
            {
                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

                try
                {
                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject <SoftwareUpdateConfiguration>(_responseContent, Client.DeserializationSettings);
                }
                catch (JsonException ex)
                {
                    _httpRequest.Dispose();
                    if (_httpResponse != null)
                    {
                        _httpResponse.Dispose();
                    }
                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
                }
            }
            // Deserialize Response
            if ((int)_statusCode == 201)
            {
                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

                try
                {
                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject <SoftwareUpdateConfiguration>(_responseContent, Client.DeserializationSettings);
                }
                catch (JsonException ex)
                {
                    _httpRequest.Dispose();
                    if (_httpResponse != null)
                    {
                        _httpResponse.Dispose();
                    }
                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
                }
            }
            if (_shouldTrace)
            {
                ServiceClientTracing.Exit(_invocationId, _result);
            }
            return(_result);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Create a new software update configuration with the name given in the URI.
 /// <see href="http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations" />
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Name of an Azure Resource group.
 /// </param>
 /// <param name='automationAccountName'>
 /// The name of the automation account.
 /// </param>
 /// <param name='softwareUpdateConfigurationName'>
 /// The name of the software update configuration to be created.
 /// </param>
 /// <param name='parameters'>
 /// Request body.
 /// </param>
 /// <param name='clientRequestId'>
 /// Identifies this specific client request.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <SoftwareUpdateConfiguration> CreateAsync(this ISoftwareUpdateConfigurationsOperations operations, string resourceGroupName, string automationAccountName, string softwareUpdateConfigurationName, SoftwareUpdateConfiguration parameters, string clientRequestId = default(string), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, automationAccountName, softwareUpdateConfigurationName, parameters, clientRequestId, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// Create a new software update configuration with the name given in the URI.
 /// <see href="http://aka.ms/azureautomationsdk/softwareupdateconfigurationoperations" />
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Name of an Azure Resource group.
 /// </param>
 /// <param name='automationAccountName'>
 /// The name of the automation account.
 /// </param>
 /// <param name='softwareUpdateConfigurationName'>
 /// The name of the software update configuration to be created.
 /// </param>
 /// <param name='parameters'>
 /// Request body.
 /// </param>
 /// <param name='clientRequestId'>
 /// Identifies this specific client request.
 /// </param>
 public static SoftwareUpdateConfiguration Create(this ISoftwareUpdateConfigurationsOperations operations, string resourceGroupName, string automationAccountName, string softwareUpdateConfigurationName, SoftwareUpdateConfiguration parameters, string clientRequestId = default(string))
 {
     return(operations.CreateAsync(resourceGroupName, automationAccountName, softwareUpdateConfigurationName, parameters, clientRequestId).GetAwaiter().GetResult());
 }