Skip to content

Commit e3683ad

Browse files
committed
Trigger Files
1 parent 5eef7e4 commit e3683ad

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

articles/azure-functions/functions-bindings-azure-mysql-trigger.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,25 @@ zone_pivot_groups: programming-languages-set-functions-lang-workers
1818
# Azure Database for MySQL trigger for Functions (Preview)
1919

2020
> [!NOTE]
21-
> While input and output bindings will be supported on all plans, the MySQL Trigger binding will be available only on [dedicated and premium plans](functions-scale.md) during the public preview. Support for Consumption plans in the MySQL Trigger binding will be introduced at general availability.
21+
> While input and output bindings are supported on all plans, the MySQL Trigger binding will be available only on [dedicated and premium plans](functions-scale.md) during the public preview. Support for Consumption plans in the MySQL Trigger binding will be introduced at general availability.
2222
>
2323
2424
The Azure Database for MySQL Trigger bindings monitor the user table for changes (inserts, updates) and invokes the function with updated row data.
2525

26-
Azure MySQL Trigger bindings use "az_func_updated_at" and column's data, to monitor the user table for changes. As such, it is necessary to alter the table structure to allow change tracking on the MySQL table before using the trigger support. The change tracking can be enabled on a table through following query. For example, enable on ‘Products’ table:
26+
Azure MySQL Trigger bindings use "az_func_updated_at" and column's data, to monitor the user table for changes. As such, it's necessary to alter the table structure to allow change tracking on the MySQL table before using the trigger support. The change tracking can be enabled on a table through following query. For example, enable on ‘Products’ table:
2727

2828
```sql
2929
ALTER TABLE Products
3030
ADD az_func_updated_at TIMESTAMP DEFAULT
3131
CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
3232
```
3333

34-
The leases table contains all columns corresponding to the primary key from the user table and three additional columns _az_func_AttemptCount, _az_func_LeaseExpirationTime, _az_func_SyncCompletedTime. So, if any of the primary key columns happen to have the same name, that will result in an error message listing any conflicts. In this case, the listed primary key columns must be renamed for the trigger to work.
34+
The leases table contains all columns corresponding to the primary key from the user table and three more columns _az_func_AttemptCount, _az_func_LeaseExpirationTime, _az_func_SyncCompletedTime. So, if any of the primary key columns happen to have the same name that will result in an error message listing any conflicts. In this case, the listed primary key columns must be renamed for the trigger to work.
3535

3636

3737
## Functionality Overview
3838

39-
When the trigger function starts, it will initiate two separate loops (Change Polling Loop and Lease Renewal Loop) that will run continuously until the function is stopped.
39+
When the trigger function starts, it initiates two separate loops (Change Polling Loop and Lease Renewal Loop) that will run continuously until the function is stopped.
4040

4141
The Azure Database for MySQL trigger binding uses a polling loop to check for changes, triggering the user function when changes are detected. At a high level, the loop looks like this:
4242

@@ -49,11 +49,11 @@ while (true) {
4949
```
5050

5151
Changes are processed in the order that they were made, with the oldest changes being processed first. A couple notes about change processing:
52-
1. If changes to multiple row are made once then the exact order they are sent to the function is based on, the ascending order of “az_func_updated_at” column and primary key columns.
52+
1. If changes to multiple row are made once then the exact order they're sent to the function is based on, the ascending order of “az_func_updated_at” column and primary key columns.
5353
2. Changes are "batched" together for a row. If multiple changes are made to a row between each iteration of the loop, then only the latest change entry exists for that row will be considered.
5454

5555
> [!NOTE]
56-
>Currently, we are not supporting Managed Identity for connections between Functions and Azure Database for MySQL.
56+
>Currently, we aren't supporting Managed Identity for connections between Functions and Azure Database for MySQL.
5757
>
5858
5959

@@ -116,7 +116,7 @@ ON UPDATE CURRENT_TIMESTAMP;
116116

117117
The MySQL trigger binds to a `IReadOnlyList<MySqlChange<T>>`, a list of `MySqlChange` objects each with two properties:
118118
- **Item:** the item that was changed. The type of the item should follow the table schema as seen in the `ToDoItem` class.
119-
- **Operation:** a value from `MySqlChangeOperation` enum. The possible values is `Update` for both insert and update.
119+
- **Operation:** a value from `MySqlChangeOperation` enum. The possible value is `Update` for both insert and update.
120120

121121
The following example shows a [C# function](functions-dotnet-class-library.md) that is invoked when there are changes to the `Product` table:
122122

@@ -313,7 +313,7 @@ CREATE TABLE Products (
313313
```
314314

315315

316-
Change tracking is enabled on the database by adding the below column to the table:
316+
Change tracking is enabled on the database by adding the following column to the table:
317317

318318
```sql
319319
ALTER TABLE <table name>
@@ -324,7 +324,7 @@ ON UPDATE CURRENT_TIMESTAMP;
324324

325325
The MySQL trigger binds to a `MySqlChangeProduct[]`, an array of `MySqlChangeProduct` objects each with two properties:
326326
- **item:** the item that was changed. The type of the item should follow the table schema as seen in the `Product` class.
327-
- **operation:** a value from `MySqlChangeOperation` enum. The possible values is `Update` for both insert and update.
327+
- **operation:** a value from `MySqlChangeOperation` enum. The possible value is `Update` for both insert and update.
328328

329329

330330
The following example shows a Java function that is invoked when there are changes to the `Product` table:
@@ -394,8 +394,8 @@ ON UPDATE CURRENT_TIMESTAMP;
394394
```
395395

396396
The MySQL trigger binds to `Product`, a list of objects each with two properties:
397-
- **item:** the item that was changed. The structure of the item will follow the table schema.
398-
- **operation:** The possible values is `Update` for both insert and update.
397+
- **item:** the item that was changed. The structure of the item follows the table schema.
398+
- **operation:** The possible value is `Update` for both insert and update.
399399

400400

401401
The following example shows a PowerShell function that is invoked when there are changes to the `Product` table.
@@ -463,8 +463,8 @@ ON UPDATE CURRENT_TIMESTAMP;
463463
```
464464

465465
The MySQL trigger binds `Changes`, an array of objects each with two properties:
466-
- **item:** the item that was changed. The structure of the item will follow the table schema.
467-
- **operation:** The possible values is `Update` for both insert and update.
466+
- **item:** the item that was changed. The structure of the item follows the table schema.
467+
- **operation:** The possible value is `Update` for both insert and update.
468468

469469

470470
The following example shows a JavaScript function that is invoked when there are changes to the `Product` table.
@@ -530,13 +530,13 @@ ON UPDATE CURRENT_TIMESTAMP;
530530
```
531531

532532
> [!NOTE]
533-
> Please note that Azure Functions version 1.22.0b4 must be used for Python .
533+
> Please note that Azure Functions version 1.22.0b4 must be used for Python.
534534
>
535535
536536

537537
The MySQL trigger binds to a variable `Product`, a list of objects each with two properties:
538-
- **item:** the item that was changed. The structure of the item will follow the table schema.
539-
- **operation:** The possible values is `Update` for both insert and update.
538+
- **item:** the item that was changed. The structure of the item follows the table schema.
539+
- **operation:** The possible value is `Update` for both insert and update.
540540

541541

542542
The following example shows a Python function that is invoked when there are changes to the `Product` table.
@@ -612,7 +612,7 @@ def main(changes):
612612
|---------|---------|
613613
| **TableName** | Required. The name of the table monitored by the trigger. |
614614
| **ConnectionStringSetting** | Required. The name of an app setting that contains the connection string for the database containing the table monitored for changes. The connection string setting name corresponds to the application setting (in `local.settings.json` for local development) that contains the [connection string](https://dev.mysql.com/doc/connector-net/en/connector-net-connections-string.html) to the Azure Database for MySQL.|
615-
| **LeasesTableName** | Optional. Name of the table used to store leases. If not specified, the leases table name will be Leases_{FunctionId}_{TableId}.
615+
| **LeasesTableName** | Optional. Name of the table used to store leases. If not specified, the leases table name is Leases_{FunctionId}_{TableId}.
616616

617617

618618
::: zone-end
@@ -629,7 +629,7 @@ In the [Java functions runtime library](/java/api/overview/azure/functions/runti
629629
| **name** | Required. The name of the parameter that the trigger binds to. |
630630
| **tableName** | Required. The name of the table monitored by the trigger. |
631631
| **connectionStringSetting** | Required. The name of an app setting that contains the connection string for the database containing the table monitored for changes. The connection string setting name corresponds to the application setting (in `local.settings.json` for local development) that contains the [connection string](https://dev.mysql.com/doc/connector-net/en/connector-net-connections-string.html) to the Azure Database for MySQL.|
632-
| **LeasesTableName** | Optional. Name of the table used to store leases. If not specified, the leases table name will be Leases_{FunctionId}_{TableId}.
632+
| **LeasesTableName** | Optional. Name of the table used to store leases. If not specified, the leases table name is Leases_{FunctionId}_{TableId}.
633633

634634
::: zone-end
635635

@@ -646,7 +646,7 @@ The following table explains the binding configuration properties that you set i
646646
| **direction** | Required. Must be set to `in`. |
647647
| **tableName** | Required. The name of the table monitored by the trigger. |
648648
| **connectionStringSetting** | Required. The name of an app setting that contains the connection string for the database containing the table monitored for changes. The connection string setting name corresponds to the application setting (in `local.settings.json` for local development) that contains the [connection string](https://dev.mysql.com/doc/connector-net/en/connector-net-connections-string.html) to the Azure Database for MySQL.|
649-
| **LeasesTableName** | Optional. Name of the table used to store leases. If not specified, the leases table name will be Leases_{FunctionId}_{TableId}.
649+
| **LeasesTableName** | Optional. Name of the table used to store leases. If not specified, the leases table name is Leases_{FunctionId}_{TableId}.
650650

651651
::: zone-end
652652

@@ -661,12 +661,12 @@ The following optional settings can be configured for the MySQL trigger for loca
661661
| Setting | Default| Description|
662662
|---------|---------|---------|
663663
|**MaxBatchSize** | 100 |The maximum number of changes processed with each iteration of the trigger loop before being sent to the triggered function.|
664-
|**PollingIntervalMs** | 1000 | The delay in milliseconds between processing each batch of changes. (1000 ms is 1 second)|
664+
|**PollingIntervalMs** | 1000 | The delay in milliseconds between processing each batch of changes. (1,000 ms is 1 second)|
665665
|**MaxChangesPerWorker**| 1000 | The upper limit on the number of pending changes in the user table that are allowed per application-worker. If the count of changes exceeds this limit, it might result in a scale-out. The setting only applies for Azure Function Apps with [runtime driven scaling enabled](#enable-runtime-driven-scaling).|
666666

667667
#### Example host.json file
668668

669-
Here is an example host.json file with the optional settings:
669+
Here's an example host.json file with the optional settings:
670670

671671
```JSON
672672
{
@@ -702,12 +702,12 @@ The local.settings.json file stores app settings and settings used by local deve
702702
| Setting | Default| Description|
703703
|---------|---------|---------|
704704
|**MySql_Trigger_BatchSize** | 100 |The maximum number of changes processed with each iteration of the trigger loop before being sent to the triggered function.|
705-
|**MySql_Trigger_PollingIntervalMs** | 1000 | The delay in milliseconds between processing each batch of changes. (1000 ms is 1 second)|
705+
|**MySql_Trigger_PollingIntervalMs** | 1000 | The delay in milliseconds between processing each batch of changes. (1,000 ms is 1 second)|
706706
|**MySql_Trigger_MaxChangesPerWorker**| 1000 | The upper limit on the number of pending changes in the user table that are allowed per application-worker. If the count of changes exceeds this limit, it might result in a scale-out. The setting only applies for Azure Function Apps with [runtime driven scaling enabled](#enable-runtime-driven-scaling).|
707707

708708
#### Example local.settings.json file
709709

710-
Here is an example local.settings.json file with the optional settings:
710+
Here's an example local.settings.json file with the optional settings:
711711

712712
```JSON
713713
{
@@ -727,7 +727,7 @@ Here is an example local.settings.json file with the optional settings:
727727

728728
Setting up change tracking for use with the Azure Database for MySQL trigger requires to add a column in table using a function. These steps can be completed from any MySQL tool that supports running queries, including [Visual Studio Code](/sql/tools/visual-studio-code/mssql-extensions) or [Azure Data Studio](/azure-data-studio/download-azure-data-studio).
729729

730-
Azure Database for MySQL Trigger ndings use "az_func_updated_at" and column's data, to monitor the user table for changes. As such, it is necessary to alter the table structure to allow change tracking on the MySQL table before using the trigger support.
730+
Azure Database for MySQL Trigger bindings use "az_func_updated_at" and column's data, to monitor the user table for changes. As such, it's necessary to alter the table structure to allow change tracking on the MySQL table before using the trigger support.
731731

732732
The change tracking can be enabled on a table through following query. For example, enable on ‘Products’ table:
733733

@@ -738,7 +738,7 @@ TIMESTAMP DEFAULT CURRENT_TIMESTAMP
738738
ON UPDATE CURRENT_TIMESTAMP;
739739
```
740740

741-
The leases table contains all columns corresponding to the primary key from the user table and two additional columns _az_func_AttemptCount and _az_func_LeaseExpirationTime. So, if any of the primary key columns happen to have the same name, that will result in an error message listing any conflicts. In this case, the listed primary key columns must be renamed for the trigger to work.
741+
The leases table contains all columns corresponding to the primary key from the user table and two more columns _az_func_AttemptCount and _az_func_LeaseExpirationTime. So, if any of the primary key columns happen to have the same name, that will result in an error message listing any conflicts. In this case, the listed primary key columns must be renamed for the trigger to work.
742742

743743

744744
## Enable runtime-driven scaling
@@ -753,9 +753,9 @@ Optionally, your functions can scale automatically based on the number of change
753753
If an exception occurs during startup then the host runtime automatically attempts to restart the trigger listener with an exponential backoff strategy. These retries continue until either the listener is successfully started or the startup is canceled.
754754

755755
### Function exception retries
756-
If an exception occurs in the user function when processing changes then the batch of rows currently being processed are retried again in 60 seconds. Other changes are processed as normal during this time, but the rows in the batch that caused the exception are ignored until the timeout period has elapsed.
756+
If an exception occurs in the user function when processing changes then the batch of rows currently being processed are retried again in 60 seconds. Other changes are processed as normal during this time, but the rows in the batch that caused the exception are ignored until the time-out period has elapsed.
757757

758-
If the function execution fails five times in a row for a given row then that row is completely ignored for all future changes. Because the rows in a batch are not deterministic, rows in a failed batch might end up in different batches in subsequent invocations. This means that not all rows in the failed batch will necessarily be ignored. If other rows in the batch were the ones causing the exception, the "good" rows might end up in a different batch that doesn't fail in future invocations.
758+
If the function execution fails five times in a row for a given row then that row is completely ignored for all future changes. Because the rows in a batch aren't deterministic, rows in a failed batch might end up in different batches in subsequent invocations. This means that not all rows in the failed batch will necessarily be ignored. If other rows in the batch were the ones causing the exception, the "good" rows might end up in a different batch that doesn't fail in future invocations.
759759

760760
## Next steps
761761

0 commit comments

Comments
 (0)