From f776447d69b92e8053a8def75b83038fdfd755a7 Mon Sep 17 00:00:00 2001 From: Michiel van Oudheusden Date: Wed, 1 Jan 2025 23:42:39 +0100 Subject: [PATCH] Price url was not set, causing a null reference exception --- src/Commands/WhatIf/DevTestWhatIfCommand.cs | 2 ++ src/Commands/WhatIf/RegionWhatIfCommand.cs | 1 + src/Commands/WhatIf/WhatIfSettings.cs | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/src/Commands/WhatIf/DevTestWhatIfCommand.cs b/src/Commands/WhatIf/DevTestWhatIfCommand.cs index 9121e60..6244500 100644 --- a/src/Commands/WhatIf/DevTestWhatIfCommand.cs +++ b/src/Commands/WhatIf/DevTestWhatIfCommand.cs @@ -37,6 +37,8 @@ public override async Task ExecuteAsync(CommandContext context, WhatIfSetti { // Get the subscription ID from the settings var subscriptionId = settings.Subscription; + _costRetriever.CostApiAddress = settings.CostApiAddress; + _priceRetriever.PriceApiAddress = settings.PriceApiAddress; if (subscriptionId.HasValue == false && (settings.GetScope.IsSubscriptionBased)) { diff --git a/src/Commands/WhatIf/RegionWhatIfCommand.cs b/src/Commands/WhatIf/RegionWhatIfCommand.cs index 1d3ffe9..282b2a6 100644 --- a/src/Commands/WhatIf/RegionWhatIfCommand.cs +++ b/src/Commands/WhatIf/RegionWhatIfCommand.cs @@ -33,6 +33,7 @@ public RegionWhatIfCommand(IPriceRetriever priceRetriever, ICostRetriever costRe public override async Task ExecuteAsync(CommandContext context, WhatIfSettings settings) { _costRetriever.CostApiAddress = settings.CostApiAddress; + _priceRetriever.PriceApiAddress = settings.PriceApiAddress; // Get the subscription ID from the settings var subscriptionId = settings.Subscription; diff --git a/src/Commands/WhatIf/WhatIfSettings.cs b/src/Commands/WhatIf/WhatIfSettings.cs index 595c221..1390721 100644 --- a/src/Commands/WhatIf/WhatIfSettings.cs +++ b/src/Commands/WhatIf/WhatIfSettings.cs @@ -74,6 +74,10 @@ public class WhatIfSettings : CommandSettings, ICostSettings //:CostSettings [Description("The base address for the Cost API. Defaults to https://management.azure.com/")] public string CostApiAddress { get; set; } = "https://management.azure.com/"; + [CommandOption("--priceApiBaseAddress ")] + [Description("The base address for the Price API. Defaults to https://prices.azure.com/")] + public string PriceApiAddress { get; set; } = "https://prices.azure.com/"; + public Scope GetScope { get {