protected override void ProcessRecordInternal()
        {
            var putParameters = new LogProfileCreatOrUpdateParameters();

            if (this.Categories == null)
            {
                this.Categories = new List<string>(ValidCategories);
            }

            putParameters.Properties = new LogProfile
            {
                Categories = this.Categories,
                Locations = this.Locations,
                RetentionPolicy = new RetentionPolicy
                {
                    Days = this.RetentionInDays.HasValue ? this.RetentionInDays.Value : 0,
                    Enabled = this.RetentionInDays.HasValue
                },
                ServiceBusRuleId = this.ServiceBusRuleId,
                StorageAccountId = this.StorageAccountId
            };

            this.InsightsManagementClient.LogProfilesOperations.CreateOrUpdateAsync(
                this.Name,
                putParameters,
                CancellationToken.None).Wait();

            PSLogProfile psResult = new PSLogProfile(
                "/subscriptions/{0}/providers/microsoft.insights/logprofiles/{1}"
                    .FormatInvariant(DefaultContext.Subscription.Id.ToString(), this.Name), 
                this.Name,
                putParameters.Properties);
            WriteObject(psResult);
        }
 /// <summary>
 /// Create or update the log profile.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.Insights.ILogProfilesOperations.
 /// </param>
 /// <param name='name'>
 /// Required. The name of the log profile.
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the operation.
 /// </param>
 /// <returns>
 /// Generic empty response. We only pass it to ensure json error
 /// handling
 /// </returns>
 public static EmptyResponse CreateOrUpdate(this ILogProfilesOperations operations, string name, LogProfileCreatOrUpdateParameters parameters)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((ILogProfilesOperations)s).CreateOrUpdateAsync(name, parameters);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
        public void LogProfiles_CreateOrUpdateTest()
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(string.Empty)
            };

            var handler = new RecordedDelegatingHandler(response);
            InsightsManagementClient customClient = this.GetInsightsManagementClient(handler);

            var parameters = new LogProfileCreatOrUpdateParameters
            {
                Properties = CreateLogProfile()
            };

            customClient.LogProfilesOperations.CreateOrUpdate(DefaultName, parameters);

            var actualRequest = JsonExtensions.FromJson<LogProfileCreatOrUpdateParameters>(handler.Request);
            AreEqual(parameters.Properties, actualRequest.Properties);
        }
 /// <summary>
 /// Create or update the log profile.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.Insights.ILogProfilesOperations.
 /// </param>
 /// <param name='name'>
 /// Required. The name of the log profile.
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the operation.
 /// </param>
 /// <returns>
 /// Generic empty response. We only pass it to ensure json error
 /// handling
 /// </returns>
 public static Task<EmptyResponse> CreateOrUpdateAsync(this ILogProfilesOperations operations, string name, LogProfileCreatOrUpdateParameters parameters)
 {
     return operations.CreateOrUpdateAsync(name, parameters, CancellationToken.None);
 }