Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Create Azure Function with SQL Binding more efficient and simple #19187

Merged
merged 16 commits into from
Apr 26, 2022

Conversation

VasuBhog
Copy link
Contributor

@VasuBhog VasuBhog commented Apr 22, 2022

This PR simplifies our process to Create Azure Function with SQL Binding.

Three Scenarios were covered:

  1. User has an azure function project in a folder (multiple or single)
  2. User has an empty workspace (no folder open) or User has no workspace/folder open

Flow is found here

Issues fixed:

General Flow of Logic:

  • Find Azure Function Project
  • Prompt For Binding Type
  • Based on entry point (command palette vs command via table) show prompts
  • Prompt for Azure Function Name
  • Prompt For Connection String Setting Name and Password for Connection String (Scenario 1 - adds connection string to local.settings.json)
  • Create Function API call (ask for namespace)
  • Prompt to Include Password for connection string and adds to local.settings.json

@coveralls
Copy link

coveralls commented Apr 22, 2022

Pull Request Test Coverage Report for Build 2228888338

  • 33 of 148 (22.3%) changed or added relevant lines in 5 files are covered.
  • 6 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.02%) to 42.253%

Changes Missing Coverage Covered Lines Changed/Added Lines %
extensions/sql-bindings/src/common/utils.ts 1 3 33.33%
extensions/sql-bindings/src/common/azureFunctionsUtils.ts 7 14 50.0%
extensions/sql-bindings/src/services/azureFunctionsService.ts 1 107 0.93%
Files with Coverage Reduction New Missed Lines %
extensions/sql-bindings/src/services/azureFunctionsService.ts 6 6.38%
Totals Coverage Status
Change from base Build 2223116021: 0.02%
Covered Lines: 27811
Relevant Lines: 61585

💛 - Coveralls

@VasuBhog
Copy link
Contributor Author

Follow up PR will cover this issue #19203

// Ask binding type for promptObjectName
quickPickStep = 'getBindingType';
let selectedBinding = await azureFunctionsUtils.promptForBindingType();
telemetryStep = CreateAzureFunctionStep.getConnectionString;
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need telemetryStep? It seems that you are reassigning it's value without sending it as telemetry

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So currently I have this so that if an error occurs at any point or if the user cancels a certain step within the flow then in the finally block we would send where they left off from.

// prompt user for include password for connection string
if (isCreateNewProject) {
if (isCreateNewProject && functionFilePath) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to make sure the azure function project is created prior to adding the connection string to the local.settings.json for the folder the user selected (and added to the workspace).

Copy link
Contributor

@Charles-Gagnon Charles-Gagnon left a comment

Choose a reason for hiding this comment

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

I didn't spend a ton of time going through all the logic - way too many changes to be able to fully review this. Make sure you're spending lots of time testing this yourself and setting up bug bashes as needed.

@@ -575,3 +575,21 @@ export async function promptConnectionStringPasswordAndUpdateConnectionString(co
return undefined;
}
}

export async function getDatabase(connectionInfo: IConnectionInfo): Promise<string | undefined> {
Copy link
Contributor

Choose a reason for hiding this comment

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

promptSelectDatabase - it's not clear what "get" means in this case

try {
const azureFunctionApi = await azureFunctionsUtils.getAzureFunctionsExtensionApi();
if (!azureFunctionApi) {
propertyBag.exitReason = exitReason;
Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably be "error" at this point

if (projectCreate === constants.learnMore) {
telemetryStep = CreateAzureFunctionStep.learnMore;
void vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(constants.sqlBindingsDoc));
TelemetryReporter.createActionEvent(TelemetryViews.CreateAzureFunctionWithSqlBinding, telemetryStep)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need to send this event? Couldn't you just use the exit event and check for step == learnMore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's right. We could also use the final block to see if it exited with the step learnMore.

@VasuBhog VasuBhog merged commit c860853 into main Apr 26, 2022
@VasuBhog VasuBhog deleted the vabhog/creatFunctionRefactor branch April 26, 2022 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants