Skip to content

Commit 89652b6

Browse files
authored
Merge pull request #23939 from VasuBhog/vabhog/sqlBindings
Azure Functions with SQL Bindings Docs
2 parents db3c416 + 32033c6 commit 89652b6

28 files changed

Lines changed: 349 additions & 1 deletion

docs/toc.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9999,6 +9999,14 @@ items:
99999999
href: tools/visual-studio-code/mssql-query-history.md
1000010000
- name: SQL Database Projects
1000110001
href: azure-data-studio/extensions/sql-database-project-extension.md
10002+
- name: SQL Bindings for Azure Functions
10003+
items:
10004+
- name: Overview
10005+
href: tools/visual-studio-code/create-azure-function-with-mssql.md
10006+
- name: From Object Explorer Tutorial
10007+
href: tools/visual-studio-code/create-azure-function-with-mssql-object-explorer.md
10008+
- name: From Command Palette Tutorial
10009+
href: tools/visual-studio-code/create-azure-function-with-mssql-command-palette.md
1000210010
- name: Tutorials
1000310011
items:
1000410012
- name: SQL Server
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
---
2+
title: Create Azure Functions with the SQL bindings extension through command palette for Visual Studio Code
3+
description: Use the Visual Studio Code command palette to create Azure functions with SQL bindings.
4+
ms.topic: conceptual
5+
ms.prod: sql
6+
ms.technology: tools-other
7+
author: VasuBhog
8+
ms.author: vabhog
9+
ms.reviewer: drskwier
10+
ms.date: 8/24/2022
11+
---
12+
13+
# Create Azure Functions with the SQL bindings extension through the Object Explorer for Visual Studio Code
14+
15+
[!INCLUDE [SQL Server ASDB, ASDBMI, ASDW ](../../includes/applies-to-version/sql-asdb-asdbmi-asa.md)]
16+
17+
## Overview
18+
Microsoft SQL Bindings for VS Code enable users to develop Azure Functions with Azure SQL bindings, see further documentation [here](create-azure-function-with-mssql.md). [Install the VS Code extension here](https://marketplace.visualstudio.com/items?itemName=ms-mssql.sql-bindings-vscode).
19+
20+
## From the Command Palette
21+
Run the `MS SQL: Create Azure Function with SQL Binding` command from the command palette to create a new function with a SQL binding.
22+
23+
:::image type="content" alt-text="Screenshot of a VS Code command palette command `MS SQL: Create Azure Function with SQL Binding (preview)." source="./media/create-azure-function-with-mssql/create-azure-function-using-command-palette.png":::
24+
25+
The extension will then prompt you to select the object type to insert (`Input binding`) or upsert into (`Output binding`), either a `Table` or `View`.
26+
27+
:::image type="content" alt-text="Screenshot of a prompt to select the object type." source="./media/create-azure-function-with-mssql/select-object-type.png":::
28+
29+
Then the extension will prompt you to select a connection profile to use for the Azure Function or create a connection profile.
30+
31+
:::image type="content" alt-text="Screenshot of a prompt for connection profile." source="./media/create-azure-function-with-mssql/prompt-for-connection-profile.png":::
32+
33+
Once you either select a connection profile or create a new connection profile, the extension will prompt you to select the database from the selected connection to use for the Azure Function.
34+
35+
:::image type="content" alt-text="Screenshot of a prompt for database" source="./media/create-azure-function-with-mssql/select-database.png":::
36+
37+
Once you select a database, the extension will prompt you to select a table, or view to use or to enter a table or view to query or upsert into. This prompt is based on the object type you selected earlier.
38+
39+
> [!NOTE]
40+
> Azure Function with SQL Binding from a `View` is only supported for `Input` bindings.
41+
42+
Prompt for Table:
43+
:::image type="content" alt-text="Screenshot of a prompt for table." source="./media/create-azure-function-with-mssql/select-table.png":::
44+
45+
Prompt for View:
46+
:::image type="content" alt-text="Screenshot of a prompt for view." source="./media/create-azure-function-with-mssql/select-view.png":::
47+
48+
The extension will then prompt you to enter the function name to be used for the Azure Function.
49+
50+
:::image type="content" alt-text="Screenshot of a prompt to enter function name." source="./media/create-azure-function-with-mssql/function-name-prompt.png":::
51+
52+
If you already have connection strings stored in the local.settings.json, then the extension will prompt you to select the connection string to use for the Azure Function or create a new connection string.
53+
54+
:::image type="content" alt-text="Screenshot of a prompt to select connection string setting." source="./media/create-azure-function-with-mssql/create-new-sql-connection-string-setting.png":::
55+
56+
If you select `Create new local app setting`, then the extension will prompt you to enter the connection string name and value.
57+
58+
:::image type="content" alt-text="Screenshot of a prompt to enter connection string." source="./media/create-azure-function-with-mssql/enter-connection-string-setting-name.png":::
59+
60+
If you're creating the `Azure Function with SQL Binding` to an existing Azure Function project, then the extension will prompt you whether you would like to include the password for the connection string in the local.settings.json file.
61+
62+
:::image type="content" alt-text="Screenshot of a prompt to save the password to the SQL connection string." source="./media/create-azure-function-with-mssql/password-prompt.png":::
63+
64+
If `Yes`, then the password will be saved to the local.settings.json file. If `No` then the extension will warn you that the password won't be saved to the local.settings.json file (shown below), and you'll need to manually add the password later to the local.settings.json file.
65+
66+
:::image type="content" alt-text="Screenshot of a warning to add password to SQL connection string later manually." source="./media/create-azure-function-with-mssql/do-not-save-password.png":::
67+
68+
The extension will then prompt you to provide the namespace for the Azure Function.
69+
:::image type="content" alt-text="Screenshot of a prompt for namespace for the Azure Function." source="./media/create-azure-function-with-mssql/namespace-for-function.png":::
70+
71+
If you're creating a brand new Azure Function project with SQL binding, then the extension will prompt whether you would like to include the password for the connection string in the local.settings.json file.
72+
73+
A progress notification will appear to indicate that the Azure Function has completed.
74+
75+
:::image type="content" alt-text="Screenshot of a information message indicating finished creating Azure Function Project." source="./media/create-azure-function-with-mssql/finished-creating-project.png":::
76+
77+
Once the Azure Function is created, the extension will generate the code either for an `Input` or `Output` binding shown [here](create-azure-function-with-mssql.md#generated-code-for-azure-functions-with-sql-bindings).
78+
79+
80+
81+
#### In an existing Azure Function
82+
Open the C# Azure Function in an editor and then run the `MS SQL: Add SQL Binding` command from the command palette to add a SQL binding to an existing function.
83+
84+
:::image type="content" alt-text="Screenshot of a VS Code command palette command `MS SQL: Add SQL Binding (preview)." source="./media/create-azure-function-with-mssql/add-sql-binding-command-palette.png":::
85+
86+
The extension will then prompt you to select Azure function in the current file to add the SQL binding to.
87+
:::image type="content" alt-text="Screenshot of Azure Functions found in project." source="./media/create-azure-function-with-mssql/select-azure-functions-in-file.png":::
88+
89+
If you're creating an Azure Function with SQL binding from a table, the extension will prompt you to select the binding type to use, either an `Input` (Retrieves data from a database) or `Output` (Save data to a database) binding.
90+
91+
If you already have connection strings stored in the local.settings.json, then the extension will prompt you to select the connection string to use for the Azure Function or create a new connection string.
92+
93+
:::image type="content" alt-text="Screenshot of a prompt to select or create a new connection string setting." source="./media/create-azure-function-with-mssql/create-new-sql-connection-string-setting.png":::
94+
95+
If you select `Create new local app setting`, then the extension will prompt you to enter the connection string name and value.
96+
97+
:::image type="content" alt-text="Screenshot of a prompt to enter connection string." source="./media/create-azure-function-with-mssql/enter-connection-string-setting-name.png":::
98+
99+
The extension will then prompt you to select a connection string method to select a connection profile or enter a connection string to use for the SQL binding.
100+
101+
:::image type="content" alt-text="Screenshot of a prompt to select connection string setting method." source="./media/create-azure-function-with-mssql/select-connection-string-method.png":::
102+
103+
If you decide to select a connection profile, the extension will prompt you to select the database from the selected connection to use for the Azure Function.
104+
105+
:::image type="content" alt-text="Screenshot of a prompt for database." source="./media/create-azure-function-with-mssql/select-database.png":::
106+
107+
Once you select a database, the extension will prompt you to select a table to use, or to enter a table or view to query or upsert into.
108+
109+
Prompt for Table:
110+
:::image type="content" alt-text="Screenshot of a prompt for table." source="./media/create-azure-function-with-mssql/select-table.png":::
111+
112+
The extension will then prompt you whether you would like to include the password for the connection string in the local.settings.json file.
113+
114+
:::image type="content" alt-text="Screenshot of a prompt to save the password to the SQL connection string." source="./media/create-azure-function-with-mssql/password-prompt.png":::
115+
116+
If `Yes`, then the password will be saved to the local.settings.json file. If `No` then the extension will warn you that the password won't be saved to the local.settings.json file (shown below), and you'll need to manually add the password later to the local.settings.json file.
117+
118+
:::image type="content" alt-text="Screenshot of a warning to add password to SQL connection string later manually." source="./media/create-azure-function-with-mssql/do-not-save-password.png":::
119+
120+
Once the Azure Function is created, the extension will generate the code either for an `Input` or `Output` binding shown [here](create-azure-function-with-mssql.md#generated-code-for-azure-functions-with-sql-bindings).
121+
122+
## Next steps
123+
124+
- [Create Azure Function with SQL binding overview](create-azure-function-with-mssql.md).
125+
- [Learn more about SQL bindings for Azure Functions](https://aka.ms/sqlbindings).
126+
- [Create Azure Function with SQL binding through the object explorer tutorial](create-azure-function-with-mssql-object-explorer.md).
127+
- [Use the mssql extension to query a SQL instance](mssql-extensions.md).
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
title: Create Azure Functions with the SQL bindings extension through the Object Explorer for Visual Studio Code
3+
description: Use the mssql object explorer to create Azure functions with SQL bindings in Visual Studio Code.
4+
ms.topic: conceptual
5+
ms.prod: sql
6+
ms.technology: tools-other
7+
author: VasuBhog
8+
ms.author: vabhog
9+
ms.reviewer: drskwier
10+
ms.date: 8/24/2022
11+
---
12+
13+
# Create Azure Functions with the SQL bindings extension through the Object Explorer
14+
15+
[!INCLUDE [SQL Server ASDB, ASDBMI, ASDW ](../../includes/applies-to-version/sql-asdb-asdbmi-asa.md)]
16+
17+
## Overview
18+
Microsoft SQL Bindings for VS Code enable users to develop Azure Functions with Azure SQL bindings, see further documentation [here](create-azure-function-with-mssql.md). [Install the VS Code extension here](https://marketplace.visualstudio.com/items?itemName=ms-mssql.sql-bindings-vscode).
19+
20+
## From the Object Explorer
21+
To create an Azure Function from a specific `Table` or `View` in object explorer (OE), right-click on a table or view from a connected server in SQL Server object explorer and select `Create Azure Function with SQL Binding.`
22+
23+
**Table OE Command**:
24+
:::image type="content" alt-text="Screenshot of object explorer context menu to add a SQL binding from Table." source="./media/create-azure-function-with-mssql/create-function-table-object-explorer.png":::
25+
26+
**View OE Command**:
27+
:::image type="content" alt-text="Screenshot of object explorer context menu to add a SQL binding from View." source="./media/create-azure-function-with-mssql/create-function-view-object-explorer.png":::
28+
29+
If you haven't yet created the Azure Function project, a VS Code prompt will appear to aid in creating a new Azure Function project.
30+
31+
:::image type="content" alt-text="Screenshot of VS Code notification to create a new Azure Function project since none were found in folder." source="./media/create-azure-function-with-mssql/create-azure-function-project.png":::
32+
33+
The extension will then ask you to select the folder where you want to create the Azure Function.
34+
35+
:::image type="content" alt-text="Screenshot of a prompt to choose folder to create Azure Function with SQL binding to." source="./media/create-azure-function-with-mssql/select-folder-to-use-for-function.png":::
36+
37+
If you're creating an Azure Function with SQL binding from a table, the extension will prompt you to select the binding type to use, either an `Input` (Retrieves data from a database) or `Output` (Save data to a database) binding.
38+
39+
> [!NOTE]
40+
> Azure Function with SQL Binding from a `View` is only supported for `Input` bindings.
41+
42+
:::image type="content" alt-text="Screenshot of a prompt to select binding type." source="./media/create-azure-function-with-mssql/binding-type-prompt.png":::
43+
44+
The extension will then prompt you to enter the function name to be used for the Azure Function.
45+
46+
:::image type="content" alt-text="Screenshot of a prompt to enter function name." source="./media/create-azure-function-with-mssql/function-name-prompt.png":::
47+
48+
If you already have connection strings stored in the local.settings.json, then the extension will prompt you to select the connection string to use for the Azure Function or create a new connection string.
49+
50+
:::image type="content" alt-text="Screenshot of a prompt to select connection string setting." source="./media/create-azure-function-with-mssql/create-new-sql-connection-string-setting.png":::
51+
52+
If you select `Create new local app setting`, then the extension will prompt you to enter the connection string name and value.
53+
54+
:::image type="content" alt-text="Screenshot of a pPrompt to enter connection string." source="./media/create-azure-function-with-mssql/enter-connection-string-setting-name.png":::
55+
56+
If you're creating the `Azure Function with SQL Binding` to an existing Azure Function project, then the extension will prompt you whether you would like to include the password for the connection string in the local.settings.json file.
57+
58+
:::image type="content" alt-text="Screenshot of a prompt to save the password to the SQL connection string." source="./media/create-azure-function-with-mssql/password-prompt.png":::
59+
60+
If `Yes`, then the password will be saved to the local.settings.json file. If `No` then the extension will warn you that the password won't be saved to the local.settings.json file (shown below), and you'll need to manually add the password later to the local.settings.json file.
61+
62+
:::image type="content" alt-text="Screenshot of a warning to add password to SQL connection string later manually." source="./media/create-azure-function-with-mssql/do-not-save-password.png":::
63+
64+
The extension will then prompt you to provide the namespace for the Azure Function.
65+
66+
:::image type="content" alt-text="Screenshot of a prompt for namespace for the Azure Function." source="./media/create-azure-function-with-mssql/namespace-for-function.png":::
67+
68+
If you're creating a brand new Azure Function project with SQL binding, then the extension will prompt whether you would like to include the password for the connection string in the local.settings.json file.
69+
70+
A progress notification will appear to indicate that the Azure Function has completed.
71+
72+
:::image type="content" alt-text="Screenshot of a information message indicating finished creating Azure Function Project." source="./media/create-azure-function-with-mssql/finished-creating-project.png":::
73+
74+
Once the Azure Function is created, the extension will generate the code either for an `Input` or `Output` binding shown [here](create-azure-function-with-mssql.md#generated-code-for-azure-functions-with-sql-bindings).
75+
76+
## Next steps
77+
78+
- [Create Azure Function with SQL binding overview](create-azure-function-with-mssql.md).
79+
- [Learn more about SQL bindings for Azure Functions](https://aka.ms/sqlbindings).
80+
- [Create Azure Function with SQL binding through the command palette tutorial](create-azure-function-with-mssql-command-palette.md).
81+
- [Use the mssql extension to query a SQL instance](mssql-extensions.md).

0 commit comments

Comments
 (0)