|
| 1 | +--- |
| 2 | +title: Self-service policies for Azure SQL Database (preview) |
| 3 | +description: Step-by-step guide on how self-service policy is created for Azure SQL Database through Microsoft Purview access policies. |
| 4 | +author: bjspeaks |
| 5 | +ms.author: blessonj |
| 6 | +ms.service: purview |
| 7 | +ms.subservice: purview-data-policies |
| 8 | +ms.topic: how-to |
| 9 | +ms.date: 11/11/2022 |
| 10 | +ms.custom: references_regions, event-tier1-build-2022 |
| 11 | +--- |
| 12 | +# Self-service policies for Azure SQL Database (preview) |
| 13 | + |
| 14 | +[!INCLUDE [feature-in-preview](includes/feature-in-preview.md)] |
| 15 | + |
| 16 | +[Self-service policies](concept-self-service-data-access-policy.md) allow you to manage access from Microsoft Purview to data sources that have been registered for **Data Use Management**. |
| 17 | + |
| 18 | +This how-to guide describes how self-service policies get created in Microsoft Purview to enable access to Azure SQL Database. The following actions are currently enabled: *Read Tables*, and *Read Views*. |
| 19 | + |
| 20 | +> [!CAUTION] |
| 21 | +> *Ownership chaining* must exist for *select* to work on Azure SQL Database *views*. |
| 22 | +
|
| 23 | +## Prerequisites |
| 24 | +[!INCLUDE [Access policies generic pre-requisites](./includes/access-policies-prerequisites-generic.md)] |
| 25 | +[!INCLUDE [Access policies Azure SQL DB pre-requisites](./includes/access-policies-prerequisites-azure-sql-db.md)] |
| 26 | + |
| 27 | +## Microsoft Purview Configuration |
| 28 | +[!INCLUDE [Access policies generic configuration](./includes/access-policies-configuration-generic.md)] |
| 29 | + |
| 30 | +### Register the data sources in Microsoft Purview |
| 31 | +The Azure SQL Database resources need to be registered first with Microsoft Purview to later define access policies. You can follow these guides: |
| 32 | + |
| 33 | +[Register and scan Azure SQL DB](./register-scan-azure-sql-database.md) |
| 34 | + |
| 35 | +After you've registered your resources, you'll need to enable data use management. Data use management can affect the security of your data, as it delegates to certain Microsoft Purview roles to manage access to the data sources. **Go through the secure practices related to data use management in this guide**: |
| 36 | + |
| 37 | +[How to enable data use management](./how-to-enable-data-use-management.md) |
| 38 | + |
| 39 | +Once your data source has the **Data use management** toggle *Enabled*, it will look like this picture. This will enable the access policies to be used with the given SQL server and all its contained databases. |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | +## Create a self-service data access request |
| 44 | + |
| 45 | +[!INCLUDE [request access to datasets](includes/how-to-self-service-request-access.md)] |
| 46 | + |
| 47 | + |
| 48 | +>[!Important] |
| 49 | +> - Publish is a background operation. It can take up to **5 minutes** for the changes to be reflected in this data source. |
| 50 | +> - Changing a policy does not require a new publish operation. The changes will be picked up with the next pull. |
| 51 | +
|
| 52 | + |
| 53 | +## View a self-service Policy |
| 54 | + |
| 55 | +To view the policies you've created, follow the article to [view the self-service policies](how-to-view-self-service-data-access-policy.md). |
| 56 | + |
| 57 | + |
| 58 | +### Test the policy |
| 59 | + |
| 60 | +The Azure Active Directory Account, group, MSI, or SPN for which the self-service policies were created, should now be able to connect to the database on the server and execute a select query against the requested table or view. |
| 61 | + |
| 62 | +#### Force policy download |
| 63 | +It's possible to force an immediate download of the latest published policies to the current SQL database by running the following command. The minimal permission required to run it's membership in ##MS_ServerStateManager##-server role. |
| 64 | + |
| 65 | +```sql |
| 66 | +-- Force immediate download of latest published policies |
| 67 | +exec sp_external_policy_refresh reload |
| 68 | +``` |
| 69 | + |
| 70 | +#### Analyze downloaded policy state from SQL |
| 71 | +The following DMVs can be used to analyze which policies have been downloaded and are currently assigned to Azure AD accounts. The minimal permission required to run them is VIEW DATABASE SECURITY STATE - or assigned Action Group *SQL Security Auditor*. |
| 72 | + |
| 73 | +```sql |
| 74 | + |
| 75 | +-- Lists generally supported actions |
| 76 | +SELECT * FROM sys.dm_server_external_policy_actions |
| 77 | + |
| 78 | +-- Lists the roles that are part of a policy published to this server |
| 79 | +SELECT * FROM sys.dm_server_external_policy_roles |
| 80 | + |
| 81 | +-- Lists the links between the roles and actions, could be used to join the two |
| 82 | +SELECT * FROM sys.dm_server_external_policy_role_actions |
| 83 | + |
| 84 | +-- Lists all Azure AD principals that were given connect permissions |
| 85 | +SELECT * FROM sys.dm_server_external_policy_principals |
| 86 | + |
| 87 | +-- Lists Azure AD principals assigned to a given role on a given resource scope |
| 88 | +SELECT * FROM sys.dm_server_external_policy_role_members |
| 89 | + |
| 90 | +-- Lists Azure AD principals, joined with roles, joined with their data actions |
| 91 | +SELECT * FROM sys.dm_server_external_policy_principal_assigned_actions |
| 92 | +``` |
| 93 | + |
| 94 | +## Additional information |
| 95 | + |
| 96 | +### Policy action mapping |
| 97 | + |
| 98 | +This section contains a reference of how actions in Microsoft Purview data policies map to specific actions in Azure SQL Database. |
| 99 | + |
| 100 | +| **Microsoft Purview policy action** | **Data source specific actions** | |
| 101 | +|-------------------------------------|--------------------------------------| |
| 102 | +||| |
| 103 | +| *Read* |Microsoft.Sql/sqlservers/Connect | |
| 104 | +||Microsoft.Sql/sqlservers/databases/Connect | |
| 105 | +||Microsoft.Sql/Sqlservers/Databases/Schemas/Tables/Rows| |
| 106 | +||Microsoft.Sql/Sqlservers/Databases/Schemas/Views/Rows | |
| 107 | +||| |
| 108 | + |
| 109 | +## Next steps |
| 110 | +Check blog, demo and related how-to guides |
| 111 | +- [self-service policies](concept-self-service-data-access-policy.md) |
| 112 | +- [What are Microsoft Purview workflows](concept-workflow.md) |
| 113 | +- [Self-service data access workflow for hybrid data estates](how-to-workflow-self-service-data-access-hybrid.md) |
0 commit comments