import { Progress } from 'vscode' ; import { AzureWizardExecuteStep } from 'vscode-azureextensionui' ; import { setLocalAppSetting } from '../../../funcConfig/local.settings' ; import { localize } from '../../../localize' ; import { IBindingSetting } from '../../../templates/IBindingTemplate' ; import { nonNullProp } from '../../../utils/nonNull' ; import { setBindingSetting } from '../../createFunction/IFunctionWizardContext' ; import { IBindingWizardContext } from '../IBindingWizardContext' ; export interface IConnection { name : string ; connectionString : string ; } export abstract class AzureConnectionCreateStepBase < T extends IBindingWizardContext > extends AzureWizardExecuteStep < T > { public priority : number = 200 ; private readonly _setting : IBindingSetting ; constructor ( setting ) { super ( ) ; this . _setting = setting ; } public abstract getConnection ( context ) ; public async execute ( context , progress ) { progress . report ( { message : localize ( 'retrieving' , 'Retrieving connection string...' ) } ) ; const result = await this . getConnection ( context ) ; let appSettingKey = `${ result . name }_${ nonNullProp ( this . _setting , 'resourceType' ) . toUpperCase ( ) }` ; appSettingKey = appSettingKey . replace ( /[^a-z0-9_\.]/gi , '' ) ; setBindingSetting ( context , this . _setting , appSettingKey ) ; await setLocalAppSetting ( context , context . projectPath , appSettingKey , result . connectionString ) ; } }