Example #1
0
        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, this.Name),
                this.Name,
                putParameters.Properties);

            WriteObject(psResult);
        }
Example #2
0
        protected override void ProcessRecordInternal()
        {
            var result = new PSLogProfileCollection();

            if (string.IsNullOrWhiteSpace(this.Name))
            {
                LogProfileListResponse resultList = this.InsightsManagementClient.LogProfilesOperations.ListAsync(CancellationToken.None).Result;

                result.AddRange(resultList.LogProfileCollection.Value.Select(x => new PSLogProfile(x.Id, x.Name, x.Properties)));
            }
            else
            {
                LogProfileGetResponse logProfiles = this.InsightsManagementClient.LogProfilesOperations.GetAsync(this.Name, CancellationToken.None).Result;
                var psResult = new PSLogProfile(logProfiles.Id, this.Name, logProfiles.Properties);
                result.Add(psResult);
            }

            WriteObject(result);
        }