Compare commits

...

6 Commits

Author SHA1 Message Date
Tara Zou
feec5fb3e2 Merge branch 'master' into users/tarazou/DedicatedGatewayType 2024-04-26 15:17:32 -04:00
Tara Zou
09b2862d40 update control plane api version 2024-04-22 16:13:01 -04:00
Tara Zou
bce026036b add tooltip 2024-04-09 11:10:13 -04:00
Tara Zou
5e83b81540 get dedicated gateway value from API response 2024-03-26 10:38:59 -04:00
Tara Zou
b26dd70bbd fix format 2024-03-21 15:15:33 -04:00
Tara Zou
4158ea9a5a Add Dedicated Gateway Type 2024-03-21 14:51:16 -04:00
4 changed files with 72 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
{
"DedicatedGatewayDescription": "Provision a dedicated gateway cluster for your Azure Cosmos DB account. A dedicated gateway is compute that is a front-end to data in your Azure Cosmos DB account. Your dedicated gateway automatically includes the integrated cache, which can improve read performance.",
"DedicatedGatewayDescription": "Provision a dedicated gateway cluster for your Azure Cosmos DB account. A dedicated gateway is compute that is a front-end to data in your Azure Cosmos DB account. You can configure your dedicated gateway cluster and choose which feature to deploy.",
"DedicatedGateway": "Dedicated Gateway",
"Provisioned": "Provisioned",
"Deprovisioned": "Deprovisioned",
@@ -8,6 +8,7 @@
"DedicatedGatewayPricing": "Learn more about dedicated gateway pricing.",
"SKUs": "SKUs",
"SKUsPlaceHolder": "Select SKUs",
"DedicatedGatewayTypePlaceHolder": "Select Dedicated Gateway Type",
"NumberOfInstances": "Number of instances",
"CosmosD4s": "Cosmos.D4s (General Purpose Cosmos Compute with 4 vCPUs, 16 GB Memory)",
"CosmosD8s": "Cosmos.D8s (General Purpose Cosmos Compute with 8 vCPUs, 32 GB Memory)",
@@ -49,6 +50,8 @@
"MetricsText": "Monitor the CPU and memory usage for the dedicated gateway instances in ",
"MetricsBlade": "the metrics blade.",
"MonitorUsage": "Monitor Usage",
"DedicatedGatewayTypeText": "Each dedicated gateway feature comes with different benefits. ",
"DedicatedGatewayTypeLink": "Learn more about the dedicated gateway features.",
"ResizingDecisionText": "To understand if the dedicated gateway is the right size, ",
"ResizingDecisionLink": "learn more about dedicated gateway sizing.",
"WarningBannerOnUpdate": "Adding or modifying dedicated gateway instances may affect your bill.",

View File

@@ -13,7 +13,7 @@ import {
UpdateDedicatedGatewayRequestParameters,
} from "./SqlxTypes";
const apiVersion = "2021-04-01-preview";
const apiVersion = "2024-02-15-preview";
export enum ResourceStatus {
Running = "Running",
@@ -24,6 +24,7 @@ export enum ResourceStatus {
export interface DedicatedGatewayResponse {
sku: string;
dedicatedGatewayType: string;
instances: number;
status: string;
endpoint: string;
@@ -33,11 +34,16 @@ export const getPath = (subscriptionId: string, resourceGroup: string, name: str
return `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroup}/providers/Microsoft.DocumentDB/databaseAccounts/${name}/services/SqlDedicatedGateway`;
};
export const updateDedicatedGatewayResource = async (sku: string, instances: number): Promise<string> => {
export const updateDedicatedGatewayResource = async (
sku: string,
dedicatedGatewayType: string,
instances: number,
): Promise<string> => {
const path = getPath(userContext.subscriptionId, userContext.resourceGroup, userContext.databaseAccount.name);
const body: UpdateDedicatedGatewayRequestParameters = {
properties: {
instanceSize: sku,
dedicatedGatewayType: dedicatedGatewayType,
instanceCount: instances,
serviceType: "SqlDedicatedGateway",
},
@@ -109,12 +115,19 @@ export const getCurrentProvisioningState = async (): Promise<DedicatedGatewayRes
const response = await getDedicatedGatewayResource();
return {
sku: response.properties.instanceSize,
dedicatedGatewayType: response.properties.dedicatedGatewayType,
instances: response.properties.instanceCount,
status: response.properties.status,
endpoint: response.properties.sqlxEndPoint,
};
} catch (e) {
return { sku: undefined, instances: undefined, status: undefined, endpoint: undefined };
return {
sku: undefined,
dedicatedGatewayType: undefined,
instances: undefined,
status: undefined,
endpoint: undefined,
};
}
};

View File

@@ -70,6 +70,17 @@ const onSKUChange = (newValue: InputType, currentValues: Map<string, SmartUiInpu
return currentValues;
};
const IntegratedCache = "IntegratedCache";
const DistributedQuery = "DistributedQuery";
const onDedicatedGatewayTypeChange = (
newValue: InputType,
currentValues: Map<string, SmartUiInput>,
): Map<string, SmartUiInput> => {
currentValues.set("dedicatedGatewayType", { value: newValue });
return currentValues;
};
const onNumberOfInstancesChange = (
newValue: InputType,
currentValues: Map<string, SmartUiInput>,
@@ -109,6 +120,7 @@ const onEnableDedicatedGatewayChange = (
const dedicatedGatewayOriginallyEnabled = baselineValues.get("enableDedicatedGateway")?.value as boolean;
if (dedicatedGatewayOriginallyEnabled === newValue) {
currentValues.set("sku", baselineValues.get("sku"));
currentValues.set("dedicatedGatewayType", baselineValues.get("dedicatedGatewayType"));
currentValues.set("instances", baselineValues.get("instances"));
currentValues.set("costPerHour", baselineValues.get("costPerHour"));
currentValues.set("warningBanner", baselineValues.get("warningBanner"));
@@ -149,6 +161,7 @@ const onEnableDedicatedGatewayChange = (
currentValues.set("costPerHour", { value: costPerHourDefaultValue, hidden: true });
}
const sku = currentValues.get("sku");
const dedicatedGatewayType = currentValues.get("dedicatedGatewayType");
const instances = currentValues.get("instances");
const hideAttributes = newValue === undefined || !(newValue as boolean);
currentValues.set("sku", {
@@ -156,6 +169,11 @@ const onEnableDedicatedGatewayChange = (
hidden: hideAttributes,
disabled: dedicatedGatewayOriginallyEnabled,
});
currentValues.set("dedicatedGatewayType", {
value: dedicatedGatewayType.value,
hidden: hideAttributes,
disabled: dedicatedGatewayOriginallyEnabled,
});
currentValues.set("instances", {
value: instances.value,
hidden: hideAttributes,
@@ -185,6 +203,15 @@ const getSkus = async (): Promise<ChoiceItem[]> => {
return skuDropDownItems;
};
const dedicatedGatewayTypeDropDownItems: ChoiceItem[] = [
{ labelTKey: "Integrated Cache", key: IntegratedCache },
{ labelTKey: "Distributed Query", key: DistributedQuery },
];
const getDedicatedGatewayType = async (): Promise<ChoiceItem[]> => {
return dedicatedGatewayTypeDropDownItems;
};
const getInstancesMin = async (): Promise<number> => {
return 1;
};
@@ -193,6 +220,14 @@ const getInstancesMax = async (): Promise<number> => {
return 5;
};
const DedicatedGatewayTypeDropdownInfo: Info = {
messageTKey: "DedicatedGatewayTypeText",
link: {
href: "https://aka.ms/cosmos-db-dedicated-gateway-size",
textTKey: "DedicatedGatewayTypeLink",
},
};
const NumberOfInstancesDropdownInfo: Info = {
messageTKey: "ResizingDecisionText",
link: {
@@ -312,8 +347,9 @@ export default class SqlX extends SelfServeBaseClass {
};
} else {
const sku = currentValues.get("sku")?.value as string;
const dedicatedGatewayType = currentValues.get("dedicatedGatewayType")?.value as string;
const instances = currentValues.get("instances").value as number;
const operationStatusUrl = await updateDedicatedGatewayResource(sku, instances);
const operationStatusUrl = await updateDedicatedGatewayResource(sku, dedicatedGatewayType, instances);
return {
operationStatusUrl: operationStatusUrl,
portalNotification: {
@@ -334,8 +370,9 @@ export default class SqlX extends SelfServeBaseClass {
}
} else {
const sku = currentValues.get("sku")?.value as string;
const dedicatedGatewayType = currentValues.get("dedicatedGatewayType")?.value as string;
const instances = currentValues.get("instances").value as number;
const operationStatusUrl = await updateDedicatedGatewayResource(sku, instances);
const operationStatusUrl = await updateDedicatedGatewayResource(sku, dedicatedGatewayType, instances);
return {
operationStatusUrl: operationStatusUrl,
portalNotification: {
@@ -361,6 +398,7 @@ export default class SqlX extends SelfServeBaseClass {
const defaults = new Map<string, SmartUiInput>();
defaults.set("enableDedicatedGateway", { value: false });
defaults.set("sku", { value: CosmosD4s, hidden: true });
defaults.set("dedicatedGatewayType", { value: IntegratedCache, hidden: true });
defaults.set("instances", { value: await getInstancesMin(), hidden: true });
defaults.set("costPerHour", undefined);
defaults.set("connectionString", undefined);
@@ -378,6 +416,7 @@ export default class SqlX extends SelfServeBaseClass {
if (response.status && response.status !== "Deleting") {
defaults.set("enableDedicatedGateway", { value: true });
defaults.set("sku", { value: response.sku, disabled: true });
defaults.set("dedicatedGatewayType", { value: response.dedicatedGatewayType || IntegratedCache, disabled: true });
defaults.set("instances", { value: response.instances, disabled: false });
defaults.set("costPerHour", { value: calculateCost(response.sku, response.instances) });
defaults.set("connectionString", {
@@ -419,6 +458,15 @@ export default class SqlX extends SelfServeBaseClass {
})
enableDedicatedGateway: boolean;
@OnChange(onDedicatedGatewayTypeChange)
@PropertyInfo(DedicatedGatewayTypeDropdownInfo)
@Values({
labelTKey: "Dedicated Gateway Features",
choices: getDedicatedGatewayType,
placeholderTKey: "DedicatedGatewayTypePlaceHolder",
})
dedicatedGatewayType: ChoiceItem;
@OnChange(onSKUChange)
@Values({
labelTKey: "SKUs",

View File

@@ -10,6 +10,7 @@ export type SqlxServiceProps = {
creationTime: string;
status: string;
instanceSize: string;
dedicatedGatewayType: string;
instanceCount: number;
sqlxEndPoint: string;
};
@@ -26,6 +27,7 @@ export type UpdateDedicatedGatewayRequestParameters = {
export type UpdateDedicatedGatewayRequestProperties = {
instanceSize: string;
dedicatedGatewayType: string;
instanceCount: number;
serviceType: string;
};