diff --git a/src/SelfServe/SqlX/SqlX.rp.ts b/src/SelfServe/SqlX/SqlX.rp.ts index 5d1b830d0..d224990bb 100644 --- a/src/SelfServe/SqlX/SqlX.rp.ts +++ b/src/SelfServe/SqlX/SqlX.rp.ts @@ -6,6 +6,7 @@ import { RefreshResult } from "../SelfServeTypes"; import SqlX from "./SqlX"; import { FetchPricesResponse, + PriceMapAndCurrencyCode, RegionsResponse, SqlxServiceResource, UpdateDedicatedGatewayRequestParameters, @@ -178,18 +179,18 @@ const getFetchPricesPathForRegion = (subscriptionId: string): string => { return `/subscriptions/${subscriptionId}/providers/Microsoft.CostManagement/fetchPrices`; }; -export const getPriceMap = async (regions: Array): Promise>> => { +export const getPriceMapAndCurrencyCode = async (regions: Array): Promise => { const telemetryData = { feature: "Calculate approximate cost", - function: "getPriceMap", + function: "getPriceMapAndCurrencyCode", description: "fetch prices API call", selfServeClassName: SqlX.name, }; - const getPriceMapTimestamp = selfServeTraceStart(telemetryData); + const getPriceMapAndCurrencyCodeTimestamp = selfServeTraceStart(telemetryData); try { const priceMap = new Map>(); - + let currencyCode; for (const region of regions) { const regionPriceMap = new Map(); @@ -207,17 +208,21 @@ export const getPriceMap = async (regions: Array): Promise>; +let currencyCode: string; let regions: Array; const calculateCost = (skuName: string, instanceCount: number): Description => { @@ -237,7 +238,7 @@ const calculateCost = (skuName: string, instanceCount: number): Description => { selfServeTraceSuccess(telemetryData, calculateCostTimestamp); return { - textTKey: `${costPerHour} USD`, + textTKey: `${costPerHour} ${currencyCode}`, type: DescriptionType.Text, }; } catch (err) { @@ -346,7 +347,9 @@ export default class SqlX extends SelfServeBaseClass { }); regions = await getRegions(); - priceMap = await getPriceMap(regions); + const priceMapAndCurrencyCode = await getPriceMapAndCurrencyCode(regions); + priceMap = priceMapAndCurrencyCode.priceMap; + currencyCode = priceMapAndCurrencyCode.currencyCode; const response = await getCurrentProvisioningState(); if (response.status && response.status !== "Deleting") { diff --git a/src/SelfServe/SqlX/SqlxTypes.ts b/src/SelfServe/SqlX/SqlxTypes.ts index a150ccbb1..7ca2fe264 100644 --- a/src/SelfServe/SqlX/SqlxTypes.ts +++ b/src/SelfServe/SqlX/SqlxTypes.ts @@ -36,9 +36,15 @@ export type FetchPricesResponse = { Count: number; }; +export type PriceMapAndCurrencyCode = { + priceMap: Map>; + currencyCode: string; +}; + export type PriceItem = { retailPrice: number; skuName: string; + currencyCode: string; }; export type RegionsResponse = {