你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

az policy attestation

管理资源策略证明。

命令

名称 说明 类型 状态
az policy attestation create

创建策略证明。

核心 GA
az policy attestation delete

删除现有策略证明。

核心 GA
az policy attestation list

列出资源的所有证明。

核心 GA
az policy attestation show

获取策略证明。

核心 GA
az policy attestation update

更新现有策略证明。

核心 GA

az policy attestation create

创建策略证明。

az policy attestation create --attestation-name
                             --policy-assignment
                             [--assessment-date]
                             [--comments]
                             [--compliance-state {Compliant, NonCompliant, Unknown}]
                             [--definition-reference-id]
                             [--evidence]
                             [--expires-on]
                             [--metadata]
                             [--namespace]
                             [--owner]
                             [--parent]
                             [--resource]
                             [--resource-group]
                             [--resource-type]

示例

在策略分配的资源组范围内创建证明

az policy attestation create -g myRg -n myAttestation --policy-assignment eeb18edc813c42d0ad5a9eab

使用策略分配资源 ID 在策略分配的资源组范围内创建证明

az policy attestation create -g myRg -n myAttestation \
  --policy-assignment "/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.Authorization/policyAssignments/myPa"

在策略集分配的订阅范围内创建证明

az policy attestation create -n myAttestation \
  --policy-assignment eeb18edc813c42d0ad5a9eab \
  --definition-reference-id auditVMPolicyReference

使用资源 ID 为特定资源创建证明

az policy attestation create \
  --resource "/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourceGroups/myRg/providers/Microsoft.Compute/virtualMachines/myVm" \
  -n myAttestation --policy-assignment eeb18edc813c42d0ad5a9eab

使用所有属性在资源组范围内创建证明

az policy attestation create --attestation-name myAttestation -g myRg -a eeb18edc813c42d0ad5a9eab \
 --compliance-state Compliant --assessment-date 2023-01-01T08:29:18Z \
 --evidence source-uri=https://sampleuri.com description="Sample description for the sample uri" \
 --evidence source-uri=https://sampleuri2.com description="Sample description 2 for the sample uri 2" \
 --expires-on 2024-08-01T05:29:18Z --owner user@myOrg.com --metadata Location=NYC Dept=ACC \
 --definition-reference-id auditVMPolicyReference

必需参数

--attestation-name --name -n

证明的名称。

--policy-assignment --policy-assignment-id -a

证明为其设置状态的策略分配的资源 ID。

可选参数

--assessment-date

评估证据的时间。

--comments

描述创建此证明的原因的注释。

--compliance-state

应在资源上设置的符合性状态。

接受的值: Compliant, NonCompliant, Unknown
--definition-reference-id

证明为其设置状态的策略集定义中的策略定义引用 ID。 如果策略分配分配策略集定义,则证明可以使用此属性选择集定义中的定义,或省略此属性并设置整个集定义的状态。

--evidence

支持此证明中设置符合性状态的证据。

--expires-on

符合性状态应过期的时间。

--metadata

用于证明的空间分隔键=值对中的其他元数据。 这会覆盖证明的任何现有元数据。

--namespace

提供程序命名空间(例如:Microsoft.Provider)。

--owner

负责设置资源状态的人员。 此值通常是 Azure Active Directory 对象 ID。

--parent

父路径(例如:resourceTypeA/nameA/resourceTypeB/nameB)。

--resource --resource-id

资源 ID 或资源名称。 如果指定了名称,请提供资源组和其他相关的资源 ID 参数。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

--resource-type

资源类型(例如:resourceTypeC)。

全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az policy attestation delete

删除现有策略证明。

az policy attestation delete --attestation-name
                             [--namespace]
                             [--parent]
                             [--resource]
                             [--resource-group]
                             [--resource-type]

示例

删除资源组范围内的证明

az policy attestation delete -g myRg -n myAttestation

必需参数

--attestation-name --name -n

证明的名称。

可选参数

--namespace

提供程序命名空间(例如:Microsoft.Provider)。

--parent

父路径(例如:resourceTypeA/nameA/resourceTypeB/nameB)。

--resource --resource-id

资源 ID 或资源名称。 如果指定了名称,请提供资源组和其他相关的资源 ID 参数。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

--resource-type

资源类型(例如:resourceTypeC)。

全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az policy attestation list

列出资源的所有证明。

az policy attestation list [--filter]
                           [--resource]
                           [--resource-group]
                           [--top]

示例

列出订阅范围内的所有策略证明

az policy attestation list

列出资源组范围内的前两个策略证明

az policy attestation list -g myRg --top 2

列出具有 myPolicyAssignment 的策略分配 ID 的所有证明

az policy attestation list --filter "PolicyAssignmentId eq '/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5'"

可选参数

--filter

OData 筛选器表达式。

--resource --resource-id

资源 ID。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

--top

要返回的最大记录数。

全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az policy attestation show

获取策略证明。

az policy attestation show --attestation-name
                           [--namespace]
                           [--parent]
                           [--resource]
                           [--resource-group]
                           [--resource-type]

示例

在订阅中显示证明。

az policy attestation show --attestation-name myAttestation

必需参数

--attestation-name --name -n

证明的名称。

可选参数

--namespace

提供程序命名空间(例如:Microsoft.Provider)。

--parent

父路径(例如:resourceTypeA/nameA/resourceTypeB/nameB)。

--resource --resource-id

资源 ID 或资源名称。 如果指定了名称,请提供资源组和其他相关的资源 ID 参数。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

--resource-type

资源类型(例如:resourceTypeC)。

全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az policy attestation update

更新现有策略证明。

az policy attestation update --attestation-name
                             [--assessment-date]
                             [--comments]
                             [--compliance-state {Compliant, NonCompliant, Unknown}]
                             [--definition-reference-id]
                             [--evidence]
                             [--expires-on]
                             [--metadata]
                             [--namespace]
                             [--owner]
                             [--parent]
                             [--policy-assignment]
                             [--resource]
                             [--resource-group]
                             [--resource-type]

示例

更新资源范围内的证明

az policy attestation update --attestation-name myAttestation \
  --resource "/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourceGroups/myRg/providers/Microsoft.Compute/virtualMachines/myVm" \
  --comments "Adding comments for this attestation"

必需参数

--attestation-name --name -n

证明的名称。

可选参数

--assessment-date

评估证据的时间。

--comments

描述创建此证明的原因的注释。

--compliance-state

应在资源上设置的符合性状态。

接受的值: Compliant, NonCompliant, Unknown
--definition-reference-id

证明为其设置状态的策略集定义中的策略定义引用 ID。 如果策略分配分配策略集定义,则证明可以使用此属性选择集定义中的定义,或省略此属性并设置整个集定义的状态。

--evidence

支持此证明中设置符合性状态的证据。

--expires-on

符合性状态应过期的时间。

--metadata

用于证明的空间分隔键=值对中的其他元数据。 这会覆盖证明的任何现有元数据。

--namespace

提供程序命名空间(例如:Microsoft.Provider)。

--owner

负责设置资源状态的人员。 此值通常是 Azure Active Directory 对象 ID。

--parent

父路径(例如:resourceTypeA/nameA/resourceTypeB/nameB)。

--policy-assignment --policy-assignment-id -a

证明为其设置状态的策略分配的资源 ID。

--resource --resource-id

资源 ID 或资源名称。 如果指定了名称,请提供资源组和其他相关的资源 ID 参数。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

--resource-type

资源类型(例如:resourceTypeC)。

全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。