Skip to content

Commit 14ec997

Browse files
committed
update postgresql passwordless tutorial
1 parent de5faed commit 14ec997

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

articles/service-connector/includes/code-postgres-aad.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,20 @@ For other languages, you can use the connection string and username that Service
100100

101101
For more code samples, see [Connect to Azure databases from App Service without secrets using a managed identity](/azure/app-service/tutorial-connect-msi-azure-database?tabs=postgresql#3-modify-your-code).
102102

103+
104+
---
105+
106+
Next, if you have created tables and sequences in postgresql flexible server, you need to login as table owner and grant permission to `aad username` that's created by Service Connector. Get the user name from connection string or configuration set by service connector, it should be look like `aad_<connection name>`. If you use Portal, click the expand button and get the value. If you use Azure CLI, check `configurations` in output of CLI command.
107+
Then, execute the query to grant permission
108+
109+
```azure-cli
110+
az extension add --name rdbms-connect
111+
112+
az postgres flexible-server execute -n <postgres server name> -u <owner username> -p "<owner password>" -d <database> --querytext "GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO \"<aad username>\";GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO \"<aad username>\";"
113+
```
114+
The `<owner username>` and `<owner password>` is the owner of existing table that can grant permission to others. `<aad username>` is the user created by Service Connector. Replace them with the actual value.
115+
116+
You can validate the result with the command:
117+
```azure-cli
118+
az postgres flexible-server execute -n <postgres server name> -u <owner username> -p "<owner password>" -d <database> --querytext "SELECT distinct(table_name) FROM information_schema.table_privileges WHERE grantee='<aad username>' AND table_schema='public';" --output table
119+
```

0 commit comments

Comments
 (0)