import { WebSiteManagementClient } from "@azure/arm-appservice" ; import { Environment } from '@azure/ms-rest-azure-env' ; import { TokenCredentialsBase } from "@azure/ms-rest-nodeauth" ; import * as vscode from 'vscode' ; import { createAzureClient } from "vscode-azureextensionui" ; import { IAzureClientInfo } from "../azure/azureClientInfo" ; import { ext } from "../extensionVariables" ; import { localize } from "../localize" ; export namespace azureClientUtil { export function getClient ( credentials , subscriptionId , environment ) { const clientInfo = { credentials : credentials , subscriptionId : subscriptionId , environment : environment } ; return createAzureClient ( clientInfo , WebSiteManagementClient ) ; } export async function selectSubscription ( ) { const azureAccountExtension = vscode . extensions . getExtension ( 'ms-vscode.azure-account' ) ; const azureAccount = azureAccountExtension ! . exports ; await azureAccount . waitForFilters ( ) ; if ( azureAccount . status !== 'LoggedIn' ) { throw new Error ( localize ( "" , "Please Log in at first!" ) ) ; } const subscriptions = azureAccount . filters . map ( filter => { return { id : filter . subscription . subscriptionId , name : filter . subscription . displayName } ; } ) ; const subscriptionId = await ext . ui . showQuickPick ( subscriptions . map ( ( s ) => { const option = s . id . concat ( ' (' , s . name , ')' ) ; return { label : option , subscriptionId : s . id } ; } ) , { canPickMany : false , placeHolder : localize ( "" , "Please choose the Azure subscription" ) } ) ; return subscriptionId . subscriptionId ; } }