Skip to content

Commit 0c1d684

Browse files
authored
Merge pull request #182971 from linda33wj/purview
Update Snowflake permission and tips
2 parents 3c73f91 + ec466f8 commit 0c1d684

File tree

2 files changed

+80
-5
lines changed

2 files changed

+80
-5
lines changed
3.63 KB
Loading

articles/purview/register-scan-snowflake.md

Lines changed: 80 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ms.author: jingwang
66
ms.service: purview
77
ms.subservice: purview-data-map
88
ms.topic: how-to #Required; leave this attribute/value as-is.
9-
ms.date: 11/19/2021
9+
ms.date: 12/15/2021
1010
ms.custom: template-how-to #Required; leave this attribute/value as-is.
1111
---
1212

@@ -42,7 +42,71 @@ When scanning Snowflake, Purview supports:
4242

4343
* Ensure Visual C++ Redistributable for Visual Studio 2012 Update 4 is installed on the self-hosted integration runtime machine. If you don't have this update installed, [you can download it here](https://www.microsoft.com/download/details.aspx?id=30679).
4444

45-
* The Snowflake user must have read access to system tables in order to access advanced metadata.
45+
### Required permissions for scan
46+
47+
Azure Purview supports basic authentication (username and password) for scanning Snowflake. The default role of the given user will be used. The Snowflake user must have read access to system tables in order to access advanced metadata. Here is a sample walkthrough to set up the permission. If you choose to use an existing user, make sure it has adequate rights.
48+
49+
1. Set up a `purview_reader` role. You will need _ACCOUNTADMIN_ rights to do this.
50+
51+
```sql
52+
USE ROLE ACCOUNTADMIN;
53+
54+
--create role to allow read only access - this will later be assigned to the purview USER
55+
CREATE OR REPLACE ROLE purview_reader;
56+
57+
--make sysadmin the parent role
58+
GRANT ROLE purview_reader TO ROLE sysadmin;
59+
```
60+
61+
2. Create a warehouse for Purview to use and grant rights.
62+
63+
```sql
64+
--create warehouse - account admin required
65+
CREATE OR REPLACE WAREHOUSE purview_wh WITH
66+
WAREHOUSE_SIZE = 'XSMALL'
67+
WAREHOUSE_TYPE = 'STANDARD'
68+
AUTO_SUSPEND = 300
69+
AUTO_RESUME = TRUE
70+
MIN_CLUSTER_COUNT = 1
71+
MAX_CLUSTER_COUNT = 2
72+
SCALING_POLICY = 'STANDARD';
73+
74+
--grant rights to the warehouse
75+
GRANT USAGE ON WAREHOUSE purview_wh TO ROLE purview_reader;
76+
```
77+
78+
3. Create a USER `purview` for Purview scan.
79+
80+
```sql
81+
CREATE OR REPLACE USER purview
82+
PASSWORD = '<password>';
83+
84+
--note the default role will be used during scan
85+
ALTER USER purview SET DEFAULT_ROLE = purview_reader;
86+
87+
--add user to purview_reader role
88+
GRANT ROLE purview_reader TO USER purview;
89+
```
90+
91+
4. Grant reader rights to the database objects.
92+
93+
```sql
94+
--grant reader access to all the database structures that purview can currently scan
95+
GRANT USAGE ON ALL SCHEMAS IN DATABASE <your_database_name> TO role purview_reader;
96+
GRANT USAGE ON ALL FUNCTIONS IN DATABASE <your_database_name> TO role purview_reader;
97+
GRANT USAGE ON ALL PROCEDURES IN DATABASE <your_database_name> TO role purview_reader;
98+
GRANT SELECT ON ALL TABLES IN DATABASE <your_database_name> TO role purview_reader;
99+
GRANT SELECT ON ALL VIEWS IN DATABASE <your_database_name> TO role purview_reader;
100+
GRANT USAGE, READ on ALL STAGES IN DATABASE <your_database_name> TO role purview_reader;
101+
102+
--grant reader access to any future objects that could be created
103+
GRANT USAGE ON FUTURE SCHEMAS IN DATABASE <your_database_name> TO role purview_reader;
104+
GRANT USAGE ON FUTURE FUNCTIONS IN DATABASE <your_database_name> TO role purview_reader;
105+
GRANT USAGE ON FUTURE PROCEDURES IN DATABASE <your_database_name> TO role purview_reader;
106+
GRANT SELECT ON FUTURE TABLES IN DATABASE <your_database_name> TO role purview_reader;
107+
GRANT SELECT ON FUTURE VIEWS IN DATABASE <your_database_name> TO role purview_reader;
108+
GRANT USAGE, READ ON FUTURE STAGES IN DATABASE <your_database_name> TO role purview_reader;
109+
```
46110

47111
## Register
48112

@@ -61,7 +125,7 @@ On the **Register sources (Snowflake)** screen, do the following:
61125

62126
1. Enter a **Name** that the data source will be listed within the Catalog.
63127

64-
1. Enter the **server** URL used to connect to the Snowflake account, for example, `xy12345.east-us-2.azure.snowflakecomputing.com`.
128+
1. Enter the **server** URL used to connect to the Snowflake account in the form of `<account_identifier>.snowflakecomputing.com`, for example, `xy12345.east-us-2.azure.snowflakecomputing.com`. Learn more about Snowflake [account identifier](https://docs.snowflake.com/en/user-guide/admin-account-identifier.html#).
65129

66130
1. Select a collection or create a new one (Optional)
67131

@@ -101,9 +165,9 @@ To create and run a new scan, do the following:
101165
* Provide the user name used to connect to Snowflake in the User name input field.
102166
* Store the user password used to connect to Snowflake in the secret key.
103167

104-
1. **Warehouse**: Specify the name of the warehouse instance to use.
168+
1. **Warehouse**: Specify the name of the warehouse instance used to empower scan in capital case. The default role assigned to the user specified in the credential must have USAGE rights on this warehouse.
105169

106-
1. **Database**: Specify the name of the database instance to import.
170+
1. **Database**: Specify the name of the database instance to import in capital case. The default role assigned to the user specified in the credential must have adequate rights on the database objects.
107171

108172
1. **Schema**: List subset of schemas to import expressed as a semicolon separated list. For example, `schema1; schema2`. All user schemas are imported if that list is empty. All system schemas and objects are ignored by default.
109173

@@ -130,6 +194,17 @@ To create and run a new scan, do the following:
130194

131195
[!INCLUDE [create and manage scans](includes/view-and-manage-scans.md)]
132196

197+
## Troubleshooting tips
198+
199+
- Check your account identifer in the source registration step. Do not include `https://` part at the front.
200+
- Make sure the warehouse name and database name are in capital case on the scan setup page.
201+
- Check your key vault. Make sure there are no typos in the password.
202+
- Check the credential you set up in Purview. The user you specify must have a default role with the necessary access rights to both the warehouse and the database you are trying to scan. See [Required permissions for scan](#required-permissions-for-scan). USE `DESCRIBE USER;` to verify the default role of the user you've specified for Purview.
203+
- Use Query History in Snowflake to see if any activity is coming across.
204+
- If there's a problem with the account identifer or password, you won't see any activity.
205+
- If there's a problem with the default role, you should at least see a `USE WAREHOUSE . . .` statement.
206+
- You can use the [QUERY_HISTORY_BY_USER table function](https://docs.snowflake.com/en/sql-reference/functions/query_history.html) to identify what role is being used by the connection. Setting up a dedicated Purview user will make troubleshooting easier.
207+
133208
## Next steps
134209

135210
Now that you have registered your source, follow the below guides to learn more about Purview and your data.

0 commit comments

Comments
 (0)