共用方式為


Policy Enrollments - List For Resource

擷取所有適用於資源的政策註冊資料。
此操作會取得與指定資源群組及訂閱中所有與該資源相符且符合可選$filter的政策註冊清單。 $filter的有效值為:'atScope()' 或 'atExactScope()'。 若未提供$filter,未篩選清單會包含所有與資源相關的政策註冊,包括直接適用的或來自所有含範圍的,以及套用於資源內資源的。 三個參數加上資源名稱可用來識別特定資源。 如果資源不是父資源的一部分(較常見的情況),則不應該提供父資源路徑(或提供為 '')。 例如,Web 應用程式可以指定為 ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp')。 如果資源是父資源的一部分,則應該提供所有參數。 例如,可以將虛擬機 DNS 名稱指定為 ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName')。 另外提供命名空間和類型名稱的便利替代方式是同時提供 {resourceType} 参數,格式: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp')。

GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyEnrollments?api-version=2026-01-01-preview
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyEnrollments?api-version=2026-01-01-preview&$filter={$filter}

URI 參數

名稱 位於 必要 類型 Description
parentResourcePath
path True

string

父資源路徑。 如果沒有,請使用空字串。

resourceGroupName
path True

string

minLength: 1
maxLength: 90

資源群組的名稱。 名稱不區分大小寫。

resourceName
path True

string

pattern: ^.+$

資源名稱。

resourceProviderNamespace
path True

string

資源提供者的命名空間。 例如,虛擬機的命名空間是 Microsoft.Compute (從 Microsoft.Compute/virtualMachines)

resourceType
path True

string

資源類型名稱。 例如,Web 應用程式的類型名稱是 'sites' (從 Microsoft.Web/sites)。

subscriptionId
path True

string (uuid)

目標訂用帳戶的標識碼。 此值必須是 UUID。

api-version
query True

string

minLength: 1

用於此作業的 API 版本。

$filter
query

string

要套用至作業的篩選條件。 $filter的有效值為:'atScope()' 或 'atExactScope()'。 如果未提供$filter,則不會執行任何篩選。 若未提供$filter,未篩選清單包含所有與範圍相關的政策註冊,包括直接適用或包含範圍的。 若提供 $filter=atScope(),回傳清單包含所有適用於該範圍的政策註冊,該政策註冊包含未篩選清單中除套用於該範圍內子範圍外的所有。 若提供 $filter=atExactScope() 格式,回傳清單僅包含該範圍內適用的所有政策註冊。

回應

名稱 類型 Description
200 OK

PolicyEnrollmentListResult

Azure 運作順利完成。

Other Status Codes

ErrorResponse

未預期的錯誤回應。

安全性

azure_auth

Azure Active Directory OAuth2 Flow。

類型: oauth2
Flow: implicit
授權 URL: https://login.microsoftonline.com/common/oauth2/authorize

範圍

名稱 Description
user_impersonation 模擬您的用戶帳戶

範例

List policy enrollments for resource

範例要求

GET https://management.azure.com/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup/providers/Microsoft.Compute/virtualMachines/MyTestVm/domainNames/MyTestComputer.cloudapp.net/providers/Microsoft.Authorization/policyEnrollments?api-version=2026-01-01-preview

範例回覆

{
  "value": [
    {
      "properties": {
        "policyAssignmentId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement",
        "policyDefinitionReferenceIds": [
          "Limit_Skus"
        ],
        "policyAssignmentInstanceId": "00000000-0000-0000-0000-000000000000",
        "displayName": "Enroll demo cluster",
        "description": "Enroll demo cluster from limit sku",
        "metadata": {
          "reason": "Enrollment for a expensive VM demo"
        }
      },
      "systemData": {
        "createdBy": "string",
        "createdByType": "User",
        "createdAt": "2020-07-01T01:01:01.1075056Z",
        "lastModifiedBy": "string",
        "lastModifiedByType": "User",
        "lastModifiedAt": "2020-07-01T02:01:01.1075056Z"
      },
      "id": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup/providers/Microsoft.Authorization/policyEnrollments/DemoExpensiveVMGroup",
      "type": "Microsoft.Authorization/policyEnrollments",
      "eTag": "00000000-0000-0000-0000-000000000000",
      "name": "DemoExpensiveVMGroup"
    },
    {
      "properties": {
        "policyAssignmentId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/LimitPorts",
        "policyAssignmentInstanceId": "00000000-0000-0000-0000-000000000000",
        "displayName": "Enroll jump box open ports",
        "description": "Enroll jump box open ports from limit ports policy",
        "metadata": {
          "reason": "Need to open RDP port to corp net"
        }
      },
      "systemData": {
        "createdBy": "string",
        "createdByType": "User",
        "createdAt": "2020-07-01T01:01:01.1075056Z",
        "lastModifiedBy": "string",
        "lastModifiedByType": "User",
        "lastModifiedAt": "2020-07-01T02:01:01.1075056Z"
      },
      "id": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup/providers/Microsoft.Compute/virtualMachines/MyTestVm/providers/Microsoft.Authorization/policyEnrollments/jumpBoxEnrollment",
      "type": "Microsoft.Authorization/policyEnrollments",
      "eTag": "00000000-0000-0000-0000-000000000000",
      "name": "jumpBoxEnrollment"
    }
  ]
}

定義

名稱 Description
AssignmentScopeValidation

驗證豁免或登記是否屬於轉讓範圍的選項。

createdByType

建立資源的身分識別類型。

ErrorAdditionalInfo

資源管理錯誤其他資訊。

ErrorDetail

錯誤詳細數據。

ErrorResponse

錯誤回應

PolicyEnrollment

保單登記。

PolicyEnrollmentListResult

PolicyEnrollment 名單操作的回應。

ResourceSelector

依資源屬性篩選原則的資源選取器。

Selector

選取器表達式。

SelectorKind

選取器種類。

systemData

與建立和上次修改資源相關的元數據。

AssignmentScopeValidation

驗證豁免或登記是否屬於轉讓範圍的選項。

Description
Default

此選項會驗證豁免位於指派範圍或指派範圍內。

DoNotValidate

此選項會略過豁免範圍位於原則指派範圍或下方的驗證。

createdByType

建立資源的身分識別類型。

Description
User
Application
ManagedIdentity
Key

ErrorAdditionalInfo

資源管理錯誤其他資訊。

名稱 類型 Description
info

object

其他資訊。

type

string

其他信息類型。

ErrorDetail

錯誤詳細數據。

名稱 類型 Description
additionalInfo

ErrorAdditionalInfo[]

錯誤其他資訊。

code

string

錯誤碼。

details

ErrorDetail[]

錯誤詳情

message

string

錯誤訊息。

target

string

錯誤目標。

ErrorResponse

錯誤回應

名稱 類型 Description
error

ErrorDetail

error 物件。

PolicyEnrollment

保單登記。

名稱 類型 Description
eTag

string

投保時的ETag。

id

string (arm-id)

資源的完整資源標識碼。 例如,“/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}”

name

string

資源的名稱

properties.assignmentScopeValidation

AssignmentScopeValidation

是否驗證註冊的選項是在指派範圍內或在指派範圍內。

properties.description

string

保單登記的描述。

properties.displayName

string

保單登記的顯示名稱。

properties.metadata

保單登記的元資料。 元數據是開放式物件,通常是索引鍵值組的集合。

properties.policyAssignmentId

string (arm-id)

正在登記的保單分配的 ID。

properties.policyAssignmentInstanceId

string (uuid)

與此登記相關的政策分配實例 ID。 該值會設定為 policyAssignmentId 在建立或更新註冊時所參考的政策指派的實例 ID。 格式為 GUID 字串。

properties.policyDefinitionReferenceIds

string[]

政策定義會參考指派政策集定義中的政策定義的 ID。 這些 ID 對應於政策集定義中的子集 policyDefinitions[*].policyDefinitionReferenceId 。 當指定且非空時,僅會註冊到參考的政策定義。 否則,整個政策集會被註冊為

properties.resourceSelectors

ResourceSelector[]

依資源屬性篩選原則的資源選取器清單。

systemData

systemData

包含 createdBy 和 modifiedBy 資訊的 Azure Resource Manager 元數據。

type

string

資源的類型。 例如“Microsoft.Compute/virtualMachines” 或 “Microsoft.Storage/storageAccounts”

PolicyEnrollmentListResult

PolicyEnrollment 名單操作的回應。

名稱 類型 Description
nextLink

string (uri)

專案下一頁的連結

value

PolicyEnrollment[]

本頁的 PolicyEnrollment 項目

ResourceSelector

依資源屬性篩選原則的資源選取器。

名稱 類型 Description
name

string

資源選取器的名稱。

selectors

Selector[]

選取器表達式的清單。

Selector

選取器表達式。

名稱 類型 Description
in

string[]

要篩選的值清單。

kind

SelectorKind

選取器種類。

notIn

string[]

要篩選掉的值清單。

SelectorKind

選取器種類。

Description
resourceLocation

依資源位置篩選原則的選取器種類。

resourceType

依資源類型篩選原則的選取器種類。

resourceWithoutLocation

依沒有位置的資源篩選原則的選取器種類。

policyDefinitionReferenceId

依原則定義參考標識元篩選原則的選取器種類。

userPrincipalId

選擇器類型用來依使用者主體 ID 過濾政策。

groupPrincipalId

選擇器類型用來依安全群組成員識別碼過濾政策。

systemData

與建立和上次修改資源相關的元數據。

名稱 類型 Description
createdAt

string (date-time)

資源建立的時間戳(UTC)。

createdBy

string

建立資源的身分識別。

createdByType

createdByType

建立資源的身分識別類型。

lastModifiedAt

string (date-time)

上次修改的資源時間戳 (UTC)

lastModifiedBy

string

上次修改資源的身分識別。

lastModifiedByType

createdByType

上次修改資源的身分識別類型。