Skip to content
13 changes: 12 additions & 1 deletion appservice/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,15 @@
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/

export { azExtEslintRecommendedTypeChecked as default } from '@microsoft/vscode-azext-eng/eslint'; // Other configurations exist
import { azExtEslintRecommendedTypeChecked, lazyImportRuleConfig } from '@microsoft/vscode-azext-eng/eslint'; // Other configurations exist
import { defineConfig } from 'eslint/config';

export default defineConfig([
azExtEslintRecommendedTypeChecked,
lazyImportRuleConfig([
'@azure/*',
'simple-git',
'ws',
'!@azure/core-rest-pipeline', // Small
]),
]);
4,916 changes: 499 additions & 4,417 deletions appservice/package-lock.json

Large diffs are not rendered by default.

44 changes: 21 additions & 23 deletions appservice/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@microsoft/vscode-azext-azureappservice",
"author": "Microsoft Corporation",
"version": "4.1.0",
"version": "4.1.1",
"description": "Common tools for developing Azure App Service extensions for VS Code",
"tags": [
"azure",
Expand Down Expand Up @@ -36,37 +36,35 @@
"vscode": "^1.105.0"
},
"dependencies": {
"@azure/abort-controller": "^1.0.4",
"@azure/arm-appinsights": "^5.0.0-beta.4",
"@azure/arm-appinsights": "^5.0.0-beta.8",
"@azure/arm-appservice": "^18.0.0",
"@azure/arm-operationalinsights": "^8.0.1",
"@azure/arm-resourcegraph": "^5.0.0-beta.3",
"@azure/core-rest-pipeline": "^1.10.3",
"@azure/storage-blob": "^12.3.0",
"@microsoft/vscode-azext-azureutils": "^4.0.0",
"@microsoft/vscode-azext-github": "^2.0.0",
"@microsoft/vscode-azext-utils": "^4.0.3",
"dayjs": "^1.11.2",
"fs-extra": "^10.0.0",
"p-retry": "^3.0.1",
"pretty-bytes": "^5.3.0",
"simple-git": "^3.5.0",
"ws": "^8.5.0",
"yazl": "^2.5.1"
"@azure/arm-operationalinsights": "^10.1.0",
"@azure/arm-resourcegraph": "^5.0.0-beta.4",
"@azure/core-rest-pipeline": "^1.22.2",
"@azure/storage-blob": "^12.31.0",
"@microsoft/vscode-azext-azureutils": "^4.0.1",
"@microsoft/vscode-azext-github": "^2.0.1",
"@microsoft/vscode-azext-utils": "^4.0.4",
"dayjs": "^1.11.19",
"fs-extra": "^11.3.3",
"p-retry": "^7.1.1",
"pretty-bytes": "^7.1.0",
"simple-git": "^3.30.0",
"ws": "^8.19.0",
"yazl": "^3.3.1"
},
"peerDependencies": {
"@azure/ms-rest-azure-env": "^2.0.0",
"@microsoft/vscode-azext-azureappsettings": "^1.0.0"
},
"devDependencies": {
"@azure/core-client": "^1.7.2",
"@microsoft/vscode-azext-eng": "1.0.0-alpha.8",
"@types/fs-extra": "^9.0.13",
"@azure/core-client": "*",
"@microsoft/vscode-azext-eng": "1.0.0-alpha.12",
"@types/fs-extra": "^11.0.4",
"@types/node": "22.x",
"@types/p-retry": "^2.0.0",
"@types/vscode": "1.105.0",
"@types/ws": "^8.5.3",
"@types/yazl": "^2.4.2",
"@types/ws": "^8.18.1",
"@types/yazl": "^3.3.0",
"@vscode/test-cli": "*",
"@vscode/test-electron": "*"
}
Expand Down
27 changes: 13 additions & 14 deletions appservice/src/SiteClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import type { AppServicePlan, FunctionEnvelope, FunctionSecrets, HostKeys, HostNameSslState, ManagedServiceIdentity, Site, SiteConfigResource, SiteLogsConfig, SiteSourceControl, SlotConfigNamesResource, SourceControl, StringDictionary, User, WebAppsListFunctionKeysResponse, WebJob, WebSiteInstanceStatus, WebSiteManagementClient } from '@azure/arm-appservice';
import type { ServiceClient } from '@azure/core-client';
import type { AppServicePlan, FunctionEnvelope, FunctionSecrets, HostKeys, ManagedServiceIdentity, Site, SiteConfigResource, SiteLogsConfig, SiteSourceControl, SlotConfigNamesResource, SourceControl, StringDictionary, User, WebAppsListFunctionKeysResponse, WebJob, WebSiteInstanceStatus, WebSiteManagementClient } from '@azure/arm-appservice';
import { RequestBodyType, createHttpHeaders, createPipelineRequest } from '@azure/core-rest-pipeline';
import type { AppSettingsClientProvider, IAppSettingsClient } from '@microsoft/vscode-azext-azureappsettings';
import { AzExtPipelineResponse, createGenericClient, uiUtils } from '@microsoft/vscode-azext-azureutils';
Expand Down Expand Up @@ -86,7 +85,7 @@ export class ParsedSite implements AppSettingsClientProvider {

this.defaultHostName = nonNullProp(site, 'defaultHostName');
this.defaultHostUrl = `https://${this.defaultHostName}`;
const kuduRepositoryUrl: HostNameSslState | undefined = nonNullProp(site, 'hostNameSslStates').find(h => !!h.hostType && h.hostType.toLowerCase() === 'repository');
const kuduRepositoryUrl = nonNullProp(site, 'hostNameSslStates').find(h => !!h.hostType && h.hostType.toLowerCase() === 'repository');
if (kuduRepositoryUrl) {
this.kuduHostName = kuduRepositoryUrl.name;
this.kuduUrl = `https://${this.kuduHostName}`;
Expand Down Expand Up @@ -332,7 +331,7 @@ export class SiteClient implements IAppSettingsClient {
}

public async zipPushDeploy(context: IActionContext, file: RequestBodyType, rawQueryParameters: KuduModels.PushDeploymentZipPushDeployOptionalParams): Promise<AzExtPipelineResponse> {
const client: ServiceClient = await createGenericClient(context, this._site.subscription);
const client = await createGenericClient(context, this._site.subscription);
const queryParameters = convertQueryParamsValuesToString(rawQueryParameters);
const queryString = new URLSearchParams(queryParameters).toString();
const request = createPipelineRequest({
Expand All @@ -345,7 +344,7 @@ export class SiteClient implements IAppSettingsClient {
}

public async warPushDeploy(context: IActionContext, file: RequestBodyType, rawQueryParameters: KuduModels.PushDeploymentWarPushDeployOptionalParams): Promise<AzExtPipelineResponse> {
const client: ServiceClient = await createGenericClient(context, this._site.subscription);
const client = await createGenericClient(context, this._site.subscription);
const queryParameters = convertQueryParamsValuesToString(rawQueryParameters);
const queryString = new URLSearchParams(queryParameters).toString();
const request = createPipelineRequest({
Expand All @@ -360,7 +359,7 @@ export class SiteClient implements IAppSettingsClient {
// TODO: only supporting /zip endpoint for now, but should support /zipurl as well
public async flexDeploy(context: IActionContext, file: RequestBodyType,
rawQueryParameters: { RemoteBuild?: boolean, Deployer?: string }): Promise<AzExtPipelineResponse> {
const client: ServiceClient = await createGenericClient(context, this._site.subscription);
const client = await createGenericClient(context, this._site.subscription);
const queryParameters = convertQueryParamsValuesToString(rawQueryParameters);
const queryString = new URLSearchParams(queryParameters).toString();
const headers = createHttpHeaders({
Expand All @@ -378,7 +377,7 @@ export class SiteClient implements IAppSettingsClient {
}

public async deploy(context: IActionContext, id: string): Promise<AzExtPipelineResponse> {
const client: ServiceClient = await createGenericClient(context, this._site.subscription);
const client = await createGenericClient(context, this._site.subscription);
return await client.sendRequest(createPipelineRequest({
method: 'PUT',
url: `${this._site.kuduUrl}/api/deployments/${id}`
Expand All @@ -387,7 +386,7 @@ export class SiteClient implements IAppSettingsClient {

// the ARM call doesn't give all of the metadata we require so ping the scm directly
public async getDeployResults(context: IActionContext): Promise<KuduModels.DeployResult[]> {
const client: ServiceClient = await createGenericClient(context, this._site.subscription, {
const client = await createGenericClient(context, this._site.subscription, {
addStatusCodePolicy: true,
});
const response: AzExtPipelineResponse = await client.sendRequest(createPipelineRequest({
Expand All @@ -407,7 +406,7 @@ export class SiteClient implements IAppSettingsClient {

// the ARM call doesn't give all of the metadata we require so ping the scm directly
public async getDeployResult(context: IActionContext, deployId: string): Promise<KuduModels.DeployResult> {
const client: ServiceClient = await createGenericClient(context, this._site.subscription, {
const client = await createGenericClient(context, this._site.subscription, {
addStatusCodePolicy: true,
});
const response: AzExtPipelineResponse = await client.sendRequest(createPipelineRequest({
Expand All @@ -419,7 +418,7 @@ export class SiteClient implements IAppSettingsClient {

// no equivalent ARM call
public async getLogEntry(context: IActionContext, deployId: string): Promise<KuduModels.LogEntry[]> {
const client: ServiceClient = await createGenericClient(context, this._site.subscription, {
const client = await createGenericClient(context, this._site.subscription, {
addStatusCodePolicy: true,
});
const response: AzExtPipelineResponse = await client.sendRequest(createPipelineRequest({
Expand All @@ -440,7 +439,7 @@ export class SiteClient implements IAppSettingsClient {

// no equivalent ARM call
public async getLogEntryDetails(context: IActionContext, deployId: string, logId: string): Promise<KuduModels.LogEntry[]> {
const client: ServiceClient = await createGenericClient(context, this._site.subscription, {
const client = await createGenericClient(context, this._site.subscription, {
addStatusCodePolicy: true,
});
const response: AzExtPipelineResponse = await client.sendRequest(createPipelineRequest({
Expand All @@ -459,15 +458,15 @@ export class SiteClient implements IAppSettingsClient {
}

public async vfsGetItem(context: IActionContext, url: string): Promise<AzExtPipelineResponse> {
const client: ServiceClient = await createGenericClient(context, this._site.subscription);
const client = await createGenericClient(context, this._site.subscription);
return await client.sendRequest(createPipelineRequest({
method: 'GET',
url,
}));
}

public async vfsPutItem(context: IActionContext, data: string | ArrayBuffer | Uint8Array, url: string, rawHeaders?: Record<string, string>): Promise<AzExtPipelineResponse> {
const client: ServiceClient = await createGenericClient(context, this._site.subscription);
const client = await createGenericClient(context, this._site.subscription);
const headers = createHttpHeaders(rawHeaders);
return await client.sendRequest(createPipelineRequest({
method: 'PUT',
Expand All @@ -484,7 +483,7 @@ export class SiteClient implements IAppSettingsClient {
*/
private async getCachedSku(context: IActionContext): Promise<string | undefined> {
if (!this._cachedSku) {
const client: ServiceClient = await createGenericClient(context, this._site.subscription);
const client = await createGenericClient(context, this._site.subscription);
const response: AzExtPipelineResponse = await client.sendRequest(createPipelineRequest({ method: 'GET', url: `${this._site.id}?api-version=2016-08-01` }));
this._cachedSku = (<{ properties: { sku?: string } }>response.parsedBody).properties.sku;
}
Expand Down
15 changes: 8 additions & 7 deletions appservice/src/TunnelProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import type { ServiceClient } from '@azure/core-client';
import { RestError, bearerTokenAuthenticationPolicy, createPipelineRequest } from "@azure/core-rest-pipeline";
import { AzExtPipelineResponse, createGenericClient } from '@microsoft/vscode-azext-azureutils';
import { AzExtServiceClientCredentials, IActionContext, IParsedError, UserCancelledError, parseError } from '@microsoft/vscode-azext-utils';
import { Server, Socket, createServer } from 'net';
import { CancellationToken, Disposable, l10n } from 'vscode';
import * as ws from 'ws';
import type { WebSocket } from 'ws';
import { ParsedSite } from './SiteClient';
import { ext } from './extensionVariables';
import { delay } from './utils/delay';
Expand Down Expand Up @@ -42,7 +41,7 @@ export class TunnelProxy {
private _port: number;
private _site: ParsedSite;
private _server: Server;
private _openSockets: ws.WebSocket[];
private _openSockets: WebSocket[];
private _isSsh: boolean;
private _credentials: AzExtServiceClientCredentials;

Expand All @@ -67,7 +66,7 @@ export class TunnelProxy {
}

public dispose(): void {
this._openSockets.forEach((tunnelSocket: ws.WebSocket) => {
this._openSockets.forEach((tunnelSocket: WebSocket) => {
tunnelSocket.close();
});
this._server.close();
Expand All @@ -79,7 +78,7 @@ export class TunnelProxy {
*/
private async pingApp(context: IActionContext): Promise<void> {
ext.outputChannel.appendLog('[Tunnel] Pinging app default url...');
const client: ServiceClient = await createGenericClient(context, undefined);
const client = await createGenericClient(context, undefined);
let statusCode: number | undefined;
try {
const response: AzExtPipelineResponse = await client.sendRequest(createPipelineRequest({ method: 'GET', url: this._site.defaultHostUrl }));
Expand All @@ -95,7 +94,7 @@ export class TunnelProxy {
}

private async checkTunnelStatus(context: IActionContext): Promise<void> {
const client: ServiceClient = await createGenericClient(context, undefined);
const client = await createGenericClient(context, undefined);
client.pipeline.addPolicy(bearerTokenAuthenticationPolicy({
scopes: [],
credential: this._credentials
Expand Down Expand Up @@ -161,6 +160,8 @@ export class TunnelProxy {
}

private async setupTunnelServer(bearerToken: string, token: CancellationToken): Promise<void> {
const ws = await import('ws');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check this import too.


return new Promise<void>((resolve: () => void, reject: (err: Error) => void): void => {
const listener: Disposable = token.onCancellationRequested(() => {
reject(new UserCancelledError('setupTunnelServer'));
Expand All @@ -169,7 +170,7 @@ export class TunnelProxy {

this._server.on('connection', (socket: Socket) => {
socket.pause(); // Pause while making the connection
const tunnelSocket: ws.WebSocket = new ws.WebSocket(
const tunnelSocket = new ws.WebSocket(
`wss://${this._site.kuduHostName}/AppServiceTunnel/Tunnel.ashx`,
{
headers: {
Expand Down
8 changes: 3 additions & 5 deletions appservice/src/createAppService/AppInsightsCreateStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import type { ApplicationInsightsManagementClient } from '@azure/arm-appinsights';
import type { ResourceGroup } from '@azure/arm-resources';
import { AzExtLocation, LocationListStep } from '@microsoft/vscode-azext-azureutils';
import { ActivityChildItem, ActivityChildType, activityErrorContext, activityFailContext, activityFailIcon, ActivityOutputType, AzureWizardExecuteStepWithActivityOutput, createContextValue, ExecuteActivityContext, ExecuteActivityOutput, nonNullProp, nonNullValueAndProp, parseError } from '@microsoft/vscode-azext-utils';
import { randomUUID } from 'crypto';
Expand Down Expand Up @@ -44,7 +42,7 @@ export class AppInsightsCreateStep extends AzureWizardExecuteStepWithActivityOut
const rgName: string = nonNullValueAndProp(context.resourceGroup, 'name');

try {
const client: ApplicationInsightsManagementClient = await createAppInsightsClient(context);
const client = await createAppInsightsClient(context);
context.appInsightsComponent = await client.components.get(rgName, newAppInsightsName);
ext.outputChannel.appendLog(l10n.t('Found existing application insights "{0}".', newAppInsightsName));
ext.outputChannel.appendLog(l10n.t('Using existing application insights "{0}".', newAppInsightsName));
Expand All @@ -59,8 +57,8 @@ export class AppInsightsCreateStep extends AzureWizardExecuteStepWithActivityOut
const resourceLocation: AzExtLocation = await LocationListStep.getLocation(context);
const appInsightsLocation = await getAppInsightsSupportedLocation(context, resourceLocation);
if (appInsightsLocation) {
const client: ApplicationInsightsManagementClient = await createAppInsightsClient(context);
const rg: ResourceGroup = nonNullProp(context, 'resourceGroup');
const client = await createAppInsightsClient(context);
const rg = nonNullProp(context, 'resourceGroup');
const rgName: string = nonNullProp(rg, 'name');
const aiName: string = nonNullProp(context, 'newAppInsightsName');

Expand Down
4 changes: 2 additions & 2 deletions appservice/src/createAppService/AppInsightsListStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import type { ApplicationInsightsComponent, ApplicationInsightsManagementClient } from "@azure/arm-appinsights";
import type { ApplicationInsightsComponent } from "@azure/arm-appinsights";
import { LocationListStep, uiUtils } from "@microsoft/vscode-azext-azureutils";
import { AzureWizardPromptStep, IAzureNamingRules, IAzureQuickPickItem, IAzureQuickPickOptions, IWizardOptions, nonNullProp } from "@microsoft/vscode-azext-utils";
import * as vscode from 'vscode';
Expand Down Expand Up @@ -32,7 +32,7 @@ export class AppInsightsListStep extends AzureWizardPromptStep<IAppServiceWizard

public static async getAppInsightsComponents(context: IAppServiceWizardContext): Promise<ApplicationInsightsComponent[]> {
if (context.appInsightsTask === undefined) {
const client: ApplicationInsightsManagementClient = await createAppInsightsClient(context);
const client = await createAppInsightsClient(context);
context.appInsightsTask = uiUtils.listAllIterator(client.components.list());
}

Expand Down
5 changes: 2 additions & 3 deletions appservice/src/createAppService/AppInsightsNameStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import type { ApplicationInsightsComponent } from '@azure/arm-appinsights';
import { AzureWizardPromptStep } from '@microsoft/vscode-azext-utils';
import * as vscode from 'vscode';
import { AppInsightsListStep, appInsightsNamingRules } from './AppInsightsListStep';
Expand All @@ -12,8 +11,8 @@ import { IAppServiceWizardContext } from './IAppServiceWizardContext';
export class AppInsightsNameStep extends AzureWizardPromptStep<IAppServiceWizardContext> {

public async isNameAvailable(context: IAppServiceWizardContext, name: string): Promise<boolean> {
const appInsightsComponents: ApplicationInsightsComponent[] = await AppInsightsListStep.getAppInsightsComponents(context);
return !appInsightsComponents.some((ai: ApplicationInsightsComponent) => ai.name !== undefined && ai.name.toLowerCase() === name.toLowerCase());
const appInsightsComponents = await AppInsightsListStep.getAppInsightsComponents(context);
return !appInsightsComponents.some((ai) => ai.name !== undefined && ai.name.toLowerCase() === name.toLowerCase());
}

public async prompt(context: IAppServiceWizardContext): Promise<void> {
Expand Down
Loading