You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SQL bindings connect to the target database by using a Connection String configured in the app settings. This will require a login be created that the function will use to access the server.
48
+
49
+
For local testing and development using a SQL (username/password) or Azure Active Directory Login is typically the easiest, but for deployed function apps it is recommended to use [Azure Active Directory Managed Authentication](https://learn.microsoft.com/azure/azure-functions/functions-identity-access-azure-sql-with-managed-identity).
50
+
51
+
## Assign Permissions
52
+
53
+
The login used by the function will need to have the following permissions assigned to the user it's mapped to in order for it to successfully interact with the database. The permissions required for each type of binding is listed below.
54
+
55
+
### Input Binding Permissions
56
+
57
+
The permissions required by input bindings depend on the query being executed.
58
+
59
+
#### Text Query Input Binding Permissions
60
+
61
+
For text query input bindings you will need the permissions required to execute the statement, which will usually be `SELECT` on the object you're retrieving rows from.
62
+
63
+
```sql
64
+
USE <DatabaseName>
65
+
GRANTSELECTON<ObjectName> TO <UserName>
66
+
```
67
+
68
+
#### Stored Procedure Input Binding Permissions
69
+
70
+
For stored procedure input bindings you will need `EXECUTE` permissions on the stored procedure.
71
+
72
+
```sql
73
+
USE <DatabaseName>
74
+
GRANT EXECUTE ON<StoredProcedureName> TO <UserName>
75
+
```
76
+
77
+
### Output Binding Permissions
78
+
79
+
-`SELECT`, `INSERT`, and `UPDATE` permissions on the table
80
+
81
+
These are required to retrieve metadata and update the rows in the table.
82
+
83
+
```sql
84
+
USE <DatabaseName>
85
+
GRANTSELECT, INSERT, UPDATEON<TableName> TO <UserName>
86
+
```
87
+
88
+
**NOTE**: In some scenarios, the presence of table components such as a SQL DML trigger may require additional permissions for the output binding to successfully complete the operation.
89
+
90
+
### Trigger Permissions
91
+
92
+
-`CREATE SCHEMA` and `CREATE TABLE` permissions on database
93
+
94
+
This is required to create the [Internal State Tables](./BindingsOverview.md#internal-state-tables) required by the trigger.
95
+
96
+
```sql
97
+
USE <DatabaseName>
98
+
GRANT CREATE SCHEMA TO <UserName>
99
+
GRANT CREATE TABLE TO <UserName>
100
+
```
101
+
102
+
-`SELECT` and `VIEW CHANGE TRACKING` permissions on the table
103
+
104
+
These are required to retrieve the data about the changes occurring in the table.
105
+
106
+
```sql
107
+
USE <DatabaseName>
108
+
GRANTSELECTON<TableName> TO <UserName>
109
+
```
110
+
111
+
-`SELECT`, `INSERT`, `UPDATE` and `DELETE` permissions on `az_func` schema
112
+
- Note this is usually automatically inherited if the login being used was the one that created the schema in the first place. If another user created the schema or ownership was changed afterwards then these permissions will need to be reapplied for the function to work.
113
+
114
+
These are required to read and update the internal state of the function.
115
+
116
+
```sql
117
+
USE <DatabaseName>
118
+
GRANTSELECT, INSERT, UPDATE, DELETEON SCHEMA::az_func TO <UserName>
119
+
```
120
+
45
121
## Create a Function Project
46
122
47
123
Now you will need a Function Project to add the binding to. If you have one created already you can skip this step.
0 commit comments