Ruft alle Nachweise für eine Ressource ab.
GET https://management.azure.com/{resourceId}/providers/Microsoft.PolicyInsights/attestations?api-version=2022-09-01
With optional parameters:
GET https://management.azure.com/{resourceId}/providers/Microsoft.PolicyInsights/attestations?$top={$top}&$filter={$filter}&api-version=2022-09-01
URI-Parameter
Name |
In |
Erforderlich |
Typ |
Beschreibung |
resourceId
|
path |
True
|
string
|
Ressourcen-ID
|
api-version
|
query |
True
|
string
|
Hierbei handelt es sich um die für diesen Vorgang zu verwendende API-Version.
|
$filter
|
query |
|
string
|
OData-Filterausdruck.
|
$top
|
query |
|
integer
int32
|
Maximale Anzahl von zurückzugebenden Datensätzen.
|
Antworten
Sicherheit
azure_auth
Azure Active Directory-OAuth2-Flow
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Name |
Beschreibung |
user_impersonation
|
Identitätswechsel Ihres Benutzerkontos
|
Beispiele
List attestations at individual resource scope
Sample Request
GET https://management.azure.com/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM/providers/Microsoft.PolicyInsights/attestations?api-version=2022-09-01
import com.azure.core.util.Context;
/** Samples for Attestations ListForResource. */
public final class Main {
/*
* x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_ListResourceScope.json
*/
/**
* Sample code: List attestations at individual resource scope.
*
* @param manager Entry point to PolicyInsightsManager.
*/
public static void listAttestationsAtIndividualResourceScope(
com.azure.resourcemanager.policyinsights.PolicyInsightsManager manager) {
manager
.attestations()
.listForResource(
"subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM",
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 attestations_list_resource_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="SUBSCRIPTION_ID",
)
response = client.attestations.list_for_resource(
resource_id="subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM",
)
for item in response:
print(item)
# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_ListResourceScope.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/2022-09-01/examples/Attestations_ListResourceScope.json
func ExampleAttestationsClient_NewListForResourcePager_listAttestationsAtIndividualResourceScope() {
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.NewAttestationsClient().NewListForResourcePager("subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM", &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.AttestationListResult = armpolicyinsights.AttestationListResult{
// Value: []*armpolicyinsights.Attestation{
// {
// Name: to.Ptr("790996e6-9871-4b1f-9cd9-ec42cd6ced1e"),
// Type: to.Ptr("Microsoft.PolicyInsights/attestations"),
// ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM/providers/microsoft.policyinsights/attestations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e"),
// Properties: &armpolicyinsights.AttestationProperties{
// AssessmentDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-10T00:00:00.000Z"); return t}()),
// Comments: to.Ptr("This subscription has passed a security audit."),
// ComplianceState: to.Ptr(armpolicyinsights.ComplianceStateCompliant),
// Evidence: []*armpolicyinsights.AttestationEvidence{
// {
// Description: to.Ptr("The results of the security audit."),
// SourceURI: to.Ptr("https://gist.github.com/contoso/9573e238762c60166c090ae16b814011"),
// }},
// ExpiresOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-15T00:00:00.000Z"); return t}()),
// LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()),
// Metadata: map[string]any{
// "departmentId": "NYC-MARKETING-1",
// },
// Owner: to.Ptr("55a32e28-3aa5-4eea-9b5a-4cd85153b966"),
// PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"),
// PolicyDefinitionReferenceID: to.Ptr("0b158b46-ff42-4799-8e39-08a5c23b4551"),
// ProvisioningState: to.Ptr("Succeeded"),
// },
// SystemData: &armpolicyinsights.SystemData{
// CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); 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, "2020-06-15T18:52:27.000Z"); return t}()),
// LastModifiedBy: to.Ptr("b69a9388-9488-4534-b470-7ec6d41beef6"),
// LastModifiedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser),
// },
// },
// {
// Name: to.Ptr("689bfc0c-a012-49fc-af40-3ebea35ff3ed"),
// Type: to.Ptr("Microsoft.PolicyInsights/attestations"),
// ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM/providers/microsoft.policyinsights/attestations/689bfc0c-a012-49fc-af40-3ebea35ff3ed"),
// Properties: &armpolicyinsights.AttestationProperties{
// ComplianceState: to.Ptr(armpolicyinsights.ComplianceStateCompliant),
// LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()),
// PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/090a47f8-13e9-441e-ad90-dc666cc5d487"),
// ProvisioningState: to.Ptr("Succeeded"),
// },
// SystemData: &armpolicyinsights.SystemData{
// CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()),
// CreatedBy: to.Ptr("34709f31-f267-4eee-8479-0da11925f2f2"),
// CreatedByType: to.Ptr(armpolicyinsights.CreatedByTypeUser),
// LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()),
// LastModifiedBy: to.Ptr("34709f31-f267-4eee-8479-0da11925f2f2"),
// 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 attestations for a resource.
*
* @summary Gets all attestations for a resource.
* x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_ListResourceScope.json
*/
async function listAttestationsAtIndividualResourceScope() {
const subscriptionId =
process.env["POLICYINSIGHTS_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceId =
"subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM";
const credential = new DefaultAzureCredential();
const client = new PolicyInsightsClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.attestations.listForResource(resourceId)) {
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
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.PolicyInsights;
using Azure.ResourceManager.PolicyInsights.Models;
// Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_ListResourceScope.json
// this example is just showing the usage of "Attestations_ListForResource" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ArmResource created on azure
// for more information of creating ArmResource, please refer to the document of ArmResource
// get the collection of this PolicyAttestationResource
string resourceId = "subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM";
ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId));
PolicyAttestationCollection collection = client.GetPolicyAttestations(scopeId);
// invoke the operation and iterate over the result
await foreach (PolicyAttestationResource item in collection.GetAllAsync())
{
// the variable item is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
PolicyAttestationData resourceData = item.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
}
Console.WriteLine($"Succeeded");
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": "0b158b46-ff42-4799-8e39-08a5c23b4551",
"complianceState": "Compliant",
"lastComplianceStateChangeAt": "2020-06-15T18:52:27Z",
"expiresOn": "2021-06-15T00:00:00Z",
"owner": "55a32e28-3aa5-4eea-9b5a-4cd85153b966",
"comments": "This subscription has passed a security audit.",
"evidence": [
{
"description": "The results of the security audit.",
"sourceUri": "https://gist.github.com/contoso/9573e238762c60166c090ae16b814011"
}
],
"assessmentDate": "2021-06-10T00:00:00Z",
"metadata": {
"departmentId": "NYC-MARKETING-1"
},
"provisioningState": "Succeeded"
},
"systemData": {
"createdBy": "b69a9388-9488-4534-b470-7ec6d41beef6",
"createdByType": "User",
"createdAt": "2020-06-15T18:52:27Z",
"lastModifiedBy": "b69a9388-9488-4534-b470-7ec6d41beef6",
"lastModifiedByType": "User",
"lastModifiedAt": "2020-06-15T18:52:27Z"
},
"id": "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM/providers/microsoft.policyinsights/attestations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e",
"name": "790996e6-9871-4b1f-9cd9-ec42cd6ced1e",
"type": "Microsoft.PolicyInsights/attestations"
},
{
"properties": {
"policyAssignmentId": "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/090a47f8-13e9-441e-ad90-dc666cc5d487",
"complianceState": "Compliant",
"lastComplianceStateChangeAt": "2020-06-15T18:52:27Z",
"provisioningState": "Succeeded"
},
"systemData": {
"createdBy": "34709f31-f267-4eee-8479-0da11925f2f2",
"createdByType": "User",
"createdAt": "2020-06-15T18:52:27Z",
"lastModifiedBy": "34709f31-f267-4eee-8479-0da11925f2f2",
"lastModifiedByType": "User",
"lastModifiedAt": "2020-06-15T18:52:27Z"
},
"id": "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM/providers/microsoft.policyinsights/attestations/689bfc0c-a012-49fc-af40-3ebea35ff3ed",
"name": "689bfc0c-a012-49fc-af40-3ebea35ff3ed",
"type": "Microsoft.PolicyInsights/attestations"
}
]
}
List attestations at individual resource scope with query parameters
Sample Request
GET https://management.azure.com/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM/providers/Microsoft.PolicyInsights/attestations?$top=1&$filter=PolicyAssignmentId eq '/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5' AND PolicyDefinitionReferenceId eq '0b158b46-ff42-4799-8e39-08a5c23b4551'&api-version=2022-09-01
import com.azure.core.util.Context;
/** Samples for Attestations ListForResource. */
public final class Main {
/*
* x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_ListResourceScope_WithQuery.json
*/
/**
* Sample code: List attestations at individual resource scope with query parameters.
*
* @param manager Entry point to PolicyInsightsManager.
*/
public static void listAttestationsAtIndividualResourceScopeWithQueryParameters(
com.azure.resourcemanager.policyinsights.PolicyInsightsManager manager) {
manager
.attestations()
.listForResource(
"subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM",
1,
"PolicyAssignmentId eq"
+ " '/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5'"
+ " AND PolicyDefinitionReferenceId eq '0b158b46-ff42-4799-8e39-08a5c23b4551'",
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 attestations_list_resource_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="SUBSCRIPTION_ID",
)
response = client.attestations.list_for_resource(
resource_id="subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM",
)
for item in response:
print(item)
# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_ListResourceScope_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/2022-09-01/examples/Attestations_ListResourceScope_WithQuery.json
func ExampleAttestationsClient_NewListForResourcePager_listAttestationsAtIndividualResourceScopeWithQueryParameters() {
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.NewAttestationsClient().NewListForResourcePager("subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM", &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 '0b158b46-ff42-4799-8e39-08a5c23b4551'"),
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.AttestationListResult = armpolicyinsights.AttestationListResult{
// Value: []*armpolicyinsights.Attestation{
// {
// Name: to.Ptr("790996e6-9871-4b1f-9cd9-ec42cd6ced1e"),
// Type: to.Ptr("Microsoft.PolicyInsights/attestations"),
// ID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM/providers/microsoft.policyinsights/attestations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e"),
// Properties: &armpolicyinsights.AttestationProperties{
// AssessmentDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-10T00:00:00.000Z"); return t}()),
// Comments: to.Ptr("This subscription has passed a security audit."),
// ComplianceState: to.Ptr(armpolicyinsights.ComplianceStateCompliant),
// Evidence: []*armpolicyinsights.AttestationEvidence{
// {
// Description: to.Ptr("The results of the security audit."),
// SourceURI: to.Ptr("https://gist.github.com/contoso/9573e238762c60166c090ae16b814011"),
// }},
// ExpiresOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-15T00:00:00.000Z"); return t}()),
// LastComplianceStateChangeAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); return t}()),
// Metadata: map[string]any{
// "departmentId": "NYC-MARKETING-1",
// },
// Owner: to.Ptr("55a32e28-3aa5-4eea-9b5a-4cd85153b966"),
// PolicyAssignmentID: to.Ptr("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"),
// PolicyDefinitionReferenceID: to.Ptr("0b158b46-ff42-4799-8e39-08a5c23b4551"),
// ProvisioningState: to.Ptr("Succeeded"),
// },
// SystemData: &armpolicyinsights.SystemData{
// CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-15T18:52:27.000Z"); 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, "2020-06-15T18:52:27.000Z"); 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 attestations for a resource.
*
* @summary Gets all attestations for a resource.
* x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_ListResourceScope_WithQuery.json
*/
async function listAttestationsAtIndividualResourceScopeWithQueryParameters() {
const subscriptionId =
process.env["POLICYINSIGHTS_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceId =
"subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM";
const top = 1;
const filter =
"PolicyAssignmentId eq '/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5' AND PolicyDefinitionReferenceId eq '0b158b46-ff42-4799-8e39-08a5c23b4551'";
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.attestations.listForResource(resourceId, 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
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.PolicyInsights;
using Azure.ResourceManager.PolicyInsights.Models;
// Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_ListResourceScope_WithQuery.json
// this example is just showing the usage of "Attestations_ListForResource" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ArmResource created on azure
// for more information of creating ArmResource, please refer to the document of ArmResource
// get the collection of this PolicyAttestationResource
string resourceId = "subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM";
ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId));
PolicyAttestationCollection collection = client.GetPolicyAttestations(scopeId);
// invoke the operation and iterate over the result
await foreach (PolicyAttestationResource item in collection.GetAllAsync())
{
// the variable item is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
PolicyAttestationData resourceData = item.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
}
Console.WriteLine($"Succeeded");
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": "0b158b46-ff42-4799-8e39-08a5c23b4551",
"complianceState": "Compliant",
"lastComplianceStateChangeAt": "2020-06-15T18:52:27Z",
"expiresOn": "2021-06-15T00:00:00Z",
"owner": "55a32e28-3aa5-4eea-9b5a-4cd85153b966",
"comments": "This subscription has passed a security audit.",
"evidence": [
{
"description": "The results of the security audit.",
"sourceUri": "https://gist.github.com/contoso/9573e238762c60166c090ae16b814011"
}
],
"assessmentDate": "2021-06-10T00:00:00Z",
"metadata": {
"departmentId": "NYC-MARKETING-1"
},
"provisioningState": "Succeeded"
},
"systemData": {
"createdBy": "b69a9388-9488-4534-b470-7ec6d41beef6",
"createdByType": "User",
"createdAt": "2020-06-15T18:52:27Z",
"lastModifiedBy": "b69a9388-9488-4534-b470-7ec6d41beef6",
"lastModifiedByType": "User",
"lastModifiedAt": "2020-06-15T18:52:27Z"
},
"id": "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM/providers/microsoft.policyinsights/attestations/790996e6-9871-4b1f-9cd9-ec42cd6ced1e",
"name": "790996e6-9871-4b1f-9cd9-ec42cd6ced1e",
"type": "Microsoft.PolicyInsights/attestations"
}
]
}
Definitionen
Attestation
Eine Nachweisressource.
Name |
Typ |
Beschreibung |
id
|
string
|
Vollqualifizierte Ressourcen-ID für die Ressource. Beispiel: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
name
|
string
|
Der Name der Ressource
|
properties.assessmentDate
|
string
|
Der Zeitpunkt der Beweiswürdigung
|
properties.comments
|
string
|
Kommentare, die beschreiben, warum dieser Nachweis erstellt wurde.
|
properties.complianceState
|
ComplianceState
|
Der Konformitätszustand, der für die Ressource festgelegt werden soll.
|
properties.evidence
|
AttestationEvidence[]
|
Der Nachweis, der den in diesem Nachweis festgelegten Konformitätszustand unterstützt.
|
properties.expiresOn
|
string
|
Der Zeitpunkt, zu dem der Konformitätszustand abläuft.
|
properties.lastComplianceStateChangeAt
|
string
|
Der Zeitpunkt, zu dem der Konformitätszustand zuletzt in diesem Nachweis geändert wurde.
|
properties.metadata
|
object
|
Zusätzliche Metadaten für diesen Nachweis
|
properties.owner
|
string
|
Die Person, die für das Festlegen des Zustands der Ressource verantwortlich ist. Dieser Wert ist in der Regel eine Azure Active Directory-Objekt-ID.
|
properties.policyAssignmentId
|
string
|
Die Ressourcen-ID der Richtlinienzuweisung, für die der Nachweis den Status festlegt.
|
properties.policyDefinitionReferenceId
|
string
|
Die Richtliniendefinitions-Referenz-ID aus einer Richtliniensatzdefinition, für die der Nachweis den Status festlegt. Wenn die Richtlinienzuweisung eine Richtliniensatzdefinition zuweist, kann der Nachweis eine Definition innerhalb der Setdefinition mit dieser Eigenschaft auswählen oder diese auslassen und den Zustand für die gesamte Mengendefinition festlegen.
|
properties.provisioningState
|
string
|
Die status des Nachweises.
|
systemData
|
systemData
|
Azure Resource Manager-Metadaten mit createdBy- und modifiedBy-Informationen.
|
type
|
string
|
Der Typ der Ressource. Z.B. "Microsoft.Compute/virtualMachines" oder "Microsoft.Storage/storageAccounts"
|
AttestationEvidence
Ein Beweis, der den im Nachweis festgelegten Konformitätsstatus unterstützt.
Name |
Typ |
Beschreibung |
description
|
string
|
Die Beschreibung dieses Beweisstücks.
|
sourceUri
|
string
|
Der URI-Speicherort des Beweiss.
|
AttestationListResult
Liste der Nachweise.
Name |
Typ |
Beschreibung |
nextLink
|
string
|
Die URL zum Abrufen des nächsten Resultsets.
|
value
|
Attestation[]
|
Array von Nachweisdefinitionen.
|
ComplianceState
Der Konformitätszustand, der für die Ressource festgelegt werden soll.
Name |
Typ |
Beschreibung |
Compliant
|
string
|
Die Ressource entspricht der Richtlinie.
|
NonCompliant
|
string
|
Die Ressource entspricht nicht der Richtlinie.
|
Unknown
|
string
|
Der Konformitätsstatus der Ressource ist nicht bekannt.
|
createdByType
Der Identitätstyp, der die Ressource erstellt hat.
Name |
Typ |
Beschreibung |
Application
|
string
|
|
Key
|
string
|
|
ManagedIdentity
|
string
|
|
User
|
string
|
|
ErrorDefinition
Fehlerdefinition.
Name |
Typ |
Beschreibung |
additionalInfo
|
TypedErrorInfo[]
|
Zusätzliche szenariospezifische Fehlerdetails.
|
code
|
string
|
Dienstspezifischer Fehlercode, der als Unterstatus für den HTTP-Fehlercode dient.
|
details
|
ErrorDefinition[]
|
Interne Fehlerdetails.
|
message
|
string
|
Beschreibung des Fehlers
|
target
|
string
|
Das Ziel des Fehlers.
|
ErrorResponse
Fehlerantwort.
systemData
Metadaten, die sich auf die Erstellung und letzte Änderung der Ressource beziehen.
Name |
Typ |
Beschreibung |
createdAt
|
string
|
Der Zeitstempel der Ressourcenerstellung (UTC).
|
createdBy
|
string
|
Die Identität, die die Ressource erstellt hat.
|
createdByType
|
createdByType
|
Der Identitätstyp, der die Ressource erstellt hat.
|
lastModifiedAt
|
string
|
Der Zeitstempel der letzten Änderung der Ressource (UTC)
|
lastModifiedBy
|
string
|
Die Identität, die die Ressource zuletzt geändert hat.
|
lastModifiedByType
|
createdByType
|
Der Identitätstyp, der die Ressource zuletzt geändert hat.
|
TypedErrorInfo
Szenariospezifische Fehlerdetails.
Name |
Typ |
Beschreibung |
info
|
|
Die szenariospezifischen Fehlerdetails.
|
type
|
string
|
Der Typ der enthaltenen Fehlerdetails.
|