ポリシーの割り当てを取得します。
この操作では、名前と作成されたスコープを指定して、1 つのポリシー割り当てを取得します。
GET https://management.azure.com/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}?api-version=2023-04-01
省略可能なパラメーターを含む:
GET https://management.azure.com/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}?$expand={$expand}&api-version=2023-04-01
URI パラメーター
名前 |
/ |
必須 |
型 |
説明 |
policyAssignmentName
|
path |
True
|
string
pattern: ^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$
|
取得するポリシー割り当ての名前。
|
scope
|
path |
True
|
string
|
ポリシー割り当てのスコープ。 有効なスコープは、管理グループ (形式: '/providers/Microsoft.Management/managementGroups/{managementGroup}')、サブスクリプション (形式: '/subscriptions/{subscriptionId}')、リソース グループ (形式: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}') です。 またはリソース (形式: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'
|
api-version
|
query |
True
|
string
minLength: 1
|
この操作に使用する API バージョン。
|
$expand
|
query |
|
string
|
応答に含める追加プロパティのコンマ区切りの一覧。 サポートされている値は 'LatestDefinitionVersion, EffectiveDefinitionVersion' です。
|
応答
セキュリティ
azure_auth
Azure Active Directory OAuth2 フロー。
型:
oauth2
フロー:
implicit
Authorization URL (承認 URL):
https://login.microsoftonline.com/common/oauth2/authorize
スコープ
名前 |
説明 |
user_impersonation
|
ユーザー アカウントを偽装する
|
例
Retrieve a policy assignment
要求のサンプル
GET https://management.azure.com/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming?api-version=2023-04-01
/**
* Samples for PolicyAssignments Get.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyAssignment.
* json
*/
/**
* Sample code: Retrieve a policy assignment.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void retrieveAPolicyAssignment(com.azure.resourcemanager.AzureResourceManager azure) {
azure.genericResources().manager().policyClient().getPolicyAssignments().getWithResponse(
"subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", null,
com.azure.core.util.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
package armpolicy_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyAssignment.json
func ExampleAssignmentsClient_Get_retrieveAPolicyAssignment() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpolicy.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewAssignmentsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", &armpolicy.AssignmentsClientGetOptions{Expand: nil})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Assignment = armpolicy.Assignment{
// Name: to.Ptr("EnforceNaming"),
// Type: to.Ptr("Microsoft.Authorization/policyAssignments"),
// ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming"),
// Properties: &armpolicy.AssignmentProperties{
// Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"),
// DefinitionVersion: to.Ptr("1.*.*"),
// DisplayName: to.Ptr("Enforce resource naming rules"),
// EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault),
// Metadata: map[string]any{
// "assignedBy": "Special Someone",
// },
// NotScopes: []*string{
// },
// Parameters: map[string]*armpolicy.ParameterValuesValue{
// "prefix": &armpolicy.ParameterValuesValue{
// Value: "DeptA",
// },
// "suffix": &armpolicy.ParameterValuesValue{
// Value: "-LC",
// },
// },
// PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
// Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { PolicyClient } = require("@azure/arm-policy");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at.
*
* @summary This operation retrieves a single policy assignment, given its name and the scope it was created at.
* x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyAssignment.json
*/
async function retrieveAPolicyAssignment() {
const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2";
const policyAssignmentName = "EnforceNaming";
const credential = new DefaultAzureCredential();
const client = new PolicyClient(credential);
const result = await client.policyAssignments.get(scope, policyAssignmentName);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
応答のサンプル
{
"properties": {
"displayName": "Enforce resource naming rules",
"description": "Force resource names to begin with given DeptA and end with -LC",
"metadata": {
"assignedBy": "Special Someone"
},
"policyDefinitionId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming",
"definitionVersion": "1.*.*",
"notScopes": [],
"parameters": {
"prefix": {
"value": "DeptA"
},
"suffix": {
"value": "-LC"
}
},
"enforcementMode": "Default",
"scope": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"
},
"id": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming",
"type": "Microsoft.Authorization/policyAssignments",
"name": "EnforceNaming"
}
Retrieve a policy assignment with a system assigned identity
要求のサンプル
GET https://management.azure.com/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming?api-version=2023-04-01
/**
* Samples for PolicyAssignments Get.
*/
public final class Main {
/*
* x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/
* getPolicyAssignmentWithIdentity.json
*/
/**
* Sample code: Retrieve a policy assignment with a system assigned identity.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
retrieveAPolicyAssignmentWithASystemAssignedIdentity(com.azure.resourcemanager.AzureResourceManager azure) {
azure.genericResources().manager().policyClient().getPolicyAssignments().getWithResponse(
"subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", null,
com.azure.core.util.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
package armpolicy_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyAssignmentWithIdentity.json
func ExampleAssignmentsClient_Get_retrieveAPolicyAssignmentWithASystemAssignedIdentity() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpolicy.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewAssignmentsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", &armpolicy.AssignmentsClientGetOptions{Expand: nil})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Assignment = armpolicy.Assignment{
// Name: to.Ptr("EnforceNaming"),
// Type: to.Ptr("Microsoft.Authorization/policyAssignments"),
// ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming"),
// Identity: &armpolicy.Identity{
// Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned),
// PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"),
// TenantID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"),
// },
// Location: to.Ptr("westus"),
// Properties: &armpolicy.AssignmentProperties{
// Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"),
// DefinitionVersion: to.Ptr("1.*.*"),
// DisplayName: to.Ptr("Enforce resource naming rules"),
// EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault),
// Metadata: map[string]any{
// "assignedBy": "Special Someone",
// },
// NotScopes: []*string{
// },
// Parameters: map[string]*armpolicy.ParameterValuesValue{
// "prefix": &armpolicy.ParameterValuesValue{
// Value: "DeptA",
// },
// "suffix": &armpolicy.ParameterValuesValue{
// Value: "-LC",
// },
// },
// PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
// Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { PolicyClient } = require("@azure/arm-policy");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at.
*
* @summary This operation retrieves a single policy assignment, given its name and the scope it was created at.
* x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyAssignmentWithIdentity.json
*/
async function retrieveAPolicyAssignmentWithASystemAssignedIdentity() {
const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2";
const policyAssignmentName = "EnforceNaming";
const credential = new DefaultAzureCredential();
const client = new PolicyClient(credential);
const result = await client.policyAssignments.get(scope, policyAssignmentName);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
応答のサンプル
{
"properties": {
"displayName": "Enforce resource naming rules",
"description": "Force resource names to begin with given DeptA and end with -LC",
"metadata": {
"assignedBy": "Special Someone"
},
"policyDefinitionId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming",
"definitionVersion": "1.*.*",
"notScopes": [],
"parameters": {
"prefix": {
"value": "DeptA"
},
"suffix": {
"value": "-LC"
}
},
"enforcementMode": "Default",
"scope": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"
},
"identity": {
"type": "SystemAssigned",
"principalId": "e6d23f8d-af97-4fbc-bda6-00604e4e3d0a",
"tenantId": "4bee2b8a-1bee-47c2-90e9-404241551135"
},
"location": "westus",
"id": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming",
"type": "Microsoft.Authorization/policyAssignments",
"name": "EnforceNaming"
}
Retrieve a policy assignment with a user assigned identity
要求のサンプル
GET https://management.azure.com/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming?api-version=2023-04-01
/**
* Samples for PolicyAssignments Get.
*/
public final class Main {
/*
* x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/
* getPolicyAssignmentWithUserAssignedIdentity.json
*/
/**
* Sample code: Retrieve a policy assignment with a user assigned identity.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
retrieveAPolicyAssignmentWithAUserAssignedIdentity(com.azure.resourcemanager.AzureResourceManager azure) {
azure.genericResources().manager().policyClient().getPolicyAssignments().getWithResponse(
"subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", null,
com.azure.core.util.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
package armpolicy_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyAssignmentWithUserAssignedIdentity.json
func ExampleAssignmentsClient_Get_retrieveAPolicyAssignmentWithAUserAssignedIdentity() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpolicy.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewAssignmentsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", &armpolicy.AssignmentsClientGetOptions{Expand: nil})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Assignment = armpolicy.Assignment{
// Name: to.Ptr("EnforceNaming"),
// Type: to.Ptr("Microsoft.Authorization/policyAssignments"),
// ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming"),
// Identity: &armpolicy.Identity{
// Type: to.Ptr(armpolicy.ResourceIdentityTypeUserAssigned),
// UserAssignedIdentities: map[string]*armpolicy.UserAssignedIdentitiesValue{
// "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": &armpolicy.UserAssignedIdentitiesValue{
// ClientID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"),
// PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"),
// },
// },
// },
// Location: to.Ptr("westus"),
// Properties: &armpolicy.AssignmentProperties{
// Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"),
// DefinitionVersion: to.Ptr("1.*.*"),
// DisplayName: to.Ptr("Enforce resource naming rules"),
// EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault),
// Metadata: map[string]any{
// "assignedBy": "Special Someone",
// },
// NotScopes: []*string{
// },
// Parameters: map[string]*armpolicy.ParameterValuesValue{
// "prefix": &armpolicy.ParameterValuesValue{
// Value: "DeptA",
// },
// "suffix": &armpolicy.ParameterValuesValue{
// Value: "-LC",
// },
// },
// PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"),
// Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { PolicyClient } = require("@azure/arm-policy");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at.
*
* @summary This operation retrieves a single policy assignment, given its name and the scope it was created at.
* x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyAssignmentWithUserAssignedIdentity.json
*/
async function retrieveAPolicyAssignmentWithAUserAssignedIdentity() {
const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2";
const policyAssignmentName = "EnforceNaming";
const credential = new DefaultAzureCredential();
const client = new PolicyClient(credential);
const result = await client.policyAssignments.get(scope, policyAssignmentName);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
応答のサンプル
{
"properties": {
"displayName": "Enforce resource naming rules",
"description": "Force resource names to begin with given DeptA and end with -LC",
"metadata": {
"assignedBy": "Special Someone"
},
"policyDefinitionId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming",
"definitionVersion": "1.*.*",
"notScopes": [],
"parameters": {
"prefix": {
"value": "DeptA"
},
"suffix": {
"value": "-LC"
}
},
"enforcementMode": "Default",
"scope": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"
},
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": {
"principalId": "e6d23f8d-af97-4fbc-bda6-00604e4e3d0a",
"clientId": "4bee2b8a-1bee-47c2-90e9-404241551135"
}
}
},
"location": "westus",
"id": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming",
"type": "Microsoft.Authorization/policyAssignments",
"name": "EnforceNaming"
}
Retrieve a policy assignment with overrides
要求のサンプル
GET https://management.azure.com/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement?api-version=2023-04-01
/**
* Samples for PolicyAssignments Get.
*/
public final class Main {
/*
* x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/
* getPolicyAssignmentWithOverrides.json
*/
/**
* Sample code: Retrieve a policy assignment with overrides.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void retrieveAPolicyAssignmentWithOverrides(com.azure.resourcemanager.AzureResourceManager azure) {
azure.genericResources().manager().policyClient().getPolicyAssignments().getWithResponse(
"subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "CostManagement", null,
com.azure.core.util.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
package armpolicy_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyAssignmentWithOverrides.json
func ExampleAssignmentsClient_Get_retrieveAPolicyAssignmentWithOverrides() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpolicy.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewAssignmentsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "CostManagement", &armpolicy.AssignmentsClientGetOptions{Expand: nil})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Assignment = armpolicy.Assignment{
// Name: to.Ptr("CostManagement"),
// Type: to.Ptr("Microsoft.Authorization/policyAssignments"),
// ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"),
// Properties: &armpolicy.AssignmentProperties{
// Description: to.Ptr("Limit the resource location and resource SKU"),
// DefinitionVersion: to.Ptr("1.*.*"),
// DisplayName: to.Ptr("Limit the resource location and resource SKU"),
// EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault),
// Metadata: map[string]any{
// "assignedBy": "Special Someone",
// },
// NotScopes: []*string{
// },
// Overrides: []*armpolicy.Override{
// {
// Kind: to.Ptr(armpolicy.OverrideKindPolicyEffect),
// Selectors: []*armpolicy.Selector{
// {
// In: []*string{
// to.Ptr("Limit_Skus"),
// to.Ptr("Limit_Locations")},
// Kind: to.Ptr(armpolicy.SelectorKindPolicyDefinitionReferenceID),
// }},
// Value: to.Ptr("Audit"),
// }},
// PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"),
// Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { PolicyClient } = require("@azure/arm-policy");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at.
*
* @summary This operation retrieves a single policy assignment, given its name and the scope it was created at.
* x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyAssignmentWithOverrides.json
*/
async function retrieveAPolicyAssignmentWithOverrides() {
const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2";
const policyAssignmentName = "CostManagement";
const credential = new DefaultAzureCredential();
const client = new PolicyClient(credential);
const result = await client.policyAssignments.get(scope, policyAssignmentName);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
応答のサンプル
{
"properties": {
"displayName": "Limit the resource location and resource SKU",
"description": "Limit the resource location and resource SKU",
"metadata": {
"assignedBy": "Special Someone"
},
"policyDefinitionId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement",
"definitionVersion": "1.*.*",
"notScopes": [],
"enforcementMode": "Default",
"scope": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2",
"overrides": [
{
"kind": "policyEffect",
"value": "Audit",
"selectors": [
{
"kind": "policyDefinitionReferenceId",
"in": [
"Limit_Skus",
"Limit_Locations"
]
}
]
}
]
},
"id": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement",
"type": "Microsoft.Authorization/policyAssignments",
"name": "CostManagement"
}
Retrieve a policy assignment with resource selectors
要求のサンプル
GET https://management.azure.com/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement?api-version=2023-04-01
/**
* Samples for PolicyAssignments Get.
*/
public final class Main {
/*
* x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/
* getPolicyAssignmentWithResourceSelectors.json
*/
/**
* Sample code: Retrieve a policy assignment with resource selectors.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
retrieveAPolicyAssignmentWithResourceSelectors(com.azure.resourcemanager.AzureResourceManager azure) {
azure.genericResources().manager().policyClient().getPolicyAssignments().getWithResponse(
"subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "CostManagement", null,
com.azure.core.util.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
package armpolicy_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyAssignmentWithResourceSelectors.json
func ExampleAssignmentsClient_Get_retrieveAPolicyAssignmentWithResourceSelectors() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpolicy.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewAssignmentsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "CostManagement", &armpolicy.AssignmentsClientGetOptions{Expand: nil})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Assignment = armpolicy.Assignment{
// Name: to.Ptr("CostManagement"),
// Type: to.Ptr("Microsoft.Authorization/policyAssignments"),
// ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"),
// Properties: &armpolicy.AssignmentProperties{
// Description: to.Ptr("Limit the resource location and resource SKU"),
// DefinitionVersion: to.Ptr("1.*.*"),
// DisplayName: to.Ptr("Limit the resource location and resource SKU"),
// EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault),
// Metadata: map[string]any{
// "assignedBy": "Special Someone",
// },
// NotScopes: []*string{
// },
// PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"),
// ResourceSelectors: []*armpolicy.ResourceSelector{
// {
// Name: to.Ptr("SDPRegions"),
// Selectors: []*armpolicy.Selector{
// {
// In: []*string{
// to.Ptr("eastus2euap"),
// to.Ptr("centraluseuap")},
// Kind: to.Ptr(armpolicy.SelectorKindResourceLocation),
// }},
// }},
// Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { PolicyClient } = require("@azure/arm-policy");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at.
*
* @summary This operation retrieves a single policy assignment, given its name and the scope it was created at.
* x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyAssignmentWithResourceSelectors.json
*/
async function retrieveAPolicyAssignmentWithResourceSelectors() {
const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2";
const policyAssignmentName = "CostManagement";
const credential = new DefaultAzureCredential();
const client = new PolicyClient(credential);
const result = await client.policyAssignments.get(scope, policyAssignmentName);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
応答のサンプル
{
"properties": {
"displayName": "Limit the resource location and resource SKU",
"description": "Limit the resource location and resource SKU",
"metadata": {
"assignedBy": "Special Someone"
},
"policyDefinitionId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement",
"definitionVersion": "1.*.*",
"notScopes": [],
"enforcementMode": "Default",
"scope": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2",
"resourceSelectors": [
{
"name": "SDPRegions",
"selectors": [
{
"kind": "resourceLocation",
"in": [
"eastus2euap",
"centraluseuap"
]
}
]
}
]
},
"id": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement",
"type": "Microsoft.Authorization/policyAssignments",
"name": "CostManagement"
}
定義
CloudError
Object
ポリシー操作からのエラー応答。
名前 |
型 |
説明 |
error
|
ErrorResponse
|
エラー応答
失敗した操作のエラーの詳細を返す、すべての Azure Resource Manager API の一般的なエラー応答。 (これは、OData エラー応答形式にも従います)。
|
createdByType
列挙
リソースを作成した ID の種類。
値 |
説明 |
Application
|
|
Key
|
|
ManagedIdentity
|
|
User
|
|
enforcementMode
列挙
ポリシー割り当て適用モード。 使用できる値は Default と DoNotEnforce です。
値 |
説明 |
Default
|
ポリシー効果は、リソースの作成または更新中に適用されます。
|
DoNotEnforce
|
ポリシー効果は、リソースの作成時または更新中には適用されません。
|
ErrorAdditionalInfo
Object
リソース管理エラーの追加情報。
名前 |
型 |
説明 |
info
|
object
|
追加情報。
|
type
|
string
|
追加情報の種類。
|
ErrorResponse
Object
エラー応答
Identity
Object
リソースの ID。 ポリシー割り当てでは、最大 1 つの ID がサポートされます。 これは、システム割り当て ID または単一ユーザー割り当て ID のいずれかです。
名前 |
型 |
説明 |
principalId
|
string
|
リソース ID のプリンシパル ID。 このプロパティは、システム割り当て ID に対してのみ提供されます
|
tenantId
|
string
|
リソース ID のテナント ID。 このプロパティは、システム割り当て ID に対してのみ提供されます
|
type
|
ResourceIdentityType
|
ID の種類。 これは、システム割り当て ID またはユーザー割り当て ID をリソースに追加するときに必要な唯一のフィールドです。
|
userAssignedIdentities
|
UserAssignedIdentities
|
ポリシーに関連付けられているユーザー ID。 ユーザー ID ディクショナリ のキー参照は、'/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}' という形式の ARM リソース ID になります。
|
NonComplianceMessage
Object
リソースがポリシーに準拠していない理由を説明するメッセージ。 これは、"拒否" エラー メッセージと、リソースの準拠していないコンプライアンスの結果に表示されます。
名前 |
型 |
説明 |
message
|
string
|
リソースがポリシーに準拠していない理由を説明するメッセージ。 これは、"拒否" エラー メッセージと、リソースの準拠していないコンプライアンスの結果に表示されます。
|
policyDefinitionReferenceId
|
string
|
メッセージの対象となるポリシー セット定義内のポリシー定義参照 ID。 これは、ポリシー割り当てによってポリシー セット定義が割り当てられている場合にのみ適用されます。 これが指定されていない場合、メッセージは、このポリシー割り当てによって割り当てられたすべてのポリシーに適用されます。
|
Override
Object
ポリシー プロパティ値のオーバーライド。
名前 |
型 |
説明 |
kind
|
OverrideKind
|
オーバーライドの種類。
|
selectors
|
Selector[]
|
セレクター式の一覧。
|
value
|
string
|
ポリシー プロパティをオーバーライドする値。
|
OverrideKind
列挙
オーバーライドの種類。
値 |
説明 |
policyEffect
|
ポリシー効果の種類がオーバーライドされます。
|
ParameterValuesValue
Object
パラメーターの値。
名前 |
型 |
説明 |
value
|
object
|
パラメーターの値。
|
PolicyAssignment
Object
ポリシーの割り当て。
名前 |
型 |
規定値 |
説明 |
id
|
string
|
|
ポリシー割り当ての ID。
|
identity
|
Identity
|
|
ポリシーの割り当てに関連付けられているマネージド ID。
|
location
|
string
|
|
ポリシー割り当ての場所。 マネージド ID を使用する場合にのみ必要です。
|
name
|
string
|
|
ポリシー割り当ての名前。
|
properties.definitionVersion
|
string
|
|
使用するポリシー定義のバージョン。
|
properties.description
|
string
|
|
このメッセージは、ポリシー違反が発生した場合の応答の一部になります。
|
properties.displayName
|
string
|
|
ポリシー割り当ての表示名。
|
properties.effectiveDefinitionVersion
|
string
|
|
使用中のポリシー定義の有効なバージョン。 これは、$expand クエリ パラメーターを使用して要求された場合にのみ存在します。
|
properties.enforcementMode
|
enforcementMode
|
Default
|
ポリシー割り当て適用モード。 使用できる値は Default と DoNotEnforce です。
|
properties.latestDefinitionVersion
|
string
|
|
使用可能なポリシー定義の最新バージョン。 これは、$expand クエリ パラメーターを使用して要求された場合にのみ存在します。
|
properties.metadata
|
object
|
|
ポリシー割り当てのメタデータ。 メタデータはオープン エンド オブジェクトであり、通常はキーと値のペアのコレクションです。
|
properties.nonComplianceMessages
|
NonComplianceMessage[]
|
|
リソースがポリシーに準拠していない理由を説明するメッセージ。
|
properties.notScopes
|
string[]
|
|
ポリシーの除外されたスコープ。
|
properties.overrides
|
Override[]
|
|
ポリシー プロパティ値のオーバーライド。
|
properties.parameters
|
<string,
ParameterValuesValue>
|
|
割り当てられたポリシー ルールのパラメーター値。 キーはパラメーター名です。
|
properties.policyDefinitionId
|
string
|
|
割り当てられているポリシー定義またはポリシー セット定義の ID。
|
properties.resourceSelectors
|
ResourceSelector[]
|
|
リソース のプロパティでポリシーをフィルター処理するリソース セレクターの一覧。
|
properties.scope
|
string
|
|
ポリシー割り当てのスコープ。
|
systemData
|
systemData
|
|
このリソースに関連するシステム メタデータ。
|
type
|
string
|
|
ポリシー割り当ての種類。
|
ResourceIdentityType
列挙
ID の種類。 これは、システム割り当て ID またはユーザー割り当て ID をリソースに追加するときに必要な唯一のフィールドです。
値 |
説明 |
None
|
リソースに関連付けられている ID が存在しないか、既存の ID を削除する必要があることを示します。
|
SystemAssigned
|
システム割り当て ID がリソースに関連付けられていることを示します。
|
UserAssigned
|
システム割り当て ID がリソースに関連付けられていることを示します。
|
ResourceSelector
Object
リソース プロパティでポリシーをフィルター処理するリソース セレクター。
名前 |
型 |
説明 |
name
|
string
|
リソース セレクターの名前。
|
selectors
|
Selector[]
|
セレクター式の一覧。
|
Selector
Object
セレクター式。
名前 |
型 |
説明 |
in
|
string[]
|
フィルター処理する値の一覧。
|
kind
|
SelectorKind
|
セレクターの種類。
|
notIn
|
string[]
|
フィルター処理する値の一覧。
|
SelectorKind
列挙
セレクターの種類。
値 |
説明 |
policyDefinitionReferenceId
|
ポリシー定義参照 ID でポリシーをフィルター処理するセレクターの種類。
|
resourceLocation
|
リソースの場所によってポリシーをフィルター処理するセレクターの種類。
|
resourceType
|
リソースの種類でポリシーをフィルター処理するセレクターの種類。
|
resourceWithoutLocation
|
場所のないリソースによってポリシーをフィルター処理するセレクターの種類。
|
systemData
Object
リソースの作成と最後の変更に関連するメタデータ。
名前 |
型 |
説明 |
createdAt
|
string
(date-time)
|
リソース作成のタイムスタンプ (UTC)。
|
createdBy
|
string
|
リソースを作成した ID。
|
createdByType
|
createdByType
|
リソースを作成した ID の種類。
|
lastModifiedAt
|
string
(date-time)
|
リソースの最終変更のタイムスタンプ (UTC)
|
lastModifiedBy
|
string
|
リソースを最後に変更した ID。
|
lastModifiedByType
|
createdByType
|
リソースを最後に変更した ID の種類。
|
UserAssignedIdentities
Object
ポリシーに関連付けられているユーザー ID。 ユーザー ID ディクショナリ のキー参照は、'/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}' という形式の ARM リソース ID になります。