Skip to content

[ApplicationInsights] fix null reference in PSApplicationInsightsComponent #20709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,30 @@ public class PSApplicationInsightsComponent
{
public PSApplicationInsightsComponent(ApplicationInsightsComponent component)
{
this.ResourceGroupName = ParseResourceGroupFromId(component.Id);
this.Name = component.Name;
this.Id = component.Id;
this.Location = component.Location;
this.Tags = component.Tag.Keys.ToDictionary(x => x, x => component.Tag[x]);
this.Kind = component.Kind;
this.Type = component.Type;
this.AppId = component.AppId;
this.ApplicationId = component.ApplicationId;
this.ApplicationType = component.ApplicationType;
this.CreationDate = component.CreationDate;
this.FlowType = component.FlowType;
this.HockeyAppId = component.HockeyAppId;
this.HockeyAppToken = component.HockeyAppToken;
this.InstrumentationKey = component.InstrumentationKey;
this.ProvisioningState = component.ProvisioningState;
this.RequestSource = component.RequestSource;
this.SamplingPercentage = component.SamplingPercentage;
this.TenantId = component.TenantId;
this.PublicNetworkAccessForIngestion = component.PublicNetworkAccessForIngestion;
this.PublicNetworkAccessForQuery = component.PublicNetworkAccessForQuery;
this.PrivateLinkScopedResources = component.PrivateLinkScopedResource.ToList();
this.RetentionInDays = component.RetentionInDay;
this.ConnectionString = component.ConnectionString;
this.ResourceGroupName = ParseResourceGroupFromId(component?.Id);
this.Name = component?.Name;
this.Id = component?.Id;
this.Location = component?.Location;
this.Tags = component?.Tag?.Keys?.ToDictionary(x => x, x => component.Tag[x]);
this.Kind = component?.Kind;
this.Type = component?.Type;
this.AppId = component?.AppId;
this.ApplicationId = component?.ApplicationId;
this.ApplicationType = component?.ApplicationType;
this.CreationDate = component?.CreationDate;
this.FlowType = component?.FlowType;
this.HockeyAppId = component?.HockeyAppId;
this.HockeyAppToken = component?.HockeyAppToken;
this.InstrumentationKey = component?.InstrumentationKey;
this.ProvisioningState = component?.ProvisioningState;
this.RequestSource = component?.RequestSource;
this.SamplingPercentage = component?.SamplingPercentage;
this.TenantId = component?.TenantId;
this.PublicNetworkAccessForIngestion = component?.PublicNetworkAccessForIngestion;
this.PublicNetworkAccessForQuery = component?.PublicNetworkAccessForQuery;
this.PrivateLinkScopedResources = component?.PrivateLinkScopedResource?.ToList();
this.RetentionInDays = component?.RetentionInDay;
this.ConnectionString = component?.ConnectionString;
}

public string Id { get; set; }
Expand Down Expand Up @@ -145,7 +145,7 @@ public PSApplicationInsightsComponentWithPricingPlan(ApplicationInsightsComponen
ApplicationInsightsComponentQuotaStatus status)
: base(component)
{
if (billing.CurrentBillingFeature.Any(f => f.Contains("Enterprise")))
if (billing != null && billing.CurrentBillingFeature != null && billing.CurrentBillingFeature.Any(f => f.Contains("Enterprise")))
{
this.PricingPlan = "Application Insights Enterprise";
}
Expand All @@ -154,11 +154,13 @@ public PSApplicationInsightsComponentWithPricingPlan(ApplicationInsightsComponen
this.PricingPlan = billing.CurrentBillingFeature.FirstOrDefault();
}

this.Cap = billing.DataVolumeCap.Cap;
this.ResetTime = billing.DataVolumeCap.ResetTime;
this.StopSendNotificationWhenHitCap = billing.DataVolumeCap.StopSendNotificationWhenHitCap.Value;
this.CapExpirationTime = status.ExpirationTime;
this.IsCapped = status.ShouldBeThrottled != null ? status.ShouldBeThrottled.Value : false;
this.Cap = billing?.DataVolumeCap?.Cap;
this.ResetTime = billing?.DataVolumeCap?.ResetTime;
if (billing != null && billing.DataVolumeCap != null && billing.DataVolumeCap.StopSendNotificationWhenHitCap != null) {
this.StopSendNotificationWhenHitCap = billing.DataVolumeCap.StopSendNotificationWhenHitCap.Value;
}
this.CapExpirationTime = status?.ExpirationTime;
this.IsCapped = status?.ShouldBeThrottled != null ? status.ShouldBeThrottled.Value : false;
}
}
}