Skip to content

Commit

Permalink
Add Service Connector (#2511)
Browse files Browse the repository at this point in the history
* Initial commit

* Add Service Connector

* Remove utils changes

* Add service connector UI

* More changes for UI

* Flip

* Requested changes and update package

* Add name to activity log

* Update package and change names

* Hope this is it
  • Loading branch information
motm32 authored Aug 23, 2023
1 parent 86b1d96 commit 64252ce
Show file tree
Hide file tree
Showing 9 changed files with 1,931 additions and 11,415 deletions.
13,209 changes: 1,795 additions & 11,414 deletions package-lock.json

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@
"title": "%appService.connectToGitHub%",
"category": "Azure App Service"
},
{
"command": "appService.createServiceConnector",
"title": "%appService.createServiceConnector%",
"category": "Azure App Service"
},
{
"command": "appService.CreateSlot",
"title": "%appService.CreateSlot%",
Expand All @@ -170,6 +175,11 @@
"title": "%appService.Delete%",
"category": "Azure App Service"
},
{
"command": "appService.deleteServiceConnector",
"title": "%appService.deleteServiceConnector%",
"category": "Azure App Service"
},
{
"command": "appService.Deploy",
"title": "%appService.Deploy%",
Expand Down Expand Up @@ -288,6 +298,11 @@
"category": "Azure App Service",
"icon": "$(eye)"
},
{
"command": "appService.validateServiceConnector",
"title": "%appService.validateServiceConnector%",
"category": "Azure App Service"
},
{
"command": "appService.ViewCommitInGitHub",
"title": "%appService.ViewCommitInGitHub%",
Expand Down Expand Up @@ -343,6 +358,10 @@
{
"command": "appService.ViewProperties",
"when": "never"
},
{
"command": "appService.validateServiceConnector",
"when": "never"
}
],
"appService.submenus.workspaceActions": [
Expand Down Expand Up @@ -625,6 +644,21 @@
"command": "appService.OpenInPortal",
"when": "view =~ /(azureResourceGroups|azureFocusView)/ && viewItem =~ /appService.*deployment\\//",
"group": "1@4"
},
{
"command": "appService.createServiceConnector",
"when": "view == azureResourceGroups && viewItem =~ /serviceConnectorGroupItem/",
"group": "1@1"
},
{
"command": "appService.deleteServiceConnector",
"when": "view == azureResourceGroups && viewItem =~ /serviceConnectorItem/",
"group": "1@1"
},
{
"command": "appService.validateServiceConnector",
"when": "view == azureResourceGroups && viewItem =~ /serviceConnectorItem/",
"group": "1@2"
}
],
"explorer/context": [
Expand Down Expand Up @@ -813,6 +847,7 @@
"@microsoft/vscode-azext-azureappservice": "^2.2.0",
"@microsoft/vscode-azext-azureappsettings": "^0.2.0",
"@microsoft/vscode-azext-azureutils": "^2.0.1",
"@microsoft/vscode-azext-serviceconnector": "0.1.1",
"@microsoft/vscode-azext-utils": "^2.0.1",
"@microsoft/vscode-azureresources-api": "^2.0.2",
"dotenv": "^6.2.0",
Expand Down
3 changes: 3 additions & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@
"appService.connections.connId": "Connection id",
"appService.connections.connection": "Connections of specific web app.",
"appService.connections.dbArray": "Array of Cosmos DB database ids.",
"appService.createServiceConnector": "Create connection...",
"appService.createWebAppDetail": "Host your APIs and full stack apps.",
"appService.createWebAppTitle": "Create App Service Web App...",
"appService.defaultWebAppToDeploy": "The default web app to use when deploying represented by its full Azure id. Every subsequent deployment of this workspace will deploy to this web app or slot. Can be disabled by setting to \"None\"",
"appService.deleteServiceConnector": "Delete connection...",
"appService.deploySubpath": "The default subpath of a workspace folder to use when deploying.",
"appService.description": "An Azure App Service management extension for Visual Studio Code.",
"appService.enableOutputTimestamps": "Prepends each line displayed in the Azure App Service output channel with a timestamp",
Expand All @@ -62,6 +64,7 @@
"appService.showSavePrompt": "Show warning dialog on remote file uploading.",
"appService.startStreamingLogs": "Start Streaming Logs",
"appService.toggleAppSettingVisibility": "Toggle App Value Visibility",
"appService.validateServiceConnector": "Validate",
"appService.viewDeploymentLogs": "View Deployment Logs",
"appService.zipGlobPattern": "Defines which files in the workspace to deploy. This applies to Zip deploy only, has no effect on other deployment methods.",
"appService.zipIgnorePattern": "Defines which files in the workspace to ignore for Zip deploy. This applies to Zip deploy only, has no effect on other deployment methods."
Expand Down
6 changes: 6 additions & 0 deletions src/commands/registerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ import { stopStreamingLogs } from './logstream/stopStreamingLogs';
import { openInPortal } from './openInPortal';
import { startRemoteDebug } from './remoteDebug/startRemoteDebug';
import { restartWebApp } from './restartWebApp';
import { createServiceConnector } from './serviceConnector/createServiceConnector';
import { deleteServiceConnector } from './serviceConnector/deleteServiceConnector';
import { validateServiceConnector } from './serviceConnector/validateServiceConnector';
import { showFile } from './showFile';
import { startSsh } from './startSsh';
import { startWebApp } from './startWebApp';
Expand Down Expand Up @@ -87,6 +90,9 @@ export function registerCommands(): void {
registerCommandWithTreeNodeUnwrapping('appService.toggleAppSettingVisibility', async (actionContext: IActionContext, node?: AppSettingTreeItem) => { await nonNullValue(node).toggleValueVisibility(actionContext); }, 250);
registerCommandWithTreeNodeUnwrapping('appService.ViewCommitInGitHub', viewCommitInGitHub);
registerCommandWithTreeNodeUnwrapping('appService.ViewProperties', viewProperties);
registerCommandWithTreeNodeUnwrapping('appService.createServiceConnector', createServiceConnector);
registerCommandWithTreeNodeUnwrapping('appService.deleteServiceConnector', deleteServiceConnector);
registerCommandWithTreeNodeUnwrapping('appService.validateServiceConnector', validateServiceConnector);
registerSiteCommand('appService.Deploy', unwrapTreeNodeCommandCallback(deploy));
registerSiteCommand('appService.DeploySlot', unwrapTreeNodeCommandCallback(deploySlot));
registerSiteCommand('appService.Redeploy', unwrapTreeNodeCommandCallback(redeployDeployment));
Expand Down
27 changes: 27 additions & 0 deletions src/commands/serviceConnector/createServiceConnector.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { ServiceConnectorGroupTreeItem, createLinker } from "@microsoft/vscode-azext-serviceconnector";
import { IActionContext } from "@microsoft/vscode-azext-utils";
import { localize } from "../../localize";
import { SiteTreeItem } from "../../tree/SiteTreeItem";
import { createActivityContext } from "../../utils/activityUtils";
import { pickWebApp } from "../../utils/pickWebApp";

export async function createServiceConnector(context: IActionContext, item?: SiteTreeItem | ServiceConnectorGroupTreeItem): Promise<void> {
item ??= await pickWebApp(context);
if (item instanceof ServiceConnectorGroupTreeItem) {
item = <SiteTreeItem>item.parent;
}

const activityContext = {
...context,
...await createActivityContext(),
activityTitle: localize('createServiceConnector', 'Create connection'),
}

await createLinker(activityContext, item.id, item.subscription);
await item.refresh(context);
}
30 changes: 30 additions & 0 deletions src/commands/serviceConnector/deleteServiceConnector.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { ServiceConnectorTreeItem, deleteLinker } from "@microsoft/vscode-azext-serviceconnector";
import { IActionContext } from "@microsoft/vscode-azext-utils";
import { localize } from "../../localize";
import { SiteTreeItem } from "../../tree/SiteTreeItem";
import { createActivityContext } from "../../utils/activityUtils";
import { pickWebApp } from "../../utils/pickWebApp";

export async function deleteServiceConnector(context: IActionContext, item?: SiteTreeItem | ServiceConnectorTreeItem): Promise<void> {
let serviceConnectorName = undefined
item ??= await pickWebApp(context);

if (item instanceof ServiceConnectorTreeItem) {
serviceConnectorName = item.label;
item = <SiteTreeItem>item.parent?.parent;
}

const activityContext = {
...context,
...await createActivityContext(),
activityTitle: localize('deleteServiceConnector', 'Delete connection'),
}

await deleteLinker(activityContext, item.id, item.subscription, serviceConnectorName);
await item.refresh(context);
}
29 changes: 29 additions & 0 deletions src/commands/serviceConnector/validateServiceConnector.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { ServiceConnectorTreeItem, validateLinker } from "@microsoft/vscode-azext-serviceconnector";
import { IActionContext } from "@microsoft/vscode-azext-utils";
import { localize } from "../../localize";
import { SiteTreeItem } from "../../tree/SiteTreeItem";
import { createActivityContext } from "../../utils/activityUtils";
import { pickWebApp } from "../../utils/pickWebApp";

export async function validateServiceConnector(context: IActionContext, item?: SiteTreeItem | ServiceConnectorTreeItem): Promise<void> {
let serviceConnectorName = undefined
item ??= await pickWebApp(context);

if (item instanceof ServiceConnectorTreeItem) {
serviceConnectorName = item.label;
item = <SiteTreeItem>item.parent?.parent;
}

const activityContext = {
...context,
...await createActivityContext(),
activityTitle: localize('validate', `Validate connection "{0}"`, serviceConnectorName),
}

await validateLinker(activityContext, item.id, item.subscription, serviceConnectorName);
}
2 changes: 2 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import { registerAppServiceExtensionVariables } from '@microsoft/vscode-azext-azureappservice';
import { registerAzureUtilsExtensionVariables } from '@microsoft/vscode-azext-azureutils';
import { registerServiceConnectorExtensionVariables } from '@microsoft/vscode-azext-serviceconnector';
import { apiUtils, AzureExtensionApi, callWithTelemetryAndErrorHandling, createApiProvider, createAzExtOutputChannel, createExperimentationService, IActionContext, registerErrorHandler, registerReportIssueCommand, registerUIExtensionVariables } from '@microsoft/vscode-azext-utils';
import { AzExtResourceType } from '@microsoft/vscode-azureresources-api';
import * as vscode from 'vscode';
Expand All @@ -31,6 +32,7 @@ export async function activateInternal(
registerUIExtensionVariables(ext);
registerAzureUtilsExtensionVariables(ext);
registerAppServiceExtensionVariables(ext);
registerServiceConnectorExtensionVariables(ext);

await callWithTelemetryAndErrorHandling('appService.activate', async (activateContext: IActionContext) => {
activateContext.telemetry.properties.isActivationEvent = 'true';
Expand Down
5 changes: 4 additions & 1 deletion src/tree/ResolvedWebAppResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { AppServicePlan, Site, SiteConfig, SiteLogsConfig, SiteSourceControl } from '@azure/arm-appservice';
import { DeleteLastServicePlanStep, DeleteSiteStep, DeploymentTreeItem, DeploymentsTreeItem, FolderTreeItem, LogFilesTreeItem, ParsedSite, SiteFilesTreeItem } from '@microsoft/vscode-azext-azureappservice';
import { AppSettingTreeItem, AppSettingsTreeItem } from '@microsoft/vscode-azext-azureappsettings';
import { ServiceConnectorGroupTreeItem } from '@microsoft/vscode-azext-serviceconnector';
import { AzExtTreeItem, AzureWizard, DeleteConfirmationStep, IActionContext, ISubscriptionContext, TreeItemIconPath, nonNullProp } from '@microsoft/vscode-azext-utils';
import { ResolvedAppResourceBase, } from '@microsoft/vscode-azext-utils/hostapi';
import { ViewPropertiesModel } from '@microsoft/vscode-azureresources-api';
Expand Down Expand Up @@ -52,6 +53,7 @@ export class ResolvedWebAppResource implements ResolvedAppResourceBase, ISiteTre
private _siteFilesNode!: SiteFilesTreeItem;
private _logFilesNode!: LogFilesTreeItem;
private _webJobsNode!: WebJobsTreeItem | WebJobsNATreeItem;
private _serviceConnectorNode!: ServiceConnectorGroupTreeItem;

private _subscription: ISubscriptionContext;

Expand Down Expand Up @@ -147,6 +149,7 @@ export class ResolvedWebAppResource implements ResolvedAppResourceBase, ISiteTre
});
// Can't find actual documentation on this, but the portal claims it and this feedback suggests it's not planned https://aka.ms/AA4q5gi
this._webJobsNode = this.site.isLinux ? new WebJobsNATreeItem(proxyTree) : new WebJobsTreeItem(proxyTree);
this._serviceConnectorNode = new ServiceConnectorGroupTreeItem(proxyTree, this.site.id);

const client = await this.site.createClient(context);
const siteConfig: SiteConfig = await client.getSiteConfig();
Expand All @@ -158,7 +161,7 @@ export class ResolvedWebAppResource implements ResolvedAppResourceBase, ISiteTre
contextValuesToAdd: ['appService']
});

const children: AzExtTreeItem[] = [this.appSettingsNode, this._connectionsNode, this.deploymentsNode, this._siteFilesNode, this._logFilesNode, this._webJobsNode];
const children: AzExtTreeItem[] = [this.appSettingsNode, this._connectionsNode, this.deploymentsNode, this._siteFilesNode, this._logFilesNode, this._webJobsNode, this._serviceConnectorNode];

if (!this.site.isSlot) {
let tier: string | undefined;
Expand Down

0 comments on commit 64252ce

Please sign in to comment.