|
| 1 | +--- |
| 2 | +title: Azure Security Center compliance monitoring using the REST API | Microsoft Docs |
| 3 | +description: Review results of automated compliance scans using the Azure Security Center REST API. |
| 4 | +services: security-center |
| 5 | +documentationcenter: na |
| 6 | +author: rloutlaw |
| 7 | +manager: angerobe |
| 8 | +ms.service: security-center |
| 9 | +ms.devlang: na |
| 10 | +ms.topic: article |
| 11 | +ms.tgt_pltfrm: na |
| 12 | +ms.workload: na |
| 13 | +ms.date: 08/23/2018 |
| 14 | +ms.author: rloutlaw |
| 15 | + |
| 16 | +--- |
| 17 | + |
| 18 | +# Review Security Center compliance results using the Azure REST APIs |
| 19 | + |
| 20 | +In this article, you learn to retrieve the security compliance information for a list of subscriptions using the Azure REST APIs. |
| 21 | + |
| 22 | +## Review compliance for each subscription |
| 23 | + |
| 24 | +The below example gets security assessement information for a given compliance and subscription using the [Get Compliances](/rest/api/securitycenter/compliances/get) operation. |
| 25 | + |
| 26 | +```http |
| 27 | +GET https://management.azure.com/subscriptions/{subscription-id}/providers/Microsoft.Security/compliances/{complianceName}?api-version=2017-08-01-preview |
| 28 | +``` |
| 29 | + |
| 30 | +The `{complianceName}` parameter is required and should contain the name of the assessed compliance for `{subscription-id}`. Output will contain the assessment results, such as: |
| 31 | + |
| 32 | +```json |
| 33 | +{ |
| 34 | +... |
| 35 | + "properties": { |
| 36 | + "assessmentResult": [ |
| 37 | + { |
| 38 | + "segmentType": "Compliant", |
| 39 | + "percentage": 77.777777777777786 |
| 40 | + } |
| 41 | + ], |
| 42 | + "resourceCount": 18, |
| 43 | + "assessmentTimestampUtcDate": "2018-01-01T00:00:00Z" |
| 44 | + } |
| 45 | +} |
| 46 | +``` |
| 47 | + |
| 48 | +## Review compliance for multiple subscriptions |
| 49 | + |
| 50 | +To get data for multiple subscriptions, make the call below to first get a list of subscriptions using the [List Subscriptions](/rest/api/resources/subscriptions/list) operation. The invoke the above [Get Compliances](/rest/api/securitycenter/compliances/get) for each of the returned subscription IDs. |
| 51 | + |
| 52 | +The API call is: |
| 53 | + |
| 54 | +```http |
| 55 | +GET https://management.azure.com/subscriptions?api-version=2016-06-01 |
| 56 | +``` |
| 57 | + |
| 58 | +Which returns an array of with values such as the following. Use the subscriptionId values in the above call to review the compliance information for all subscriptions. |
| 59 | + |
| 60 | +```json |
| 61 | +"value": [ |
| 62 | + { |
| 63 | + "id": "/subscriptions/{subscription-id}", |
| 64 | + "subscriptionId": "{subscription-id}", |
| 65 | + "displayName": "Demo subscription", |
| 66 | + ... |
| 67 | + } |
| 68 | +``` |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | + |
0 commit comments