{"id":1704,"date":"2023-02-28T07:59:01","date_gmt":"2023-02-28T15:59:01","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/azure-sql\/?p=1704"},"modified":"2023-03-01T10:38:43","modified_gmt":"2023-03-01T18:38:43","slug":"getting-started-with-azure-sql-bindings-part-1","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/azure-sql\/getting-started-with-azure-sql-bindings-part-1\/","title":{"rendered":"Getting Started with Azure SQL Bindings: Part 1"},"content":{"rendered":"<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/download.png\"><img decoding=\"async\" class=\"wp-image-1774 alignright\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/download.png\" alt=\"Image download\" width=\"244\" height=\"128\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/download.png 600w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/download-300x158.png 300w\" sizes=\"(max-width: 244px) 100vw, 244px\" \/><\/a>Expanding on the excellent post by <a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/author\/drskwier\/\">Drew Skwiers-Koballa;<\/a>\u00a0<a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/developing-with-azure-sql-bindings-and-azure-sql-trigger-for-azure-functions\/\">Developing with Azure SQL bindings and Azure SQL trigger for Azure Functions<\/a>, I&#8217;d like to take a chance to walk you through creating your first SQL Binding using a completely local development environment. Part 1 will cover creating a SQL Binding to get data from an Azure SQL Database. Parts 2 and 3 will then cover inserts, updates, and deletes as well as calling stored procedures.<\/p>\n<p>&nbsp;<\/p>\n<h2><\/h2>\n<h2>Prerequisites and Setup<\/h2>\n<p>Our local development environment will be using VS Code and Docker. If you don&#8217;t have either installed, you can get VS Code <a href=\"https:\/\/code.visualstudio.com\/Download\">here<\/a> and Docker Desktop <a href=\"https:\/\/www.docker.com\/products\/docker-desktop\/\">here<\/a>. You can also run through this post with either Windows or macOS. VS Code and Docker are available for both platforms so install both before proceeding.<\/p>\n<p>The Azure Functions Core Tools are needed so that we can run Azure functions right on your computer, no cloud needed until you are ready to deploy. You can get the installer <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/azure-functions\/functions-run-local?tabs=v4%2Cwindows%2Ccsharp%2Cportal%2Cbash#install-the-azure-functions-core-tools\">here<\/a>.<\/p>\n<p>.NET is also needed for our local development environment. This post will be using version 7 which can be downloaded <a href=\"https:\/\/dotnet.microsoft.com\/en-us\/download\/dotnet\/7.0\">here<\/a> or is probably already installed if you have Visual Studio already installed. You can check the version by issuing a dotnet &#8211;version at a terminal prompt on your OS.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/dotnet_ver.png\"><img decoding=\"async\" class=\"alignnone wp-image-1707 size-full\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/dotnet_ver.png\" alt=\"Image dotnet ver\" width=\"403\" height=\"64\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/dotnet_ver.png 403w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/dotnet_ver-300x48.png 300w\" sizes=\"(max-width: 403px) 100vw, 403px\" \/><\/a><\/p>\n<p>While at the command prompt, run the following command to update SQL Projects with some new cool features:<\/p>\n<pre class=\"lia-code-sample line-numbers language-bash\"><code class=\"language-bash\">dotnet new -i Microsoft.Build.Sql.Templates<\/code><\/pre>\n<p>Then <strong>create a directory<\/strong> called bindings101 for the project in the terminal window (<strong>mkdir bindings101<\/strong>). Once it&#8217;s created, <strong>enter<\/strong> the directory.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/createBindingsDir.png\"><img decoding=\"async\" class=\"alignnone wp-image-1708 size-full\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/createBindingsDir.png\" alt=\"Image createBindingsDir\" width=\"564\" height=\"209\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/createBindingsDir.png 564w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/createBindingsDir-300x111.png 300w\" sizes=\"(max-width: 564px) 100vw, 564px\" \/><\/a><\/p>\n<p>In the newly created directory, issue the following commands:<\/p>\n<pre class=\"lia-code-sample line-numbers language-bash\"><code class=\"language-bash\">dotnet new sqlproj -n <span class=\"token string\">\"bindingsProject\"<\/span> -tp <span class=\"token string\">\"SqlAzureV12\"<\/span><\/code><\/pre>\n<pre class=\"lia-code-sample line-numbers language-bash\"><code class=\"language-bash\">code .<\/code><\/pre>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/createBindingsProject.png\"><img decoding=\"async\" class=\"alignnone wp-image-1709 size-full\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/createBindingsProject.png\" alt=\"Image createBindingsProject\" width=\"955\" height=\"111\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/createBindingsProject.png 955w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/createBindingsProject-300x35.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/createBindingsProject-768x89.png 768w\" sizes=\"(max-width: 955px) 100vw, 955px\" \/><\/a><\/p>\n<p>Using <strong>code .<\/strong> in a directory instantly opens VS Code and pointing at the directory we were just in. There is also a database project ready to be used there.<\/p>\n<h2>Install VS Code Extensions<\/h2>\n<p>Before we start building the binding, there are some extensions that are needed. The first one is the <strong>MS SQL Extension<\/strong>. Using the VS Code extensions panel, search for ms sql. Click the install &#8230;<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/Screenshot-2023-02-27-064441.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1744\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/Screenshot-2023-02-27-064441.png\" alt=\"Image Screenshot 2023 02 27 064441\" width=\"971\" height=\"229\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/Screenshot-2023-02-27-064441.png 971w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/Screenshot-2023-02-27-064441-300x71.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/Screenshot-2023-02-27-064441-768x181.png 768w\" sizes=\"(max-width: 971px) 100vw, 971px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>The next extension is the <strong>C# extension<\/strong>. Again, using the search, enter c# and install this extension.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/Screenshot-2023-02-27-064453.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1745\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/Screenshot-2023-02-27-064453.png\" alt=\"Image Screenshot 2023 02 27 064453\" width=\"942\" height=\"247\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/Screenshot-2023-02-27-064453.png 942w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/Screenshot-2023-02-27-064453-300x79.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/Screenshot-2023-02-27-064453-768x201.png 768w\" sizes=\"(max-width: 942px) 100vw, 942px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Finally, search for the <strong>Azure Functions extension<\/strong> and install it.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/functionsExt.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1729\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/functionsExt.png\" alt=\"Image functionsExt\" width=\"904\" height=\"216\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/functionsExt.png 904w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/functionsExt-300x72.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/functionsExt-768x184.png 768w\" sizes=\"(max-width: 904px) 100vw, 904px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h2>Using Azure Functions Core Tools<\/h2>\n<p>With VS Code open, open a <strong>New Terminal<\/strong> using the Terminal Dropdown menu.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/openTerminalVSCode.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1712\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/openTerminalVSCode.png\" alt=\"Image openTerminalVSCode\" width=\"746\" height=\"376\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/openTerminalVSCode.png 746w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/openTerminalVSCode-300x151.png 300w\" sizes=\"(max-width: 746px) 100vw, 746px\" \/><\/a><\/p>\n<p>Our first SQl Binding is going to use .NET as the language. To initialize the project for a .NET binding, enter the following command in the VS Code terminal:<\/p>\n<pre>func init --worker-runtime dotnet<\/pre>\n<p>Looking at the file navigator, the func process added the necessary files to use Azure functions locally right here within VS Code!<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/funcinit.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1713\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/funcinit.png\" alt=\"Image funcinit\" width=\"839\" height=\"472\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/funcinit.png 839w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/funcinit-300x169.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/funcinit-768x432.png 768w\" sizes=\"(max-width: 839px) 100vw, 839px\" \/><\/a><\/p>\n<p>Using the terminal in VS Code again, we are going to add the extension needed for SQL Bindings. Run the following command:<\/p>\n<pre>dotnet add package Microsoft.Azure.WebJobs.Extensions.Sql --prerelease<\/pre>\n<h2>Create a Database and Table<\/h2>\n<p>On the left side of VS Code, click the <strong>Database Projects icon<\/strong>.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/DBProjects.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1715\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/DBProjects.png\" alt=\"Image DBProjects\" width=\"301\" height=\"370\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/DBProjects.png 301w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/DBProjects-244x300.png 244w\" sizes=\"(max-width: 301px) 100vw, 301px\" \/><\/a><\/p>\n<p>You can see the project that was created when you previously issued the command &#8220;new sqlproj&#8221;, ready to be used, here in Database Projects,<\/p>\n<p>Right click on <strong>bindingsProject<\/strong> and select <strong>Add Table<\/strong>.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/addTable.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1739\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/addTable.png\" alt=\"Image addTable\" width=\"443\" height=\"304\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/addTable.png 443w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/addTable-300x206.png 300w\" sizes=\"(max-width: 443px) 100vw, 443px\" \/><\/a><\/p>\n<p>Name the table <strong>customers<\/strong> and then press <strong>enter<\/strong>.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/tableName.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1717\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/tableName.png\" alt=\"Image tableName\" width=\"606\" height=\"78\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/tableName.png 606w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/tableName-300x39.png 300w\" sizes=\"(max-width: 606px) 100vw, 606px\" \/><\/a><\/p>\n<p>Replace the code in the <strong>customers.sql<\/strong> file with the following:<\/p>\n<div>\n<pre>CREATE TABLE [dbo].[customers]\r\n(\r\n  [Id] INT NOT NULL PRIMARY KEY,\r\n  [Name] NVARCHAR(200) NOT NULL,\r\n  [Address] NVARCHAR(300) NOT NULL,\r\n  [State] NVARCHAR(20) NOT NULL,\r\n  [Phone] NVARCHAR(20) NOT NULL\r\n)\r\n\r\n<\/pre>\n<div>Then save the file.<\/div>\n<div><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/customersTable.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1718\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/customersTable.png\" alt=\"Image customersTable\" width=\"611\" height=\"228\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/customersTable.png 611w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/customersTable-300x112.png 300w\" sizes=\"(max-width: 611px) 100vw, 611px\" \/><\/a><\/div>\n<div><\/div>\n<div>Right click on the <strong>bindingsProject<\/strong> and select <strong>Publish<\/strong>.<\/div>\n<div><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/PublishProject1.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1727\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/PublishProject1.png\" alt=\"Image PublishProject1\" width=\"613\" height=\"197\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/PublishProject1.png 613w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/PublishProject1-300x96.png 300w\" sizes=\"(max-width: 613px) 100vw, 613px\" \/><\/a><\/div>\n<div><\/div>\n<div>This will start the process of creating a MS SQL instance in a Docker container and deploying the table into that database for the local development environment. Ensure Docker Desktop is up and running before proceeding to the next section. A series of dialog boxes appear on the top of VS Code app to create the local database instance.<\/div>\n<div><\/div>\n<div>\n<div>\n<div>Select<strong> Publish to a new Azure Database emulator<\/strong> for the Select where to publish the project to dialog window:<\/div>\n<div>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/deploy2.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1501\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/deploy2.png\" alt=\"Image deploy2\" width=\"604\" height=\"133\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/deploy2.png 604w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/deploy2-300x66.png 300w\" sizes=\"(max-width: 604px) 100vw, 604px\" \/><\/a><\/p>\n<\/div>\n<\/div>\n<div>Use the default port number 1433 for the SQL Server port and press enter.<\/div>\n<div>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/deploy3.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1502\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/deploy3.png\" alt=\"Image deploy3\" width=\"604\" height=\"86\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/deploy3.png 604w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/deploy3-300x43.png 300w\" sizes=\"(max-width: 604px) 100vw, 604px\" \/><\/a><\/p>\n<\/div>\n<div><\/div>\n<div>Enter a password you want to use for the admin user (sa user) in this dialog box. Ensure the password is a complex password that includes letters, numbers, and special characters.<\/div>\n<div>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/deploy4.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1503\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/deploy4.png\" alt=\"Image deploy4\" width=\"604\" height=\"85\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/deploy4.png 604w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/deploy4-300x42.png 300w\" sizes=\"(max-width: 604px) 100vw, 604px\" \/><\/a><\/p>\n<\/div>\n<div><\/div>\n<div>Enter the same password again.<\/div>\n<div>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/deploy5.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1504\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/deploy5.png\" alt=\"Image deploy5\" width=\"604\" height=\"95\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/deploy5.png 604w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/deploy5-300x47.png 300w\" sizes=\"(max-width: 604px) 100vw, 604px\" \/><\/a><\/p>\n<\/div>\n<div><\/div>\n<div>The wizard is then going to ask you about what docker image to pull. If you are on windows on an x86\/x64 based CPU, select the <strong>Full<\/strong> <strong>image<\/strong>. If you are on windows on ARM or an Apple Silicon Mac, select the Lite image.<\/div>\n<div>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/deploy6.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1505\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/deploy6.png\" alt=\"Image deploy6\" width=\"601\" height=\"109\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/deploy6.png 601w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/deploy6-300x54.png 300w\" sizes=\"(max-width: 601px) 100vw, 601px\" \/><\/a><\/p>\n<\/div>\n<div><\/div>\n<div>Now, <strong>accept<\/strong> the license agreement.<\/div>\n<div>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/deploy7.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1506\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/deploy7.png\" alt=\"Image deploy7\" width=\"596\" height=\"109\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/deploy7.png 596w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/deploy7-300x55.png 300w\" sizes=\"(max-width: 596px) 100vw, 596px\" \/><\/a><\/p>\n<\/div>\n<div><\/div>\n<div>And select the<strong> latest Default<\/strong> as the image tag<\/div>\n<div>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/dbImages.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1722\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/dbImages.png\" alt=\"Image dbImages\" width=\"612\" height=\"329\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/dbImages.png 612w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/dbImages-300x161.png 300w\" sizes=\"(max-width: 612px) 100vw, 612px\" \/><\/a><\/p>\n<\/div>\n<div><\/div>\n<div>Select <strong>Don&#8217;t use profile<\/strong> for the publish profile dialog box<\/div>\n<div>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/deploy9.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1508\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/deploy9.png\" alt=\"Image deploy9\" width=\"596\" height=\"107\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/deploy9.png 596w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/deploy9-300x54.png 300w\" sizes=\"(max-width: 596px) 100vw, 596px\" \/><\/a><\/p>\n<\/div>\n<div><\/div>\n<div>And finally, select <strong>bindingsProject<\/strong> as the database name we will create.<\/div>\n<div>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/bindingsDB.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1723\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/bindingsDB.png\" alt=\"Image bindingsDB\" width=\"611\" height=\"121\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/bindingsDB.png 611w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/bindingsDB-300x59.png 300w\" sizes=\"(max-width: 611px) 100vw, 611px\" \/><\/a><\/p>\n<\/div>\n<div>When the database has started, and the project has been published,<\/div>\n<\/div>\n<\/div>\n<div><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/publishProject.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1724\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/publishProject.png\" alt=\"Image publishProject\" width=\"782\" height=\"248\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/publishProject.png 782w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/publishProject-300x95.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/publishProject-768x244.png 768w\" sizes=\"(max-width: 782px) 100vw, 782px\" \/><\/a><\/div>\n<div><\/div>\n<div>VS Code will also create a connection to the database. Open the <strong>Tables folder<\/strong> to see the customers table.<\/div>\n<div>\n<div><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/dbConnection1.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1725\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/dbConnection1.png\" alt=\"Image dbConnection1\" width=\"256\" height=\"311\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/dbConnection1.png 256w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/dbConnection1-247x300.png 247w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/a><\/div>\n<\/div>\n<div>\n<div><\/div>\n<\/div>\n<h2>Create an Input Binding<\/h2>\n<p><strong>Press &#8216;F1&#8217;<\/strong> in VS Code and search for <strong>Azure Functions: Create Function<\/strong>\u00a0and select it.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/azureCreateFunc.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1730\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/azureCreateFunc.png\" alt=\"Image azureCreateFunc\" width=\"607\" height=\"121\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/azureCreateFunc.png 607w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/azureCreateFunc-300x60.png 300w\" sizes=\"(max-width: 607px) 100vw, 607px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Choose <strong>HttpTrigger<\/strong><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/httpTrigger1.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1747\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/httpTrigger1.png\" alt=\"Image httpTrigger1\" width=\"600\" height=\"114\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/httpTrigger1.png 600w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/httpTrigger1-300x57.png 300w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Provide a function <strong>name.<\/strong> Use<strong> getCustomer<\/strong><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/httpTrigger2.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1748\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/httpTrigger2.png\" alt=\"Image httpTrigger2\" width=\"607\" height=\"101\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/httpTrigger2.png 607w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/httpTrigger2-300x50.png 300w\" sizes=\"(max-width: 607px) 100vw, 607px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Enter a <strong>namespace<\/strong>. Use <strong>Customer.Function<\/strong><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/httpTrigger3.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1749\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/httpTrigger3.png\" alt=\"Image httpTrigger3\" width=\"605\" height=\"103\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/httpTrigger3.png 605w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/httpTrigger3-300x51.png 300w\" sizes=\"(max-width: 605px) 100vw, 605px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Finally for <strong>Access Rights<\/strong>, use <strong>Anonymous<\/strong>.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/httpTrigger4.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1750\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/httpTrigger4.png\" alt=\"Image httpTrigger4\" width=\"598\" height=\"140\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/httpTrigger4.png 598w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/httpTrigger4-300x70.png 300w\" sizes=\"(max-width: 598px) 100vw, 598px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>In the file that opens in VS Code (named <strong>getCustomers.cs<\/strong>), replace the <strong>public static async Task&lt;IActionResult&gt; Run<\/strong> block<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/runBlock11.png\"><img decoding=\"async\" class=\"alignnone wp-image-1757\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/runBlock11.png\" alt=\"Image runBlock11\" width=\"684\" height=\"443\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/runBlock11.png 1052w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/runBlock11-300x194.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/runBlock11-1024x664.png 1024w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/runBlock11-768x498.png 768w\" sizes=\"(max-width: 684px) 100vw, 684px\" \/><\/a><\/p>\n<p>with the below code.<\/p>\n<div>\n<pre>  \u00a0 \u00a0 \u00a0 public static async Task&lt;IActionResult&gt; Run(\r\n  \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 [HttpTrigger(AuthorizationLevel.Anonymous, \"get\", \"post\", Route = \"customer\")] HttpRequest req,\r\n  \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ILogger log,\r\n  \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 [Sql(\"select * from dbo.customers\",\r\n  \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \"SqlConnectionString\")]\r\n  \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 IEnumerable&lt;Customer&gt; customer)\r\n  \u00a0 \u00a0 \u00a0 {\r\n  \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 return new OkObjectResult(customer);\r\n\u00a0 \u00a0 \u00a0 \u00a0 }<\/pre>\n<\/div>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/runBlock22.png\"><img decoding=\"async\" class=\"alignnone wp-image-1758\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/runBlock22.png\" alt=\"Image runBlock22\" width=\"673\" height=\"420\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/runBlock22.png 900w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/runBlock22-300x187.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/runBlock22-768x480.png 768w\" sizes=\"(max-width: 673px) 100vw, 673px\" \/><\/a><\/p>\n<p><strong>Save<\/strong> the file.<\/p>\n<h3>About the SQL Binding Structure<\/h3>\n<p>Providing code without an explanation is never good, so this next section will break down the following code:<\/p>\n<pre> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 [Sql(\"select * from dbo.customers\",\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \"SqlConnectionString\")]<\/pre>\n<p>There are four parts to the Input Binding as represented in the table (from the <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/azure-functions\/functions-bindings-azure-sql-input?tabs=in-process&amp;pivots=programming-language-csharp\">documentation<\/a>):<\/p>\n<table class=\"table table-sm\" style=\"width: 95.119%;height: 238px\" aria-label=\"Table 1\">\n<thead>\n<tr>\n<th style=\"width: 20.4469%\">Attribute property<\/th>\n<th style=\"width: 127.486%\">Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"width: 20.4469%\"><strong>CommandText<\/strong><\/td>\n<td style=\"width: 127.486%\">Required. The Transact-SQL query command or name of the stored procedure executed by the binding.<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 20.4469%\"><strong>CommandType<\/strong><\/td>\n<td style=\"width: 127.486%\">Required. A\u00a0<a href=\"https:\/\/learn.microsoft.com\/en-us\/dotnet\/api\/system.data.commandtype\" data-linktype=\"absolute-path\">CommandType<\/a>\u00a0value, which is\u00a0<a href=\"https:\/\/learn.microsoft.com\/en-us\/dotnet\/api\/system.data.commandtype#fields\" data-linktype=\"absolute-path\">Text<\/a>\u00a0for a query and\u00a0<a href=\"https:\/\/learn.microsoft.com\/en-us\/dotnet\/api\/system.data.commandtype#fields\" data-linktype=\"absolute-path\">StoredProcedure<\/a>\u00a0for a stored procedure.<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 20.4469%\"><strong>Parameters<\/strong><\/td>\n<td style=\"width: 127.486%\">Optional. Zero or more parameter values passed to the command during execution as a single string. Must follow the format\u00a0<code>@param1=param1,@param2=param2<\/code>. Neither the parameter name nor the parameter value can contain a comma (<code>,<\/code>) or an equals sign (<code>=<\/code>).<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 20.4469%\"><strong>ConnectionStringSetting<\/strong><\/td>\n<td style=\"width: 127.486%\">Required. The name of an app setting that contains the connection string for the database against which the query or stored procedure is being executed. This value isn&#8217;t the actual connection string and must instead resolve to an environment variable name.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>And to expand it further:<\/p>\n<div>\n<pre style=\"padding-left: 80px\">[Sql(CommandText,\r\n  \u00a0 CommandType,\r\n  \u00a0 Parameters,\r\n\u00a0 \u00a0 ConnectionStringSetting\r\n\r\n)]<\/pre>\n<\/div>\n<p>Looking at the code in the <strong>getCustomers.cs file<\/strong><\/p>\n<pre> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 [Sql(\"select * from dbo.customers\",\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \"SqlConnectionString\")]<\/pre>\n<p>CommandText is the SQL query, CommandType defaults to CommandType.Text and not present in the call. There are no Parameters to pass in this example so it is not needed. And the last parameter, as indicated in the table is the connect string to the database. This will be entered later in this post and point to the local SQL Database we published the Database Project to. In parts 2 and 3, when Output and Trigger bindings used, more of these parameters will be passed to the binding.<\/p>\n<h3>Add a Class<\/h3>\n<p>While editing the <strong>getCustomers.cs<\/strong> file, add &#8216;<strong>using System.Collections.Generic;<\/strong>&#8216; to the namespaces list at the <strong>top<\/strong> of the page.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/addSystem.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1761\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/addSystem.png\" alt=\"Image addSystem\" width=\"492\" height=\"285\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/addSystem.png 492w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/addSystem-300x174.png 300w\" sizes=\"(max-width: 492px) 100vw, 492px\" \/><\/a><\/p>\n<p><strong>Save<\/strong> the file.<\/p>\n<p>Right click in the<strong> File Navigator<\/strong> under the project files and select<strong> New File<\/strong>.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/newFile.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1760\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/newFile.png\" alt=\"Image newFile\" width=\"309\" height=\"402\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/newFile.png 309w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/newFile-231x300.png 231w\" sizes=\"(max-width: 309px) 100vw, 309px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Then, <strong>name<\/strong> the new file <strong>Customer.cs<\/strong><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/nameFile.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1759\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/nameFile.png\" alt=\"Image nameFile\" width=\"259\" height=\"261\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/nameFile.png 259w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/nameFile-150x150.png 150w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/nameFile-24x24.png 24w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/nameFile-48x48.png 48w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/nameFile-96x96.png 96w\" sizes=\"(max-width: 259px) 100vw, 259px\" \/><\/a><\/p>\n<p>Paste the code below into the file. These are the column names of our database table.<\/p>\n<p><strong>Note that the casing of the Object field names and the table column names must match.<\/strong><\/p>\n<p><span style=\"color: #292b2c;font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;font-size: 14.4px\">namespace Customer.Function<\/span><\/p>\n<div>\n<pre>  \u00a0 { public class Customer {\r\n  \u00a0 \u00a0 \u00a0 public int Id { get; set; }\r\n  \u00a0 \u00a0 \u00a0 public string Name { get; set; }\r\n  \u00a0 \u00a0 \u00a0 public string Address { get; set; }\r\n  \u00a0 \u00a0 \u00a0 public string State { get; set; }\r\n  \u00a0 \u00a0 \u00a0 public string Phone { get; set; }\r\n  \u00a0 \u00a0 \u00a0 }\r\n  \u00a0 }<\/pre>\n<\/div>\n<p><strong>Save<\/strong> the file.<\/p>\n<p>Using the File Navigator, <strong>click<\/strong> on the<strong> local.settings.json<\/strong> file.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/localSettings.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1763\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/localSettings.png\" alt=\"Image localSettings\" width=\"251\" height=\"289\" \/><\/a><\/p>\n<p>Add the following line in the top of the <strong>Values<\/strong> section and <strong>replace<\/strong> yourstrongpassword with the password you used when you created the database.<\/p>\n<pre>\"SqlConnectionString\": \"Server=localhost,1433;Database=bindingsProject;User ID=sa;Password=yourstrongpassword;Encrypt=True;TrustServerCertificate=True;Connection Timeout=30;\",<\/pre>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/connectString.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1764\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/connectString.png\" alt=\"Image connectString\" width=\"1490\" height=\"215\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/connectString.png 1490w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/connectString-300x43.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/connectString-1024x148.png 1024w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/connectString-768x111.png 768w\" sizes=\"(max-width: 1490px) 100vw, 1490px\" \/><\/a><\/p>\n<p>While still in the local.settings.json file, set <strong>AzureWebJobsStorage<\/strong> to <strong>UseDevelopmentStorage=false<\/strong><\/p>\n<div>\n<pre>\"AzureWebJobsStorage\": \"UseDevelopmentStorage=false\",<\/pre>\n<div><strong style=\"font-size: 1rem\">Save<\/strong><span style=\"font-size: 1rem\"> the file.<\/span><\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<h2>Try the Function<\/h2>\n<p>Navigate back to the <strong>getCustomers.cs<\/strong> file and press<span style=\"font-size: 1rem\"> &#8216;<strong>F5<\/strong>&#8216; to run your code. This will start up the Functions Host with a local HTTP Trigger and SQL Input Binding. In the output section on the bottom of VS Code, a URL will be show similar to<\/span><\/p>\n<pre><span style=\"font-size: 1rem\">getCustomers: [GET,POST] http:\/\/localhost:7071\/api\/customer\r\n<a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/urlOutput.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1765\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/urlOutput.png\" alt=\"Image urlOutput\" width=\"753\" height=\"128\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/urlOutput.png 753w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/urlOutput-300x51.png 300w\" sizes=\"(max-width: 753px) 100vw, 753px\" \/><\/a>\r\n\r\n<\/span><\/pre>\n<p><strong>Control Click<\/strong> or <strong>copy and paste the URL<\/strong> into a browser. The result in the browser should be an <strong>empty array<\/strong> because there is no data in the table.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/browser1.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1766\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/browser1.png\" alt=\"Image browser1\" width=\"440\" height=\"153\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/browser1.png 440w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/browser1-300x104.png 300w\" sizes=\"(max-width: 440px) 100vw, 440px\" \/><\/a><\/p>\n<p>We can add data to the table by clicking the <strong>SQL Server icon<\/strong> on the <strong>left side of VS Code<\/strong><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/sqlTab1.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1768\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/sqlTab1.png\" alt=\"Image sqlTab1\" width=\"303\" height=\"483\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/sqlTab1.png 303w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/sqlTab1-188x300.png 188w\" sizes=\"(max-width: 303px) 100vw, 303px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>then<strong> right clicking the server name<\/strong> and selecting <strong>New Query<\/strong><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/newQuery.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1769\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/newQuery.png\" alt=\"Image newQuery\" width=\"519\" height=\"233\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/newQuery.png 519w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/newQuery-300x135.png 300w\" sizes=\"(max-width: 519px) 100vw, 519px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Copy and paste the following SQL into the query sheet<\/p>\n<div>\n<pre>insert into dbo.customers values (1, N'Ben', N'123 West Street', N'Any State', N'(555)-555-0000');\r\n\r\n<\/pre>\n<div><span style=\"font-size: 1rem\">Click the <strong>run<\/strong> button to insert the row into the table<\/span><\/div>\n<\/div>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/insertStatement1.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1770\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/insertStatement1.png\" alt=\"Image insertStatement1\" width=\"982\" height=\"83\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/insertStatement1.png 982w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/insertStatement1-300x25.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/insertStatement1-768x65.png 768w\" sizes=\"(max-width: 982px) 100vw, 982px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>and <strong>refresh<\/strong> the browser. The row is now seen in JSON format from the SQL Binding function in your browser.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/browser2.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1771\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/browser2.png\" alt=\"Image browser2\" width=\"711\" height=\"135\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/browser2.png 711w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/02\/browser2-300x57.png 300w\" sizes=\"(max-width: 711px) 100vw, 711px\" \/><\/a><\/p>\n<p><strong>Congratulations!<\/strong> You have successfully created your first SQL input binding!<\/p>\n<h2>Part 2 and 3<\/h2>\n<p>In the next parts, Output and Trigger SQL Bindings will be covered with samples and a walkthrough for each.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Expanding on the excellent post by Drew Skwiers-Koballa;\u00a0Developing with Azure SQL bindings and Azure SQL trigger for Azure Functions, I&#8217;d like to take a chance to walk you through creating your first SQL Binding using a completely local development environment. Part 1 will cover creating a SQL Binding to get data from an Azure SQL [&hellip;]<\/p>\n","protected":false},"author":95874,"featured_media":1774,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[555,1,556,533],"tags":[244,510,541,557,558],"class_list":["post-1704","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure-functions","category-azure-sql","category-sql-bindings","category-visual-studio-code","tag-net","tag-azure-sql-database","tag-azure-functions","tag-sql-bindings","tag-vs-code"],"acf":[],"blog_post_summary":"<p>Expanding on the excellent post by Drew Skwiers-Koballa;\u00a0Developing with Azure SQL bindings and Azure SQL trigger for Azure Functions, I&#8217;d like to take a chance to walk you through creating your first SQL Binding using a completely local development environment. Part 1 will cover creating a SQL Binding to get data from an Azure SQL [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/posts\/1704","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/users\/95874"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/comments?post=1704"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/posts\/1704\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/media\/1774"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/media?parent=1704"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/categories?post=1704"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/tags?post=1704"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}