Gets all remediations for the subscription.
GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations?api-version=2021-10-01
With optional parameters:
GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations?$top={$top}&$filter={$filter}&api-version=2021-10-01
URI Parameters
Name |
In |
Required |
Type |
Description |
subscriptionId
|
path |
True
|
string
|
Microsoft Azure subscription ID.
|
api-version
|
query |
True
|
string
|
Client Api Version.
|
$filter
|
query |
|
string
|
OData filter expression.
|
$top
|
query |
|
integer
int32
|
Maximum number of records to return.
|
Responses
Security
azure_auth
Azure Active Directory OAuth2 Flow
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Name |
Description |
user_impersonation
|
impersonate your user account
|
Examples
Sample request
GET https://management.azure.com/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/Microsoft.PolicyInsights/remediations?api-version=2021-10-01
import com.azure.core.util.Context;
/** Samples for Remediations List. */
public final class Main {
/*
* x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListSubscriptionScope.json
*/
/**
* Sample code: List remediations at subscription scope.
*
* @param manager Entry point to PolicyInsightsManager.
*/
public static void listRemediationsAtSubscriptionScope(
com.azure.resourcemanager.policyinsights.PolicyInsightsManager manager) {
manager.remediations().list(null, null, Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.policyinsights import PolicyInsightsClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-policyinsights
# USAGE
python remediations_list_subscription_scope.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = PolicyInsightsClient(
credential=DefaultAzureCredential(),
subscription_id="35ee058e-5fa0-414c-8145-3ebb8d09b6e2",
)
response = client.remediations.list_for_subscription()
for item in response:
print(item)
# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListSubscriptionScope.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armpolicyinsights_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListSubscriptionScope.json
func ExampleRemediationsClient_NewListForSubscriptionPager_listRemediationsAtSubscriptionScope() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewRemediationsClient().NewListForSubscriptionPager(&armpolicyinsights.QueryOptions{Top: nil,
Filter: nil,
OrderBy: nil,
Select: nil,
From: nil,
To: nil,
Apply: nil,
SkipToken: nil,
Expand: nil,
}, nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page.RemediationListResult = armpolicyinsights.RemediationListResult{
// Value: []*armpolicyinsights.Remediation{
// {
// Name: to.Ptr("790996e6-9871-4b1f-9cd9-ec42cd6ced1e"),
// Type: to.Ptr("Microsoft.PolicyInsights/remediations"),
// ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.policyinsights/remediations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e"),
// Properties: &armpolicyinsights.RemediationProperties{
// CorrelationID: to.Ptr("a14e1d60-dae9-4771-b4be-a556d69e77a6"),
// CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()),
// DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{
// FailedDeployments: to.Ptr[int32](0),
// SuccessfulDeployments: to.Ptr[int32](2),
// TotalDeployments: to.Ptr[int32](2),
// },
// FailureThreshold: &armpolicyinsights.RemediationPropertiesFailureThreshold{
// Percentage: to.Ptr[float32](0.1),
// },
// LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()),
// ParallelDeployments: to.Ptr[int32](6),
// PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"),
// ProvisioningState: to.Ptr("Succeeded"),
// ResourceCount: to.Ptr[int32](42),
// ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant),
// StatusMessage: to.Ptr("Remediation extended status"),
// },
// SystemData: &armpolicyinsights.SystemData{
// CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:49:16.463Z"); return t}()),
// CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"),
// CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser),
// LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:50:18.464Z"); return t}()),
// LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"),
// LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser),
// },
// },
// {
// Name: to.Ptr("0866f0cc-6cb3-422c-9fb6-a4e3e2266da8"),
// Type: to.Ptr("Microsoft.PolicyInsights/remediations"),
// ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup2/providers/microsoft.policyinsights/remediations/0866f0cc-6cb3-422c-9fb6-a4e3e2266da8"),
// Properties: &armpolicyinsights.RemediationProperties{
// CorrelationID: to.Ptr("957378d3-a143-421e-8b0e-3048dff01932"),
// CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:49:16.463Z"); return t}()),
// DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{
// FailedDeployments: to.Ptr[int32](0),
// SuccessfulDeployments: to.Ptr[int32](2),
// TotalDeployments: to.Ptr[int32](2),
// },
// FailureThreshold: &armpolicyinsights.RemediationPropertiesFailureThreshold{
// Percentage: to.Ptr[float32](0.1),
// },
// LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:50:18.464Z"); return t}()),
// ParallelDeployments: to.Ptr[int32](6),
// PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"),
// ProvisioningState: to.Ptr("Succeeded"),
// ResourceCount: to.Ptr[int32](42),
// ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant),
// StatusMessage: to.Ptr("Remediation extended status"),
// },
// SystemData: &armpolicyinsights.SystemData{
// CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:49:16.463Z"); return t}()),
// CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"),
// CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser),
// LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:50:18.464Z"); return t}()),
// LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"),
// LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser),
// },
// }},
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { PolicyInsightsClient } = require("@azure/arm-policyinsights");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Gets all remediations for the subscription.
*
* @summary Gets all remediations for the subscription.
* x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListSubscriptionScope.json
*/
async function listRemediationsAtSubscriptionScope() {
const subscriptionId =
process.env["POLICYINSIGHTS_SUBSCRIPTION_ID"] || "35ee058e-5fa0-414c-8145-3ebb8d09b6e2";
const credential = new DefaultAzureCredential();
const client = new PolicyInsightsClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.remediations.listForSubscription()) {
resArray.push(item);
}
console.log(resArray);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"properties": {
"policyAssignmentId": "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5",
"provisioningState": "Succeeded",
"createdOn": "2018-09-13T21:51:09.075918Z",
"lastUpdatedOn": "2018-09-13T21:52:10.0011706Z",
"resourceDiscoveryMode": "ExistingNonCompliant",
"deploymentStatus": {
"totalDeployments": 2,
"successfulDeployments": 2,
"failedDeployments": 0
},
"statusMessage": "Remediation extended status",
"correlationId": "a14e1d60-dae9-4771-b4be-a556d69e77a6",
"resourceCount": 42,
"parallelDeployments": 6,
"failureThreshold": {
"percentage": 0.1
}
},
"id": "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.policyinsights/remediations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e",
"name": "790996e6-9871-4b1f-9cd9-ec42cd6ced1e",
"type": "Microsoft.PolicyInsights/remediations",
"systemData": {
"createdBy": "b69a9388-9488-4534-b470-7ec6d41beef6",
"createdByType": "User",
"createdAt": "2018-09-13T21:49:16.4638131Z",
"lastModifiedBy": "b69a9388-9488-4534-b470-7ec6d41beef6",
"lastModifiedByType": "User",
"lastModifiedAt": "2018-09-13T21:50:18.4647478Z"
}
},
{
"properties": {
"policyAssignmentId": "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5",
"provisioningState": "Succeeded",
"createdOn": "2018-09-13T21:49:16.4638131Z",
"lastUpdatedOn": "2018-09-13T21:50:18.4647478Z",
"resourceDiscoveryMode": "ExistingNonCompliant",
"deploymentStatus": {
"totalDeployments": 2,
"successfulDeployments": 2,
"failedDeployments": 0
},
"statusMessage": "Remediation extended status",
"correlationId": "957378d3-a143-421e-8b0e-3048dff01932",
"resourceCount": 42,
"parallelDeployments": 6,
"failureThreshold": {
"percentage": 0.1
}
},
"id": "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup2/providers/microsoft.policyinsights/remediations/0866f0cc-6cb3-422c-9fb6-a4e3e2266da8",
"name": "0866f0cc-6cb3-422c-9fb6-a4e3e2266da8",
"type": "Microsoft.PolicyInsights/remediations",
"systemData": {
"createdBy": "b69a9388-9488-4534-b470-7ec6d41beef6",
"createdByType": "User",
"createdAt": "2018-09-13T21:49:16.4638131Z",
"lastModifiedBy": "b69a9388-9488-4534-b470-7ec6d41beef6",
"lastModifiedByType": "User",
"lastModifiedAt": "2018-09-13T21:50:18.4647478Z"
}
}
]
}
Sample request
GET https://management.azure.com/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/Microsoft.PolicyInsights/remediations?$top=1&$filter=PolicyAssignmentId eq '/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5' AND PolicyDefinitionReferenceId eq 'storageSkuDef'&api-version=2021-10-01
import com.azure.core.util.Context;
/** Samples for Remediations List. */
public final class Main {
/*
* x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListSubscriptionScope_WithQuery.json
*/
/**
* Sample code: List remediations at subscription scope with query parameters.
*
* @param manager Entry point to PolicyInsightsManager.
*/
public static void listRemediationsAtSubscriptionScopeWithQueryParameters(
com.azure.resourcemanager.policyinsights.PolicyInsightsManager manager) {
manager
.remediations()
.list(
1,
"PolicyAssignmentId eq"
+ " '/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5'"
+ " AND PolicyDefinitionReferenceId eq 'storageSkuDef'",
Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.policyinsights import PolicyInsightsClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-policyinsights
# USAGE
python remediations_list_subscription_scope_with_query.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = PolicyInsightsClient(
credential=DefaultAzureCredential(),
subscription_id="35ee058e-5fa0-414c-8145-3ebb8d09b6e2",
)
response = client.remediations.list_for_subscription()
for item in response:
print(item)
# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListSubscriptionScope_WithQuery.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armpolicyinsights_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/05a9cdab363b8ec824094ee73950c04594325172/specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListSubscriptionScope_WithQuery.json
func ExampleRemediationsClient_NewListForSubscriptionPager_listRemediationsAtSubscriptionScopeWithQueryParameters() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpolicyinsights.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewRemediationsClient().NewListForSubscriptionPager(&armpolicyinsights.QueryOptions{Top: to.Ptr[int32](1),
Filter: to.Ptr("PolicyAssignmentId eq '/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5' AND PolicyDefinitionReferenceId eq 'storageSkuDef'"),
OrderBy: nil,
Select: nil,
From: nil,
To: nil,
Apply: nil,
SkipToken: nil,
Expand: nil,
}, nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page.RemediationListResult = armpolicyinsights.RemediationListResult{
// Value: []*armpolicyinsights.Remediation{
// {
// Name: to.Ptr("790996e6-9871-4b1f-9cd9-ec42cd6ced1e"),
// Type: to.Ptr("Microsoft.PolicyInsights/remediations"),
// ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.policyinsights/remediations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e"),
// Properties: &armpolicyinsights.RemediationProperties{
// CorrelationID: to.Ptr("a14e1d60-dae9-4771-b4be-a556d69e77a6"),
// CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:51:09.075Z"); return t}()),
// DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{
// FailedDeployments: to.Ptr[int32](0),
// SuccessfulDeployments: to.Ptr[int32](2),
// TotalDeployments: to.Ptr[int32](2),
// },
// FailureThreshold: &armpolicyinsights.RemediationPropertiesFailureThreshold{
// Percentage: to.Ptr[float32](0.1),
// },
// LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:52:10.001Z"); return t}()),
// ParallelDeployments: to.Ptr[int32](6),
// PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"),
// PolicyDefinitionReferenceID: to.Ptr("storageSkuDef"),
// ProvisioningState: to.Ptr("Succeeded"),
// ResourceCount: to.Ptr[int32](42),
// ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant),
// StatusMessage: to.Ptr("Remediation extended status"),
// },
// SystemData: &armpolicyinsights.SystemData{
// CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:49:16.463Z"); return t}()),
// CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"),
// CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser),
// LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:50:18.464Z"); return t}()),
// LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"),
// LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser),
// },
// },
// {
// Name: to.Ptr("0866f0cc-6cb3-422c-9fb6-a4e3e2266da8"),
// Type: to.Ptr("Microsoft.PolicyInsights/remediations"),
// ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/rg2/providers/microsoft.policyinsights/remediations/0866f0cc-6cb3-422c-9fb6-a4e3e2266da8"),
// Properties: &armpolicyinsights.RemediationProperties{
// CorrelationID: to.Ptr("957378d3-a143-421e-8b0e-3048dff01932"),
// CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:49:16.463Z"); return t}()),
// DeploymentStatus: &armpolicyinsights.RemediationDeploymentSummary{
// FailedDeployments: to.Ptr[int32](0),
// SuccessfulDeployments: to.Ptr[int32](2),
// TotalDeployments: to.Ptr[int32](2),
// },
// LastUpdatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:50:18.464Z"); return t}()),
// PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"),
// PolicyDefinitionReferenceID: to.Ptr("storageSkuDef"),
// ProvisioningState: to.Ptr("Succeeded"),
// ResourceDiscoveryMode: to.Ptr(armpolicyinsights.ResourceDiscoveryModeExistingNonCompliant),
// StatusMessage: to.Ptr("Remediation extended status"),
// },
// SystemData: &armpolicyinsights.SystemData{
// CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:49:16.463Z"); return t}()),
// CreatedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"),
// CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser),
// LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T21:50:18.464Z"); return t}()),
// LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"),
// LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser),
// },
// }},
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { PolicyInsightsClient } = require("@azure/arm-policyinsights");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Gets all remediations for the subscription.
*
* @summary Gets all remediations for the subscription.
* x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListSubscriptionScope_WithQuery.json
*/
async function listRemediationsAtSubscriptionScopeWithQueryParameters() {
const subscriptionId =
process.env["POLICYINSIGHTS_SUBSCRIPTION_ID"] || "35ee058e-5fa0-414c-8145-3ebb8d09b6e2";
const top = 1;
const filter =
"PolicyAssignmentId eq '/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5' AND PolicyDefinitionReferenceId eq 'storageSkuDef'";
const options = {
queryOptions: { top: top, filter: filter },
};
const credential = new DefaultAzureCredential();
const client = new PolicyInsightsClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.remediations.listForSubscription(options)) {
resArray.push(item);
}
console.log(resArray);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"properties": {
"policyAssignmentId": "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5",
"policyDefinitionReferenceId": "storageSkuDef",
"provisioningState": "Succeeded",
"createdOn": "2018-09-13T21:51:09.075918Z",
"lastUpdatedOn": "2018-09-13T21:52:10.0011706Z",
"resourceDiscoveryMode": "ExistingNonCompliant",
"deploymentStatus": {
"totalDeployments": 2,
"successfulDeployments": 2,
"failedDeployments": 0
},
"statusMessage": "Remediation extended status",
"correlationId": "a14e1d60-dae9-4771-b4be-a556d69e77a6",
"resourceCount": 42,
"parallelDeployments": 6,
"failureThreshold": {
"percentage": 0.1
}
},
"id": "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.policyinsights/remediations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e",
"name": "790996e6-9871-4b1f-9cd9-ec42cd6ced1e",
"type": "Microsoft.PolicyInsights/remediations",
"systemData": {
"createdBy": "b69a9388-9488-4534-b470-7ec6d41beef6",
"createdByType": "User",
"createdAt": "2018-09-13T21:49:16.4638131Z",
"lastModifiedBy": "b69a9388-9488-4534-b470-7ec6d41beef6",
"lastModifiedByType": "User",
"lastModifiedAt": "2018-09-13T21:50:18.4647478Z"
}
},
{
"properties": {
"policyAssignmentId": "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5",
"policyDefinitionReferenceId": "storageSkuDef",
"provisioningState": "Succeeded",
"createdOn": "2018-09-13T21:49:16.4638131Z",
"lastUpdatedOn": "2018-09-13T21:50:18.4647478Z",
"resourceDiscoveryMode": "ExistingNonCompliant",
"deploymentStatus": {
"totalDeployments": 2,
"successfulDeployments": 2,
"failedDeployments": 0
},
"statusMessage": "Remediation extended status",
"correlationId": "957378d3-a143-421e-8b0e-3048dff01932"
},
"id": "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/rg2/providers/microsoft.policyinsights/remediations/0866f0cc-6cb3-422c-9fb6-a4e3e2266da8",
"name": "0866f0cc-6cb3-422c-9fb6-a4e3e2266da8",
"type": "Microsoft.PolicyInsights/remediations",
"systemData": {
"createdBy": "b69a9388-9488-4534-b470-7ec6d41beef6",
"createdByType": "User",
"createdAt": "2018-09-13T21:49:16.4638131Z",
"lastModifiedBy": "b69a9388-9488-4534-b470-7ec6d41beef6",
"lastModifiedByType": "User",
"lastModifiedAt": "2018-09-13T21:50:18.4647478Z"
}
}
]
}
Definitions
createdByType
The type of identity that created the resource.
Name |
Type |
Description |
Application
|
string
|
|
Key
|
string
|
|
ManagedIdentity
|
string
|
|
User
|
string
|
|
ErrorDefinition
Error definition.
Name |
Type |
Description |
additionalInfo
|
TypedErrorInfo[]
|
Additional scenario specific error details.
|
code
|
string
|
Service specific error code which serves as the substatus for the HTTP error code.
|
details
|
ErrorDefinition[]
|
Internal error details.
|
message
|
string
|
Description of the error.
|
target
|
string
|
The target of the error.
|
ErrorResponse
Error response.
FailureThreshold
The remediation failure threshold settings
Name |
Type |
Description |
percentage
|
number
|
A number between 0.0 to 1.0 representing the percentage failure threshold. The remediation will fail if the percentage of failed remediation operations (i.e. failed deployments) exceeds this threshold.
|
The remediation definition.
Name |
Type |
Description |
id
|
string
|
The ID of the remediation.
|
name
|
string
|
The name of the remediation.
|
properties.correlationId
|
string
|
The remediation correlation Id. Can be used to find events related to the remediation in the activity log.
|
properties.createdOn
|
string
|
The time at which the remediation was created.
|
properties.deploymentStatus
|
RemediationDeploymentSummary
|
The deployment status summary for all deployments created by the remediation.
|
properties.failureThreshold
|
FailureThreshold
|
The remediation failure threshold settings
|
properties.filters
|
RemediationFilters
|
The filters that will be applied to determine which resources to remediate.
|
properties.lastUpdatedOn
|
string
|
The time at which the remediation was last updated.
|
properties.parallelDeployments
|
integer
|
Determines how many resources to remediate at any given time. Can be used to increase or reduce the pace of the remediation. If not provided, the default parallel deployments value is used.
|
properties.policyAssignmentId
|
string
|
The resource ID of the policy assignment that should be remediated.
|
properties.policyDefinitionReferenceId
|
string
|
The policy definition reference ID of the individual definition that should be remediated. Required when the policy assignment being remediated assigns a policy set definition.
|
properties.provisioningState
|
string
|
The status of the remediation. This refers to the entire remediation task, not individual deployments. Allowed values are Evaluating, Canceled, Cancelling, Failed, Complete, or Succeeded.
|
properties.resourceCount
|
integer
|
Determines the max number of resources that can be remediated by the remediation job. If not provided, the default resource count is used.
|
properties.resourceDiscoveryMode
|
ResourceDiscoveryMode
|
The way resources to remediate are discovered. Defaults to ExistingNonCompliant if not specified.
|
properties.statusMessage
|
string
|
The remediation status message. Provides additional details regarding the state of the remediation.
|
systemData
|
systemData
|
Azure Resource Manager metadata containing createdBy and modifiedBy information.
|
type
|
string
|
The type of the remediation.
|
The deployment status summary for all deployments created by the remediation.
Name |
Type |
Description |
failedDeployments
|
integer
|
The number of deployments required by the remediation that have failed.
|
successfulDeployments
|
integer
|
The number of deployments required by the remediation that have succeeded.
|
totalDeployments
|
integer
|
The number of deployments required by the remediation.
|
The filters that will be applied to determine which resources to remediate.
Name |
Type |
Description |
locations
|
string[]
|
The resource locations that will be remediated.
|
List of remediations.
Name |
Type |
Description |
nextLink
|
string
|
The URL to get the next set of results.
|
value
|
Remediation[]
|
Array of remediation definitions.
|
ResourceDiscoveryMode
The way resources to remediate are discovered. Defaults to ExistingNonCompliant if not specified.
Name |
Type |
Description |
ExistingNonCompliant
|
string
|
Remediate resources that are already known to be non-compliant.
|
ReEvaluateCompliance
|
string
|
Re-evaluate the compliance state of resources and then remediate the resources found to be non-compliant.
|
systemData
Metadata pertaining to creation and last modification of the resource.
Name |
Type |
Description |
createdAt
|
string
|
The timestamp of resource creation (UTC).
|
createdBy
|
string
|
The identity that created the resource.
|
createdByType
|
createdByType
|
The type of identity that created the resource.
|
lastModifiedAt
|
string
|
The timestamp of resource last modification (UTC)
|
lastModifiedBy
|
string
|
The identity that last modified the resource.
|
lastModifiedByType
|
createdByType
|
The type of identity that last modified the resource.
|
TypedErrorInfo
Scenario specific error details.
Name |
Type |
Description |
info
|
|
The scenario specific error details.
|
type
|
string
|
The type of included error details.
|