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

az policy assignment identity

管理策略分配的托管标识。

命令

名称 说明 类型 Status
az policy assignment identity assign

将系统分配的标识或用户分配的标识添加到策略分配。

Core GA
az policy assignment identity remove

从策略分配中删除托管标识。

Core GA
az policy assignment identity show

显示策略分配的托管标识。

Core GA

az policy assignment identity assign

Breaking change

替换现有标识将在资源命令的未来版本中发生更改。 它首先需要删除现有标识。

将系统分配的标识或用户分配的标识添加到策略分配。

az policy assignment identity assign --name
                                     [--identity-scope]
                                     [--resource-group]
                                     [--role]
                                     [--scope]
                                     [--system-assigned]
                                     [--user-assigned]

示例

将系统分配的托管标识添加到策略分配。

az policy assignment identity assign --system-assigned -g MyResourceGroup -n MyPolicyAssignment

将系统分配的托管标识添加到策略分配,并向其授予当前资源组的“参与者”角色。

az policy assignment identity assign --system-assigned -g MyResourceGroup -n MyPolicyAssignment --role Contributor --identity-scope /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup

将用户分配的托管标识添加到策略分配。

az policy assignment identity assign --user-assigned MyAssignedId -g MyResourceGroup -n MyPolicyAssignment

必需参数

--name -n

策略分配的名称。

可选参数

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--identity-scope

系统分配的标识可以访问的范围。

属性
Parameter group: Managed Identity Arguments
--resource-group -g

将应用策略的资源组。

--role

将分配给托管标识的角色名称或 ID。

属性
Parameter group: Managed Identity Arguments
默认值: Contributor
--scope

此策略分配子命令适用的范围。 默认为当前上下文订阅。

--system-assigned

提供此标志以使用系统分配标识进行策略分配。 请查看有关更多示例的帮助。

属性
Parameter group: Managed Identity Arguments
--user-assigned

要用于策略分配的 UserAssigned 标识 ID。 请查看有关更多示例的帮助。

属性
Parameter group: Managed Identity Arguments
全局参数
--debug

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

属性
默认值: False
--help -h

显示此帮助消息并退出。

--only-show-errors

仅显示错误,禁止显示警告。

属性
默认值: False
--output -o

输出格式。

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

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

--subscription

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

--verbose

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

属性
默认值: False

az policy assignment identity remove

Breaking change

在资源命令的未来版本中,删除用户分配的标识将发生更改。 它需要提供 --mi-user-assigned 开关。

从策略分配中删除托管标识。

az policy assignment identity remove --name
                                     [--resource-group]
                                     [--scope]

必需参数

--name -n

策略分配的名称。

可选参数

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--resource-group -g

将应用策略的资源组。

--scope

此策略分配子命令适用的范围。 默认为当前上下文订阅。

全局参数
--debug

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

属性
默认值: False
--help -h

显示此帮助消息并退出。

--only-show-errors

仅显示错误,禁止显示警告。

属性
默认值: False
--output -o

输出格式。

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

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

--subscription

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

--verbose

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

属性
默认值: False

az policy assignment identity show

显示策略分配的托管标识。

az policy assignment identity show --name
                                   [--resource-group]
                                   [--scope]

示例

显示策略分配的托管标识。 (autogenerated)

az policy assignment identity show --name MyPolicyAssignment --scope '/providers/Microsoft.Management/managementGroups/MyManagementGroup'

必需参数

--name -n

策略分配的名称。

可选参数

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--resource-group -g

将应用策略的资源组。

--scope

此策略分配子命令适用的范围。 默认为当前上下文订阅。

全局参数
--debug

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

属性
默认值: False
--help -h

显示此帮助消息并退出。

--only-show-errors

仅显示错误,禁止显示警告。

属性
默认值: False
--output -o

输出格式。

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

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

--subscription

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

--verbose

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

属性
默认值: False