Skip to content

Commit 6dbfb4d

Browse files
Add permissions details section to setup (#679)
* Add permissions details section to setup * Update docs/GeneralSetup.md Co-authored-by: Chris LaFreniere <40371649+chlafreniere@users.noreply.github.com> * fixes * Update docs/GeneralSetup.md Co-authored-by: Chris LaFreniere <40371649+chlafreniere@users.noreply.github.com> --------- Co-authored-by: Chris LaFreniere <40371649+chlafreniere@users.noreply.github.com>
1 parent 6667a3d commit 6dbfb4d

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

docs/GeneralSetup.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,82 @@ ALTER TABLE ['{table_name}'] ALTER COLUMN ['{primary_key_column_name}'] int NOT
4242
ALTER TABLE ['{table_name}'] ADD CONSTRAINT PKey PRIMARY KEY CLUSTERED (['{primary_key_column_name}']);
4343
```
4444

45+
## Create Login and User
46+
47+
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+
GRANT SELECT ON <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+
GRANT SELECT, INSERT, UPDATE ON <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+
GRANT SELECT ON <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+
GRANT SELECT, INSERT, UPDATE, DELETE ON SCHEMA::az_func TO <UserName>
119+
```
120+
45121
## Create a Function Project
46122

47123
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

Comments
 (0)