Skip to content

Commit 464265a

Browse files
authored
Merge pull request #217675 from inward-eye/main
how to fetch policies
2 parents 2d96d24 + ddbf4dc commit 464265a

File tree

1 file changed

+111
-6
lines changed

1 file changed

+111
-6
lines changed

articles/purview/troubleshoot-policy-distribution.md

Lines changed: 111 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ms.date: 11/08/2022
1313

1414
[!INCLUDE [feature-in-preview](includes/feature-in-preview.md)]
1515

16-
In this tutorial, learn how to programmatically fetch access policies that were created in Microsoft Purview. This can be used to troubleshoot the communication of policies between Microsoft Purview, where policies are created and updated and the data sources on which these policies are enforced.
16+
In this tutorial, learn how to programmatically fetch access policies that were created in Microsoft Purview. With this you can troubleshoot the communication of policies between Microsoft Purview, where policies are created and updated and the data sources on which these policies are enforced.
1717
This guide will use Arc-enabled SQL Server as an example of data source.
1818

1919
To get the necessary context about Microsoft Purview policies, see concept guides listed in [next-steps](#next-steps).
@@ -28,7 +28,7 @@ To get the necessary context about Microsoft Purview policies, see concept guide
2828
## Overview
2929
There are two ways to fetch access policies from Microsoft Purview
3030
- Full pull: Provides a complete set of policies for a particular data resource scope.
31-
- Delta pull: Provides an incremental view of policies, that is, what has changed since the last pull request, whether that one was a full pull or a delta pull.
31+
- Delta pull: Provides an incremental view of policies, that is, what has changed since the last pull request, whether that one was a full pull or a delta pull. A full pull is required prior to the first delta pull.
3232

3333
Microsoft Purview policy model is described using [JSON syntax](https://datatracker.ietf.org/doc/html/rfc8259)
3434

@@ -49,18 +49,19 @@ GET {{endpoint}}/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupNam
4949
|Http Code|Http Code Description|Type|Description|Response|
5050
|---------|---------------------|----|-----------|--------|
5151
|200|Success|Success|Request processed successfully|Policy data|
52-
|404|Not Found|Error|The request path is invalid or not registered|Error data|
5352
|401|Unauthenticated|Error|No bearer token passed in request or invalid token|Error data|
5453
|403|Forbidden|Error|Other authentication errors|Error data|
54+
|404|Not found|Error|The request path is invalid or not registered|Error data|
5555
|500|Internal server error|Error|Backend service unavailable|Error data|
5656
|503|Backend service unavailable|Error|Backend service unavailable|Error data|
5757

5858
### Example for Arc-enabled SQL Server
5959

6060
##### Example parameters:
61+
- Microsoft Purview account = relecloud-pv
6162
- resourceProvider = Microsoft.AzureArcData
6263
- resourceType = sqlServerInstances
63-
- apiVersion = 2021-01-01-preview
64+
- resourceName = vm-finance
6465

6566
##### Example request:
6667
```
@@ -69,6 +70,8 @@ GET https://relecloud-pv.purview.azure.com/pds/subscriptions/b285630c-8185-456b-
6970

7071
##### Example response:
7172

73+
`200 OK`
74+
7275
```json
7376
{
7477
"count": 2,
@@ -95,30 +98,132 @@ GET https://relecloud-pv.purview.azure.com/pds/subscriptions/b285630c-8185-456b-
9598
}
9699
```
97100

101+
## Delta pull
102+
103+
### Request
104+
To fetch policies via full pull, send a `GET` request to /policyEvents as follows:
105+
106+
```
107+
GET {{endpoint}}/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProvider}/{resourceType}/{resourceName}/policyEvents?api-version={apiVersion}&syncToken={syncToken}
108+
```
109+
110+
Provide the syncToken you got from the prior pull in any successive delta pulls.
111+
112+
### Response status codes
113+
114+
|Http Code|Http Code Description|Type|Description|Response|
115+
|---------|---------------------|----|-----------|--------|
116+
|200|Success|Success|Request processed successfully|Policy data|
117+
|304|Not modified|Success|No events received since last delta pull call|None|
118+
|401|Unauthenticated|Error|No bearer token passed in request or invalid token|Error data|
119+
|403|Forbidden|Error|Other authentication errors|Error data|
120+
|404|Not found|Error|The request path is invalid or not registered|Error data|
121+
|500|Internal server error|Error|Backend service unavailable|Error data|
122+
|503|Backend service unavailable|Error|Backend service unavailable|Error data|
123+
124+
### Example for Arc-enabled SQL Server
125+
126+
##### Example parameters:
127+
- Microsoft Purview account = relecloud-pv
128+
- resourceProvider = Microsoft.AzureArcData
129+
- resourceType = sqlServerInstances
130+
- resourceName = vm-finance
131+
- syncToken = 808:0
132+
133+
##### Example request:
134+
```
135+
https://relecloud-pv.purview.azure.com/pds/subscriptions/b285630c-8185-456b-80ae-97296561303e/resourceGroups/Finance-rg/providers/Microsoft.AzureArcData/sqlServerInstances/vm-finance/policyEvents?api-version=2021-01-01-preview&syncToken=808:0
136+
```
137+
138+
##### Example response:
139+
140+
`200 OK`
141+
142+
```json
143+
{
144+
"count": 2,
145+
"syncToken": "816:0",
146+
"elements": [
147+
{
148+
"eventType": "Microsoft.Purview/PolicyElements/Write",
149+
"id": "6554a0d5-2d18-49fb-b44d-dc26f935fc61",
150+
"scopes": [
151+
"/subscriptions/b285630c-8185-456b-80ae-97296561303e/resourceGroups/Finance-rg/providers/Microsoft.AzureArcData/SqlServerInstances/vm-finance"
152+
],
153+
"kind": "policyset",
154+
"updatedAt": "2022-11-09T00:46:23.2085292Z",
155+
"version": 1,
156+
"elementJson": "{\"id\":\"6554a0d5-2d18-49fb-b44d-dc26f935fc61\",\"name\":\"6554a0d5-2d18-49fb-b44d-dc26f935fc61\",\"kind\":\"policyset\",\"version\":1,\"updatedAt\":\"2022-11-09T00:46:23.2085292Z\",\"preconditionRules\":[{\"dnfCondition\":[[{\"attributeName\":\"resource.azure.path\",\"attributeValueIncludedIn\":[\"/subscriptions/b285630c-8185-456b-80ae-97296561303e/resourceGroups/Finance-rg/providers/Microsoft.AzureArcData/SqlServerInstances/vm-finance/**\"]}]]}],\"policyRefs\":[\"919a18b7-6dfd-4e3c-81c9-3414dcbd0cef\"]}"
157+
},
158+
{
159+
"eventType": "Microsoft.Purview/PolicyElements/Write",
160+
"id": "919a18b7-6dfd-4e3c-81c9-3414dcbd0cef",
161+
"scopes": [
162+
"/subscriptions/b285630c-8185-456b-80ae-97296561303e/resourceGroups/Finance-rg/providers/Microsoft.AzureArcData/SqlServerInstances/vm-finance"
163+
],
164+
"kind": "policy",
165+
"updatedAt": "2022-11-09T00:46:23.2085486Z",
166+
"version": 1,
167+
"elementJson": "{\"id\":\"919a18b7-6dfd-4e3c-81c9-3414dcbd0cef\",\"name\":\"ArcSQL-Finance_sqlperfmonitor\",\"kind\":\"policy\",\"version\":1,\"updatedAt\":\"2022-11-09T00:46:23.2085486Z\",\"decisionRules\":[{\"kind\":\"decisionrule\",\"effect\":\"Permit\",\"updatedAt\":\"11/09/2022 00:46:23\",\"cnfCondition\":[[{\"attributeName\":\"resource.azure.path\",\"attributeValueIncludedIn\":[\"/subscriptions/b285630c-8185-456b-80ae-97296561303e/resourceGroups/Finance-rg/providers/Microsoft.AzureArcData/SqlServerInstances/vm-finance/**\"]}],[{\"fromRule\":\"purviewdatarole_builtin_sqlperfmonitor\",\"attributeName\":\"derived.purview.role\",\"attributeValueIncludes\":\"purviewdatarole_builtin_sqlperfmonitor\"}],[{\"attributeName\":\"principal.microsoft.groups\",\"attributeValueIncludedIn\":[\"e119d3ec-8353-4a33-96e7-e1a95680d37d\"]}]]},{\"kind\":\"decisionrule\",\"effect\":\"Permit\",\"id\":\"auto_81cd13c9-0417-4b97-a310-c14009a7c2ed\",\"updatedAt\":\"11/09/2022 00:46:23\",\"cnfCondition\":[[{\"attributeName\":\"resource.azure.path\",\"attributeValueIncludedIn\":[\"/subscriptions/b285630c-8185-456b-80ae-97296561303e/resourceGroups/Finance-rg/providers/Microsoft.AzureArcData/SqlServerInstances/vm-finance\"]}],[{\"attributeName\":\"request.azure.dataAction\",\"attributeValueIncludedIn\":[\"Microsoft.Sql/sqlservers/Connect\"]}],[{\"attributeName\":\"principal.microsoft.groups\",\"attributeValueIncludedIn\":[\"e119d3ec-8353-4a33-96e7-e1a95680d37d\"]}]]},{\"kind\":\"decisionrule\",\"effect\":\"Permit\",\"id\":\"auto_4b655d27-c8b0-4aa7-aa36-27f95ede2ada\",\"updatedAt\":\"11/09/2022 00:46:23\",\"cnfCondition\":[[{\"attributeName\":\"resource.azure.path\",\"attributeValueIncludedIn\":[\"/subscriptions/b285630c-8185-456b-80ae-97296561303e/resourceGroups/Finance-rg/providers/Microsoft.AzureArcData/SqlServerInstances/vm-finance/databases/**\"]}],[{\"attributeName\":\"request.azure.dataAction\",\"attributeValueIncludedIn\":[\"Microsoft.Sql/sqlservers/databases/Connect\"]}],[{\"attributeName\":\"principal.microsoft.groups\",\"attributeValueIncludedIn\":[\"e119d3ec-8353-4a33-96e7-e1a95680d37d\"]}]]}]}"
168+
}
169+
]
170+
}
171+
```
172+
98173
## Policy constructs
99174
There are 3 top-level policy constructs used within the full pull (/policyElements) and delta pull (/policyEvents) requests: PolicySet, Policy and AttributeRule.
100175

101176
### PolicySet
102177

103178
PolicySet associates Policy to a resource scope. Purview policy decision compute starts with a list of PolicySets. PolicySet evaluation triggers evaluation of Policy referenced in the PolicySet.
104179

180+
|member|value|type|cardinality|description|
181+
|------|-----|----|-----------|-----------|
182+
|ID| |string|1||
183+
|name| |string|1||
184+
|kind| |string|1||
185+
|version|1|number|1||
186+
|updatedAt| |string|1|String representation of time in yyyy-MM-ddTHH:mm:ss.fffffffZ Ex: "2022-01-11T09:55:52.6472858Z"|
187+
|preconditionRules| |array[Object:Rule]|0..1||
188+
|policyRefs| |array[string]|1|List of policy IDs|
105189

106190
### Policy
107191

108192
Policy specifies decision that should be emitted if the policy is applicable for the request provided request context attributes satisfy attribute predicates specified in the policy. Evaluation of policy triggers evaluation of AttributeRules referenced in the Policy.
109193

194+
|member|value|type|cardinality|description|
195+
|------|-----|----|-----------|-----------|
196+
|ID| |string|1||
197+
|name| |string|1||
198+
|kind| |string|1||
199+
|version|1|number|1||
200+
|updatedAt| |string|1|String representation of time in yyyy-MM-ddTHH:mm:ss.fffffffZ Ex: "2022-01-11T09:55:52.6472858Z"|
201+
|preconditionRules| |array[Object:Rule]|0..1|All the rules are 'anded'|
202+
|decisionRules| |array[Object:DecisionRule]|1||
203+
204+
110205
### AttributeRule
111206

112207
AttributeRule produces derived attributes and add them to request context attributes. Evaluation of AttributeRule triggers evaluation of additional AttributeRules referenced in the AttributeRule.
113208

209+
|member|value|type|cardinality|description|
210+
|------|-----|----|-----------|-----------|
211+
|ID| |string|1||
212+
|name| |string|1||
213+
|kind|AttributeRule|string|1||
214+
|version|1|number|1||
215+
|dnfCondition| |array[array[Object:AttributePredicate]]|0..1||
216+
|cnfCondition| |array[array[Object:AttributePredicate]]|0..1||
217+
|condition| |Object: Condition|0..1||
218+
|derivedAttributes| |array[Object:DerivedAttribute]|1||
114219

115220
## Common sub-constructs used in PolicySet, Policy, AttributeRule
116221

117222
#### AttributePredicate
118223
AttributePredicate checks whether predicate specified on an attribute is satisfied. AttributePredicate can specify the following properties:
119224
- attributeName: specifies attribute name on which attribute predicate needs to be evaluated.
120-
- matcherId: Identifier of matcher function that is used to compare the attribute value looked up in request context by the attribute name to the attribute value literal specified in the predicate. At present we support 2 matcherId(s): ExactMatcher, GlobMatcher. If matcherId isn't specified, it defaults to GlobMatcher.
121-
- fromRule: optional property specifying the identifier of an AttributeRule that needs to be evaluated to populate the request context with attribute values that would be compared in this predicate.
225+
- matcherId: ID of matcher function that is used to compare the attribute value looked up in request context by the attribute name to the attribute value literal specified in the predicate. At present we support 2 matcherId(s): ExactMatcher, GlobMatcher. If matcherId isn't specified, it defaults to GlobMatcher.
226+
- fromRule: optional property specifying the ID of an AttributeRule that needs to be evaluated to populate the request context with attribute values that would be compared in this predicate.
122227
- attributeValueIncludes: scalar literal value that should match the request context attribute values.
123228
- attributeValueIncludedIn: array of literal values that should match the request context attribute values.
124229
- attributeValueExcluded: scalar literal value that should not match the request context attribute values.

0 commit comments

Comments
 (0)