mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-11 02:32:35 -05:00
Add Connection String Execute Step for SQL Bindings (#19293)
* add execute step * nit comment * edit param docs * address comments * ensure the user has the installs the latest version
This commit is contained in:
@@ -13,6 +13,7 @@ import * as azureFunctionsContracts from '../contracts/azureFunctions/azureFunct
|
||||
import { CreateAzureFunctionStep, TelemetryActions, TelemetryReporter, TelemetryViews, ExitReason } from '../common/telemetry';
|
||||
import { AddSqlBindingParams, BindingType, GetAzureFunctionsParams, GetAzureFunctionsResult, ResultStatus } from 'sql-bindings';
|
||||
import { IConnectionInfo, ITreeNodeInfo } from 'vscode-mssql';
|
||||
import { createAddConnectionStringStep } from '../createNewProject/addConnectionStringStep';
|
||||
|
||||
export const hostFileName: string = 'host.json';
|
||||
|
||||
@@ -223,6 +224,8 @@ export async function createAzureFunction(node?: ITreeNodeInfo): Promise<void> {
|
||||
.withAdditionalProperties(propertyBag)
|
||||
.withConnectionInfo(connectionInfo).send();
|
||||
}
|
||||
// addtional execution step that will be used by vscode-azurefunctions to execute only when creating a new azure function project
|
||||
let connectionStringExecuteStep = createAddConnectionStringStep(projectFolder, connectionInfo, connectionStringSettingName);
|
||||
|
||||
// create C# Azure Function with SQL Binding
|
||||
telemetryStep = 'createFunctionAPI';
|
||||
@@ -238,7 +241,8 @@ export async function createAzureFunction(node?: ITreeNodeInfo): Promise<void> {
|
||||
...(selectedBindingType === BindingType.output && { table: objectName })
|
||||
},
|
||||
folderPath: projectFolder,
|
||||
suppressCreateProjectPrompt: true
|
||||
suppressCreateProjectPrompt: true,
|
||||
...(isCreateNewProject && { executeStep: connectionStringExecuteStep })
|
||||
});
|
||||
TelemetryReporter.createActionEvent(TelemetryViews.CreateAzureFunctionWithSqlBinding, telemetryStep)
|
||||
.withAdditionalProperties(propertyBag)
|
||||
@@ -246,22 +250,9 @@ export async function createAzureFunction(node?: ITreeNodeInfo): Promise<void> {
|
||||
|
||||
// check for the new function file to be created and dispose of the file system watcher
|
||||
const timeoutForFunctionFile = utils.timeoutPromise(constants.timeoutAzureFunctionFileError);
|
||||
let functionFilePath = await Promise.race([newFunctionFileObject.filePromise, timeoutForFunctionFile]);
|
||||
|
||||
// prompt user for include password for connection string
|
||||
if (isCreateNewProject && functionFilePath) {
|
||||
telemetryStep = CreateAzureFunctionStep.promptForIncludePassword;
|
||||
let settingsFile = await azureFunctionsUtils.getSettingsFile(projectFolder);
|
||||
if (!settingsFile) {
|
||||
return;
|
||||
}
|
||||
let connectionString = await azureFunctionsUtils.promptConnectionStringPasswordAndUpdateConnectionString(connectionInfo, settingsFile);
|
||||
if (!connectionString) {
|
||||
return;
|
||||
}
|
||||
void azureFunctionsUtils.addConnectionStringToConfig(connectionString, projectFolder, connectionStringSettingName);
|
||||
}
|
||||
await Promise.race([newFunctionFileObject.filePromise, timeoutForFunctionFile]);
|
||||
|
||||
telemetryStep = 'finishCreateFunction';
|
||||
propertyBag.telemetryStep = telemetryStep;
|
||||
exitReason = ExitReason.finishCreate;
|
||||
TelemetryReporter.createActionEvent(TelemetryViews.CreateAzureFunctionWithSqlBinding, TelemetryActions.finishCreateAzureFunctionWithSqlBinding)
|
||||
|
||||
Reference in New Issue
Block a user