-
Notifications
You must be signed in to change notification settings - Fork 149
Expand file tree
/
Copy pathRemoteSettingsAddStep.ts
More file actions
38 lines (33 loc) · 1.98 KB
/
RemoteSettingsAddStep.ts
File metadata and controls
38 lines (33 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { activitySuccessContext, activitySuccessIcon, AzureWizardExecuteStep, createUniversallyUniqueContextValue, GenericTreeItem, nonNullProp } from "@microsoft/vscode-azext-utils";
import { ext } from "../../extensionVariables";
import { localize } from "../../localize";
import { type AddMIConnectionsContext } from "./AddMIConnectionsContext";
export class RemoteSettingsAddStep extends AzureWizardExecuteStep<AddMIConnectionsContext> {
public priority: number = 110;
public async execute(context: AddMIConnectionsContext): Promise<void> {
const client = await nonNullProp(context, 'functionapp').site.createClient(context);
const remoteSettings = await client.listApplicationSettings();
const properties = remoteSettings.properties || {};
for (const connection of nonNullProp(context, 'connectionsToAdd')) {
properties[connection.name] = connection.value;
}
await client.updateApplicationSettings({ properties });
for (const connection of nonNullProp(context, 'connectionsToAdd')) {
context.activityChildren?.push(
new GenericTreeItem(undefined, {
contextValue: createUniversallyUniqueContextValue(['useExistingResourceGroupInfoItem', activitySuccessContext]),
label: localize('addedAppSetting', 'Add app setting "{0}"', connection.name),
iconPath: activitySuccessIcon
})
);
}
await ext.rgApi.tree.refresh(context);
}
public shouldExecute(context: AddMIConnectionsContext): boolean {
return !!context.functionapp && !!context.connections;
}
}