Skip to content

Commit

Permalink
Update to new azure-sdk-for-js
Browse files Browse the repository at this point in the history
  • Loading branch information
ejizba committed Jul 24, 2020
1 parent d087ea2 commit 061713b
Show file tree
Hide file tree
Showing 42 changed files with 115 additions and 187 deletions.
7 changes: 3 additions & 4 deletions gulpfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// tslint:disable:typedef
// tslint:disable:no-unsafe-any

import * as msRest from '@azure/ms-rest-js';
import * as fse from 'fs-extra';
import * as gulp from 'gulp';
import * as chmod from 'gulp-chmod';
Expand All @@ -18,7 +19,6 @@ import * as filter from 'gulp-filter';
import * as os from 'os';
import * as path from 'path';
import * as request from 'request';
import * as requestP from 'request-promise';
import * as buffer from 'vinyl-buffer';
import * as source from 'vinyl-source-stream';
import { gulp_installAzureAccount, gulp_installVSCodeExtension, gulp_webpack } from 'vscode-azureextensiondev';
Expand All @@ -34,9 +34,8 @@ async function prepareForWebpack(): Promise<void> {

let downloadLink;
async function getFuncLink() {
// tslint:disable-next-line:no-any
const body = await <any>requestP('https://aka.ms/V00v5v');
const cliFeed = JSON.parse(body);
const client = new msRest.ServiceClient();
const cliFeed = (await client.sendRequest({ method: 'GET', url: 'https://aka.ms/V00v5v' })).parsedBody;
const version = cliFeed.tags['v3-prerelease'].release;
console.log(`Func cli feed version: ${version}`);
const cliRelease = cliFeed.releases[version].standaloneCli.find((rel) => {
Expand Down
28 changes: 13 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1025,13 +1025,12 @@
"@types/p-retry": "^3.0.1",
"@types/ps-tree": "^1.1.0",
"@types/request": "2.0.7",
"@types/request-promise": "4.1.38",
"@types/semver": "^5.5.0",
"@types/vscode": "1.40.0",
"@types/websocket": "^1.0.0",
"@types/xml2js": "^0.4.5",
"@types/xregexp": "^3.0.30",
"azure-arm-resource": "^3.0.0-preview",
"@azure/arm-resources": "^3.0.0",
"copy-webpack-plugin": "^5.1.1",
"glob": "^7.1.6",
"gulp": "^4.0.2",
Expand All @@ -1041,39 +1040,38 @@
"mocha": "^7.1.1",
"mocha-junit-reporter": "^1.23.3",
"mocha-multi-reporters": "^1.1.7",
"request": "^2.88.2",
"ts-node": "^7.0.1",
"tslint": "^5.20.1",
"tslint-microsoft-contrib": "^6.2.0",
"typescript": "^3.8.3",
"vinyl-buffer": "^1.0.1",
"vinyl-source-stream": "^2.0.0",
"vsce": "^1.71.0",
"vscode-azureextensiondev": "^0.4.0",
"vscode-azureextensiondev": "^0.5.0",
"vscode-test": "^1.3.0",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10"
},
"dependencies": {
"azure-arm-appinsights": "^2.1.0",
"azure-arm-cosmosdb": "^1.1.2",
"azure-arm-eventhub": "^3.2.0",
"azure-arm-sb": "^2.3.0-preview",
"azure-arm-storage": "^4.0.0",
"azure-arm-website": "^5.3.0",
"@azure/arm-appinsights": "^2.1.0",
"@azure/arm-appservice": "^6.0.0",
"@azure/arm-cosmosdb": "^9.0.0",
"@azure/arm-eventhub": "^3.2.0",
"@azure/arm-servicebus": "^3.2.0",
"@azure/arm-storage": "^15.0.0",
"@azure/ms-rest-js": "^2.0.7",
"azure-storage": "^2.10.3",
"extract-zip": "^1.6.6",
"fs-extra": "^4.0.2",
"ms-rest": "^2.5.3",
"ms-rest-azure": "^2.3.1",
"opn": "^6.0.0",
"portfinder": "^1.0.23",
"p-retry": "^4.1.0",
"ps-tree": "^1.1.1",
"request-promise": "^4.2.4",
"semver": "^5.7.1",
"vscode-azureappservice": "^0.64.0",
"vscode-azureextensionui": "^0.33.8",
"vscode-azurekudu": "^0.1.8",
"vscode-azureappservice": "^0.65.0",
"vscode-azureextensionui": "^0.34.0",
"vscode-azurekudu": "^0.2.0",
"vscode-nls": "^4.1.1",
"websocket": "^1.0.29",
"xml2js": "^0.4.19",
Expand Down
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 { CosmosDBManagementClient, CosmosDBManagementModels } from 'azure-arm-cosmosdb';
import { CosmosDBManagementClient, CosmosDBManagementModels } from '@azure/arm-cosmosdb';
import { createAzureClient } from 'vscode-azureextensionui';
import { getResourceGroupFromId } from '../../../../utils/azure';
import { nonNullProp } from '../../../../utils/nonNull';
Expand All @@ -13,7 +13,7 @@ import { ICosmosDBWizardContext } from './ICosmosDBWizardContext';

export class CosmosDBConnectionCreateStep extends AzureConnectionCreateStepBase<IBindingWizardContext & ICosmosDBWizardContext> {
public async getConnection(context: ICosmosDBWizardContext): Promise<IConnection> {
const databaseAccount: CosmosDBManagementModels.DatabaseAccount = nonNullProp(context, 'databaseAccount');
const databaseAccount: CosmosDBManagementModels.DatabaseAccountGetResults = nonNullProp(context, 'databaseAccount');
const name: string = nonNullProp(databaseAccount, 'name');

const client: CosmosDBManagementClient = createAzureClient(context, CosmosDBManagementClient);
Expand Down
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 { CosmosDBManagementClient } from 'azure-arm-cosmosdb';
import { CosmosDBManagementClient } from '@azure/arm-cosmosdb';
import { AzureWizardPromptStep, createAzureClient } from 'vscode-azureextensionui';
import { localize } from '../../../../localize';
import { promptForResource } from '../../../../utils/azure';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { CosmosDBManagementModels } from 'azure-arm-cosmosdb';
import { CosmosDBManagementModels } from '@azure/arm-cosmosdb';
import { ISubscriptionWizardContext } from 'vscode-azureextensionui';

export interface ICosmosDBWizardContext extends ISubscriptionWizardContext {
databaseAccount?: CosmosDBManagementModels.DatabaseAccount;
databaseAccount?: CosmosDBManagementModels.DatabaseAccountGetResults;
}
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 { EventHubManagementClient, EventHubManagementModels } from 'azure-arm-eventhub';
import { EventHubManagementClient, EventHubManagementModels } from '@azure/arm-eventhub';
import { AzureWizardPromptStep, createAzureClient } from 'vscode-azureextensionui';
import { localize } from '../../../../localize';
import { IBaseResourceWithName, promptForResource } from '../../../../utils/azure';
Expand Down
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 { EventHubManagementClient, EventHubManagementModels } from 'azure-arm-eventhub';
import { EventHubManagementClient, EventHubManagementModels } from '@azure/arm-eventhub';
import { createAzureClient } from 'vscode-azureextensionui';
import { nonNullProp } from '../../../../utils/nonNull';
import { IBindingWizardContext } from '../../IBindingWizardContext';
Expand Down
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 { EventHubManagementClient, EventHubManagementModels } from 'azure-arm-eventhub';
import { EventHubManagementClient, EventHubManagementModels } from '@azure/arm-eventhub';
import { AzureWizardPromptStep, createAzureClient } from 'vscode-azureextensionui';
import { localize } from '../../../../localize';
import { promptForResource } from '../../../../utils/azure';
Expand Down
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 { EventHubManagementClient, EventHubManagementModels } from 'azure-arm-eventhub';
import { EventHubManagementClient, EventHubManagementModels } from '@azure/arm-eventhub';
import { AzureWizardPromptStep, createAzureClient } from 'vscode-azureextensionui';
import { localize } from '../../../../localize';
import { getResourceGroupFromId, promptForResource } from '../../../../utils/azure';
Expand Down
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 { ServiceBusManagementModels } from 'azure-arm-sb';
import { ServiceBusManagementModels } from '@azure/arm-servicebus';
import { ISubscriptionWizardContext } from 'vscode-azureextensionui';

export interface IServiceBusWizardContext extends ISubscriptionWizardContext {
Expand Down
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 { ServiceBusManagementClient, ServiceBusManagementModels } from 'azure-arm-sb';
import { ServiceBusManagementClient, ServiceBusManagementModels } from '@azure/arm-servicebus';
import { createAzureClient } from 'vscode-azureextensionui';
import { localize } from '../../../../localize';
import { getResourceGroupFromId } from '../../../../utils/azure';
Expand Down
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 { ServiceBusManagementClient } from 'azure-arm-sb';
import { ServiceBusManagementClient } from '@azure/arm-servicebus';
import { AzureWizardPromptStep, createAzureClient } from 'vscode-azureextensionui';
import { localize } from '../../../../localize';
import { promptForResource } from '../../../../utils/azure';
Expand Down
2 changes: 1 addition & 1 deletion src/commands/appSettings/downloadAppSettings.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 { WebSiteManagementModels } from "azure-arm-website";
import { WebSiteManagementModels } from "@azure/arm-appservice";
import * as fse from 'fs-extra';
import * as vscode from 'vscode';
import { AppSettingsTreeItem, IAppSettingsClient } from "vscode-azureappservice";
Expand Down
2 changes: 1 addition & 1 deletion src/commands/appSettings/uploadAppSettings.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 { WebSiteManagementModels } from "azure-arm-website";
import { WebSiteManagementModels } from "@azure/arm-appservice";
import * as fse from 'fs-extra';
import * as vscode from 'vscode';
import { AppSettingsTreeItem, IAppSettingsClient } from "vscode-azureappservice";
Expand Down
2 changes: 1 addition & 1 deletion src/commands/createFunctionApp/FunctionAppCreateStep.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 { WebSiteManagementClient, WebSiteManagementModels as SiteModels } from 'azure-arm-website';
import { WebSiteManagementClient, WebSiteManagementModels as SiteModels } from '@azure/arm-appservice';
import { Progress } from 'vscode';
import { SiteClient, WebsiteOS } from 'vscode-azureappservice';
import { AzureWizardExecuteStep, createAzureClient, parseError } from 'vscode-azureextensionui';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { HttpOperationResponse } from '@azure/ms-rest-js';
import * as fse from 'fs-extra';
import * as path from 'path';
import { Progress } from 'vscode';
import * as xml2js from 'xml2js';
import { localize } from '../../../localize';
import { confirmOverwriteFile } from "../../../utils/fs";
import { requestUtils } from '../../../utils/requestUtils';
Expand Down Expand Up @@ -97,43 +97,24 @@ export class PowerShellProjectCreateStep extends ScriptProjectCreateStep {
});

try {
const xmlResult: string = await this.getPSGalleryAzModuleInfo();
const versionResult: string = await this.parseLatestAzModuleVersion(xmlResult);
const response: HttpOperationResponse = await requestUtils.sendRequestWithTimeout({ method: 'GET', url: this.azModuleGalleryUrl });
const versionResult: string = await this.parseLatestAzModuleVersion(response);
const [major]: string[] = versionResult.split('.');
return parseInt(major);
} catch {
return undefined;
}
}

private async getPSGalleryAzModuleInfo(): Promise<string> {
const request: requestUtils.Request = await requestUtils.getDefaultRequestWithTimeout(this.azModuleGalleryUrl, undefined, 'GET');
return await requestUtils.sendRequest(request);
}

private async parseLatestAzModuleVersion(azModuleInfo: string): Promise<string> {
const moduleInfo: string = await new Promise((
resolve: (ret: string) => void,
// tslint:disable-next-line:no-any
rejects: (reason: any) => void): void => {
// tslint:disable-next-line:no-any
xml2js.parseString(azModuleInfo, { explicitArray: false }, (err: any, result: string): void => {
if (err) {
rejects(err);
} else {
resolve(result);
}
});
});

// tslint:disable-next-line:no-string-literal no-unsafe-any
if (moduleInfo['feed'] && moduleInfo['feed']['entry'] && Array.isArray(moduleInfo['feed']['entry'])) {
// tslint:disable-next-line:no-string-literal no-unsafe-any
const releasedVersions: string[] = moduleInfo['feed']['entry']
// tslint:disable-next-line:no-string-literal no-unsafe-any
.filter(entry => entry['m:properties']['d:IsPrerelease']['_'] === 'false')
// tslint:disable-next-line:no-string-literal no-unsafe-any
private async parseLatestAzModuleVersion(response: HttpOperationResponse): Promise<string> {
// tslint:disable-next-line: no-any
const moduleInfo: any = response.parsedBody;
// tslint:disable: no-unsafe-any
if (moduleInfo?.entry && Array.isArray(moduleInfo.entry)) {
const releasedVersions: string[] = moduleInfo.entry
.filter(entry => entry['m:properties']['d:IsPrerelease']._ === 'false')
.map(entry => entry['m:properties']['d:Version']);
// tslint:enable: no-unsafe-any

// Select the latest version
if (releasedVersions.length > 0) {
Expand All @@ -143,6 +124,6 @@ export class PowerShellProjectCreateStep extends ScriptProjectCreateStep {
}

// If no version is found, throw exception
throw new Error(`Failed to parse latest Az module version ${azModuleInfo}`);
throw new Error(`Failed to parse latest Az module version ${response.bodyAsText}`);
}
}
2 changes: 1 addition & 1 deletion src/commands/deploy/deploy.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 { WebSiteManagementModels } from 'azure-arm-website';
import { WebSiteManagementModels } from '@azure/arm-appservice';
import * as vscode from 'vscode';
import { deploy as innerDeploy, getDeployFsPath, getDeployNode, IDeployContext, IDeployPaths, showDeployConfirmation } from 'vscode-azureappservice';
import { IActionContext } from 'vscode-azureextensionui';
Expand Down
2 changes: 1 addition & 1 deletion src/commands/deploy/verifyAppSettings.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 { WebSiteManagementModels } from 'azure-arm-website';
import { WebSiteManagementModels } from '@azure/arm-appservice';
import * as vscode from 'vscode';
import { SiteClient } from 'vscode-azureappservice';
import { DialogResponses, IActionContext } from 'vscode-azureextensionui';
Expand Down
17 changes: 5 additions & 12 deletions src/commands/executeFunction.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 { HttpMethods } from 'ms-rest';
import { window } from 'vscode';
import { SiteClient } from 'vscode-azureappservice';
import { IActionContext, parseError } from 'vscode-azureextensionui';
Expand Down Expand Up @@ -48,30 +47,24 @@ export async function executeFunction(context: IActionContext, node?: FunctionTr
}

let url: string;
let method: HttpMethods;
let body: {};
if (node.config.isHttpTrigger) {
url = nonNullProp(node, 'triggerUrl');
method = 'GET';
body = functionInput;
} else {
// https://docs.microsoft.com/azure/azure-functions/functions-manually-run-non-http
url = `${node.parent.parent.hostUrl}/admin/functions/${node.name}`;
method = 'POST';
body = { input: functionInput };
}

let response: string | undefined;
let responseText: string | null | undefined;
await node.runWithTemporaryDescription(localize('executing', 'Executing...'), async () => {
const request: requestUtils.Request = await requestUtils.getDefaultRequestWithTimeout(url, undefined, method);
const headers: { [name: string]: string | undefined } = {};
if (client) {
request.headers['x-functions-key'] = (await client.listHostKeys()).masterKey;
headers['x-functions-key'] = (await client.listHostKeys()).masterKey;
}
request.headers['Content-Type'] = 'application/json';
request.body = body;
request.json = true;
try {
response = await requestUtils.sendRequest(request);
responseText = (await requestUtils.sendRequestWithTimeout({ method: 'POST', url, headers, body })).bodyAsText;
} catch (error) {
if (!client && parseError(error).errorType === 'ECONNREFUSED') {
context.errorHandling.suppressReportIssue = true;
Expand All @@ -82,6 +75,6 @@ export async function executeFunction(context: IActionContext, node?: FunctionTr
}
});

const message: string = response ? localize('executedWithResponse', 'Executed function "{0}". Response: "{1}"', node.name, response) : localize('executed', 'Executed function "{0}"', node.name);
const message: string = responseText ? localize('executedWithResponse', 'Executed function "{0}". Response: "{1}"', node.name, responseText) : localize('executed', 'Executed function "{0}"', node.name);
window.showInformationMessage(message);
}
2 changes: 1 addition & 1 deletion src/commands/logstream/enableFileLogging.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 { WebSiteManagementModels } from 'azure-arm-website';
import { WebSiteManagementModels } from '@azure/arm-appservice';
import { SiteClient } from 'vscode-azureappservice';

export async function enableFileLogging(client: SiteClient, logsConfig?: WebSiteManagementModels.SiteLogsConfig): Promise<void> {
Expand Down
Loading

0 comments on commit 061713b

Please sign in to comment.