使用 Azure Policy 为托管应用程序部署关联Deploy associations for a managed application using Azure Policy

Azure 策略可用于部署关联,将资源关联到托管应用程序。Azure policies can be used to deploy associations to associate resources to a managed application. 本文介绍了一种用于部署关联的内置策略,并介绍了如何使用该策略。In this article, we describe a built-in policy that deploys associations and how you can use that policy.

用于部署关联的内置策略Built-in policy to deploy associations

“为托管应用程序部署关联”是一种内置策略,此策略可用于部署关联,将资源关联到托管应用程序。Deploy associations for a managed application is a built-in policy that can be used to deploy association to associate a resource to a managed application. 此策略接受三个参数:The policy accepts three parameters:

  • 托管应用程序 ID - 此 ID 是需将资源关联到其中的托管应用程序的资源 ID。Managed application ID - This ID is the resource ID of the managed application to which the resources need to be associated.
  • 要关联的资源类型 - 这些资源类型是要关联到托管应用程序的资源类型的列表。Resource types to associate - These resource types are the list of resource types to be associated to the managed application. 可以使用同一策略将多个资源类型关联到一个托管应用程序。You can associate multiple resource types to a managed application using the same policy.
  • 关联名称前缀 - 此字符串是要添加到正在创建的关联资源的名称中的前缀。Association name prefix - This string is the prefix to be added to the name of the association resource being created. 默认值为“DeployedByPolicy”。The default value is "DeployedByPolicy".

如何使用部署关联内置策略How to use the deploy associations built-in policy

先决条件Prerequisites

如果托管应用程序需要订阅的权限来执行操作,则在不授权的情况下,关联资源的策略部署将不起作用。If the managed application needs permissions to the subscription to perform an action, the policy deployment of association resource wouldn't work without granting the permissions.

策略分配Policy assignment

若要使用内置策略,请创建一个策略分配,并分配“为托管应用程序部署关联”策略。To use the built-in policy, create a policy assignment and assign the Deploy associations for a managed application policy. 成功分配策略后,策略会标识不合规的资源并为这些资源部署关联。Once the policy has been assigned successfully, the policy will identify non-compliant resources and deploy association for those resources.

分配内置策略