Skip to content

Commit 37a56b0

Browse files
One more README change from dev (#54)
* More README changes * remove en-us
1 parent fd2445b commit 37a56b0

File tree

1 file changed

+42
-46
lines changed

1 file changed

+42
-46
lines changed

README.md

Lines changed: 42 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
# SQL Extension for Azure Functions - Preview #
1+
# SQL Extension for Azure Functions - Preview
22

33
[![Build Status](https://mssqltools.visualstudio.com/CrossPlatBuildScripts/_apis/build/status/SQL%20Bindings/SQL%20Bindings%20-%20Nightly?branchName=dev)](https://mssqltools.visualstudio.com/CrossPlatBuildScripts/_build/latest?definitionId=481&branchName=dev)
44

5-
## Introduction ##
5+
## Introduction
66

77
This repository contains extension code for the SQL trigger and bindings as well as a quick start, tutorial, and samples of how to use them. A high level explanation of the trigger and bindings is provided below. Additional information for each is in their respective sample sections.
88

99
- **input binding**: takes a SQL query to run on a provided table and returns the output of the query.
1010
- **output binding**: takes a list of rows and upserts them into the user table (i.e. If a row doesn't already exist, it is added. If it does, it is updated).
1111
- **trigger**: requires the user to specify the name of a table, and in the event a change occurs (i.e. the row is updated, deleted, or inserted), the trigger will return the updated rows and values along with any associated metadata.
1212

13-
## Table of Contents ##
13+
## Table of Contents
1414

1515
- [SQL Extension for Azure Functions - Preview](#sql-extension-for-azure-functions---preview)
1616
- [Introduction](#introduction)
@@ -39,9 +39,9 @@ This repository contains extension code for the SQL trigger and bindings as well
3939
- [Trigger Samples](#trigger-samples)
4040
- [Contributing](#contributing)
4141

42-
## Quick Start ##
42+
## Quick Start
4343

44-
### SQL Setup ###
44+
### SQL Setup
4545

4646
This requires already having a SQL database. If you need to create a SQL database, please refer to [Create Azure SQL Database](#Create-Azure-SQL-Database) in the tutorials section.
4747

@@ -59,25 +59,25 @@ A primary key must be set in your SQL table before using the bindings. To do thi
5959
ALTER TABLE ['your table name'] ADD CONSTRAINT PKey PRIMARY KEY CLUSTERED (['column to be primary key']);
6060
```
6161

62-
2. SQL's [change tracking functionality](https://docs.microsoft.com/sql/relational-databases/track-changes/about-change-tracking-sql-server?view=sql-server-ver15) must be enabled on the database to use the trigger. Please note that change tracking has additional costs. If you do not plan on using the trigger, you can skip this step. To enable change tracking on the database, run:
62+
1. SQL's [change tracking functionality](https://docs.microsoft.com/sql/relational-databases/track-changes/about-change-tracking-sql-server?view=sql-server-ver15) must be enabled on the database to use the trigger. Please note that change tracking has additional costs. If you do not plan on using the trigger, you can skip this step. To enable change tracking on the database, run:
6363
6464
```sql
6565
ALTER DATABASE ['your database name']
6666
SET CHANGE_TRACKING = ON
6767
(CHANGE_RETENTION = 2 DAYS, AUTO_CLEANUP = ON)
6868
```
6969
70-
3. Change tracking must be enabled on the table to use the trigger. If you do not plan on using the trigger, you can skip this step. To enable change tracking on the table, run:
70+
1. Change tracking must be enabled on the table to use the trigger. If you do not plan on using the trigger, you can skip this step. To enable change tracking on the table, run:
7171
7272
```sql
7373
ALTER TABLE ['your table name']
7474
ENABLE CHANGE_TRACKING
7575
WITH (TRACK_COLUMNS_UPDATED = ON)
7676
```
7777
78-
4. Congrats on setting up your database! Now continue to set up your local environment and complete the quick start. For more information on what change tracking does for the bindings, go to the [Trigger](#Trigger) section.
78+
1. Congrats on setting up your database! Now continue to set up your local environment and complete the quick start. For more information on what change tracking does for the bindings, go to the [Trigger](#Trigger) section.
7979
80-
### Set Up Local .NET Function App ###
80+
### Set Up Local .NET Function App
8181
8282
These steps can be done in the CLI, Powershell. Completing this section will allow you to begin using the bindings.
8383
@@ -101,21 +101,21 @@ These steps can be done in the CLI, Powershell. Completing this section will all
101101
dotnet add package Microsoft.Azure.WebJobs.Extensions.Sql --version 1.0.0-preview3
102102
```
103103
104-
2. Ensure you have Azure Storage Emulator running. For information on the Azure Storage Emulator, refer [here](https://docs.microsoft.com/azure/storage/common/storage-use-emulator#get-the-storage-emulator)
104+
1. Ensure you have Azure Storage Emulator running. For information on the Azure Storage Emulator, refer [here](https://docs.microsoft.com/azure/storage/common/storage-use-emulator#get-the-storage-emulator)
105105
106-
3. Get your SqlConnectionString. Your connection string can be found in your SQL database resource by going to the left blade and clicking 'Connection strings'. Copy the Connection String.
106+
1. Get your SqlConnectionString. Your connection string can be found in your SQL database resource by going to the left blade and clicking 'Connection strings'. Copy the Connection String.
107107
108108
(*Note: when pasting in the connection string, you will need to replace part of the connection string where it says '{your_password}' with your Azure SQL Server password*)
109109
110-
4. In 'local.settings.json' in 'Values', verify you have the below. If not, add the below and replace "Your Connection String" with the your connection string from the previous step:
110+
1. In 'local.settings.json' in 'Values', verify you have the below. If not, add the below and replace "Your Connection String" with the your connection string from the previous step:
111111
112112
```json
113113
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
114114
"AzureWebJobsDashboard": "UseDevelopmentStorage=true",
115115
"SqlConnectionString": "<Your Connection String>"
116116
```
117117
118-
5. Verify your host.json looks like the below:
118+
1. Verify your host.json looks like the below:
119119
120120
```json
121121
{
@@ -131,11 +131,11 @@ These steps can be done in the CLI, Powershell. Completing this section will all
131131
}
132132
```
133133
134-
6. You have setup your local environment and are now ready to create your first SQL bindings! Continue to the [input](#Input-Binding-Tutorial), [output](#Output-Binding-Tutorial), and [trigger](#Trigger-Tutorial) binding tutorials, or refer to [More Samples](#More-Samples) for information on how to use the bindings and explore on your own.
134+
1. You have setup your local environment and are now ready to create your first SQL bindings! Continue to the [input](#Input-Binding-Tutorial), [output](#Output-Binding-Tutorial), and [trigger](#Trigger-Tutorial) binding tutorials, or refer to [More Samples](#More-Samples) for information on how to use the bindings and explore on your own.
135135
136-
## Tutorials ##
136+
## Tutorials
137137
138-
### Create Azure SQL Database ###
138+
### Create Azure SQL Database
139139
140140
We will create a simple Azure SQL Database. For additional reference on Azure SQL Databases, go [here](https://docs.microsoft.com/azure/azure-sql/database/single-database-create-quickstart?tabs=azure-portal).
141141
@@ -173,7 +173,7 @@ We will create a simple Azure SQL Database. For additional reference on Azure SQ
173173
174174
- Congratulations! You have successfully created an Azure SQL Database! Make sure you complete [Quick Start](#Quick-Start) before continuing to the rest of the tutorial.
175175
176-
### Input Binding Tutorial ###
176+
### Input Binding Tutorial
177177
178178
Note: This tutorial requires that the Azure SQL database is setup as shown in [Create Azure SQL Database](#Create-Azure-SQL-Database).
179179
@@ -183,19 +183,15 @@ Note: This tutorial requires that the Azure SQL database is setup as shown in [C
183183
- In the file that opens, replace the 'public static async Task< IActionResult > Run' block with the below code.
184184
185185
```csharp
186-
public static class HttpTriggerCSharp1
186+
public static async Task<IActionResult> Run(
187+
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "employees")] HttpRequest req,
188+
ILogger log,
189+
[Sql("select * from Employees",
190+
CommandType = System.Data.CommandType.Text,
191+
ConnectionStringSetting = "SqlConnectionString")]
192+
IEnumerable<Employee> employee)
187193
{
188-
[FunctionName("HttpTriggerCSharp1")]
189-
public static async Task<IActionResult> Run(
190-
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "employees")] HttpRequest req,
191-
ILogger log,
192-
[Sql("select * from Employees",
193-
CommandType = System.Data.CommandType.Text,
194-
ConnectionStringSetting = "SqlConnectionString")]
195-
IEnumerable<Employee> employee)
196-
{
197-
return new OkObjectResult(employee);
198-
}
194+
return new OkObjectResult(employee);
199195
}
200196
```
201197
@@ -225,7 +221,7 @@ Note: This tutorial requires that the Azure SQL database is setup as shown in [C
225221
- You should see your database output in the browser window.
226222
- Congratulations! You have successfully created your first SQL input binding! Checkout [Input Binding](#Input-Binding) for more information on how to use it and explore on your own!
227223

228-
### Output Binding Tutorial ###
224+
### Output Binding Tutorial
229225

230226
Note: This tutorial requires that the Azure SQL database is setup as shown in [Create Azure SQL Database](#Create-Azure-SQL-Database), and that you have the 'Employee.cs' class from the [Input Binding Tutorial](#Input-Binding-Tutorial).
231227

@@ -271,7 +267,7 @@ Note: This tutorial requires that the Azure SQL database is setup as shown in [C
271267
- Hit 'F5' to run your code. Click the link to upsert the output array values in your SQL table. Your upserted values should launch in the browser.
272268
- Congratulations! You have successfully created your first SQL output binding! Checkout [Output Binding](#Output-Binding) for more information on how to use it and explore on your own!
273269

274-
### Trigger Tutorial ###
270+
### Trigger Tutorial
275271

276272
This tutorial requires that the Azure SQL database is setup as shown in [Create Azure SQL Database](#Create-Azure-SQL-Database), and that you have the 'Employee.cs' class from the [Input Binding Tutorial](#Input-Binding-Tutorial).
277273

@@ -314,9 +310,9 @@ This tutorial requires that the Azure SQL database is setup as shown in [Create
314310
- Update, insert, or delete additional rows in your SQL table using the SQL query editor while the function app is running and observe the log updates.
315311
- Congratulations! You have successfully created your first SQL trigger! Checkout [Trigger Samples](#Trigger-Samples) for more information on how to use the trigger and explore on your own!
316312

317-
## More Samples ##
313+
## More Samples
318314

319-
### Input Binding ###
315+
### Input Binding
320316

321317
The input binding takes four arguments
322318

@@ -334,7 +330,7 @@ The following are valid binding types for the result of the query/stored procedu
334330

335331
The repo contains examples of each of these binding types [here](https://github.com/Azure/azure-functions-sql-extension/tree/dev/samples/SqlExtensionSamples/InputBindingSamples). A few examples are also included below.
336332

337-
#### Query String ###
333+
#### Query String
338334

339335
The input binding executes the "select * from Products where Cost = @Cost" query, returning the result as an `IEnumerable<Product>`, where Product is a user-defined POCO. The *Parameters* argument passes the `{cost}` specified in the URL that triggers the function, `getproducts/{cost}`, as the value of the `@Cost` parameter in the query. *CommandType* is set to `System.Data.CommandType.Text`, since the constructor argument of the binding is a raw query.
340336

@@ -373,7 +369,7 @@ public class Product
373369
}
374370
```
375371

376-
#### Empty Parameter Value ####
372+
#### Empty Parameter Value
377373

378374
In this case, the parameter value of the `@Name` parameter is an empty string.
379375

@@ -392,7 +388,7 @@ In this case, the parameter value of the `@Name` parameter is an empty string.
392388
}
393389
```
394390

395-
#### Null Parameter Value ####
391+
#### Null Parameter Value
396392

397393
If the `{name}` specified in the `getproducts-namenull/{name}` URL is "null", the query returns all rows for which the Name column is `NULL`. Otherwise, it returns all rows for which the value of the Name column matches the string passed in `{name}`
398394

@@ -411,7 +407,7 @@ If the `{name}` specified in the `getproducts-namenull/{name}` URL is "null", th
411407
}
412408
```
413409

414-
#### Stored Procedure ####
410+
#### Stored Procedure
415411

416412
`SelectsProductCost` is the name of a procedure stored in the user's database. In this case, *CommandType* is `System.Data.CommandType.StoredProcedure`. The parameter value of the `@Cost` parameter in the procedure is once again the `{cost}` specified in the `getproducts-storedprocedure/{cost}` URL.
417413
@@ -430,7 +426,7 @@ If the `{name}` specified in the `getproducts-namenull/{name}` URL is "null", th
430426
}
431427
```
432428
433-
#### IAsyncEnumerable ####
429+
#### IAsyncEnumerable
434430
435431
Using the `IAsyncEnumerable` binding generally requires that the `Run` function be `async`. It is also important to call `DisposeAsync` at the end of function execution to make sure all resources used by the enumerator are freed.
436432
@@ -455,7 +451,7 @@ public static async Task<IActionResult> Run(
455451
}
456452
```
457453
458-
### Output Binding ###
454+
### Output Binding
459455
460456
The output binding takes a list of rows to be upserted into a user table. If the primary key value of the row already exists in the table, the row is interpreted as an update, meaning that the values of the other columns in the table for that primary key are updated. If the primary key value does not exist in the table, the row is interpreted as an insert. The upserting of the rows is batched by the output binding code.
461457
@@ -472,7 +468,7 @@ The following are valid binding types for the rows to be upserted into the table
472468
473469
The repo contains examples of each of these binding types [here](https://github.com/Azure/azure-functions-sql-extension/tree/dev/samples/SqlExtensionSamples/OutputBindingSamples). A few examples are also included below.
474470
475-
#### ICollector<T>/IAsyncCollector<T> ####
471+
#### ICollector<T>/IAsyncCollector<T>
476472
477473
When using an `ICollector`, it is not necessary to instantiate it. The function can add rows to the `ICollector` directly, and its contents are automatically upserted once the function exits.
478474
@@ -516,7 +512,7 @@ public static async Task<IActionResult> Run(
516512
}
517513
```
518514
519-
#### Array ####
515+
#### Array
520516
521517
This output binding type requires explicit instantiation within the function body. Note also that the `Product[]` array must be prefixed by `out` when attached to the output binding
522518
@@ -545,7 +541,7 @@ public static IActionResult Run(
545541
}
546542
```
547543
548-
#### Single Row ####
544+
#### Single Row
549545
550546
When binding to a single row, it is also necessary to prefix the row with `out`
551547
@@ -566,9 +562,9 @@ public static IActionResult Run(
566562
}
567563
```
568564
569-
### Trigger ###
565+
### Trigger
570566
571-
#### Change Tracking ####
567+
#### Change Tracking
572568
573569
The trigger uses SQL's [change tracking functionality](https://docs.microsoft.com/sql/relational-databases/track-changes/about-change-tracking-sql-server?view=sql-server-ver15) to monitor a user table for changes. As such, it is necessary to enable change tracking on the database and table before using the trigger. This can be done in the query editor in the portal. If you need help navigating to it, visit the [Create Azure SQL Database](#Create-Azure-SQL-Database) section in the README.
574570

@@ -594,7 +590,7 @@ The trigger uses SQL's [change tracking functionality](https://docs.microsoft.co
594590
595591
The trigger needs to have read access to the table being monitored for changes as well as to the change tracking system tables. It also needs write access to an `az_func` schema within the database, where it will create additional worker tables to process the changes. Each user table will thus have an associated change tracking table and worker table. The worker table will contain roughly as many rows as the change tracking table, and will be cleaned up approximately as often as the change table.
596592
597-
#### Trigger Samples ####
593+
#### Trigger Samples
598594
The trigger takes two arguments
599595
600596
- **TableName**: Passed as a constructor argument to the binding. Represents the name of the table to be monitored for changes.
@@ -622,7 +618,7 @@ public static void Run(
622618
}
623619
```
624620
625-
## Contributing ##
621+
## Contributing
626622
627623
This project welcomes contributions and suggestions. Most contributions require you to agree to a
628624
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us

0 commit comments

Comments
 (0)