您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

以编程方式创建 Azure Enterprise 订阅(预览版)Programmatically create Azure Enterprise subscriptions (preview)

Azure 企业协议 (EA) 客户可以以编程方式创建 EA (MS-AZR-0017P) 和 EA 开发/测试 (MS-AZR-0148P) 订阅。As an Azure customer on Enterprise Agreement (EA), you can create EA (MS-AZR-0017P) and EA Dev/Test (MS-AZR-0148P) subscriptions programmatically. 本文介绍如何使用 Azure 资源管理器以编程方式创建订阅。In this article, you learn how to create subscriptions programmatically using Azure Resource Manager.

通过此 API 创建 Azure 订阅时,该订阅受你从 Microsoft 或授权经销商处获取 Microsoft Azure 服务时所签署协议的约束。When you create an Azure subscription from this API, that subscription is governed by the agreement under which you obtained Microsoft Azure services from Microsoft or an authorized reseller. 有关详细信息,请参阅 Microsoft Azure 法律信息To learn more, see Microsoft Azure Legal Information.

备注

本文进行了更新,以便使用新的 Azure PowerShell Az 模块。This article has been updated to use the new Azure PowerShell Az module. 你仍然可以使用 AzureRM 模块,至少在 2020 年 12 月之前,它将继续接收 bug 修补程序。You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. 若要详细了解新的 Az 模块和 AzureRM 兼容性,请参阅新 Azure Powershell Az 模块简介To learn more about the new Az module and AzureRM compatibility, see Introducing the new Azure PowerShell Az module. 有关 Az 模块安装说明,请参阅安装 Azure PowerShellFor Az module installation instructions, see Install Azure PowerShell.

必备组件Prerequisites

你想要创建下的订阅注册帐户,必须具有的所有者角色。You must have an Owner role on the Enrollment Account you wish to create subscriptions under. 可通过两种方式来获取这些角色:There are two ways to get these roles:

  • 你的注册管理员可以将你的帐户所有者(登录所需) 这使你的注册帐户所有者。Your Enrollment Administrator can make you an Account Owner (sign in required) which makes you an Owner of the Enrollment Account. 按照收到的邀请电子邮件中的说明手动创建初始订阅。Follow the instructions in the invitation email you receive to manually create an initial subscription. 请先确认帐户所有权并手动创建初始 EA 订阅,然后继续下一步操作。Confirm account ownership and manually create an initial EA subscription before proceeding to the next step. 只将帐户添加到合约是不够的。Just adding the account to the enrollment isn't enough.

  • 注册帐户的现有所有者可以向你授予访问权限An existing Owner of the Enrollment Account can grant you access. 类似地,若要使用某个服务主体来创建 EA 订阅,必须向该服务主体授予创建订阅的权限Similarly, if you want to use a service principal to create the EA subscription, you must grant that service principal the ability to create subscriptions.

查找有访问权限的帐户Find accounts you have access to

将你作为帐户所有者添加到 Azure EA 注册后,Azure 使用帐户到注册的关系来确定订阅收费对象。After you're added to an Azure EA enrollment as an Account Owner, Azure uses the account-to-enrollment relationship to determine where to bill the subscription charges. 在该帐户下创建的所有订阅均针对该帐户所在的 EA 注册进行计费。All subscriptions created under the account are billed towards the EA enrollment that the account is in. 若要创建订阅,必须传入拥有订阅所需的合约帐户和用户主体的相关值。To create subscriptions, you must pass in values about the enrollment account and the user principals to own the subscription.

若要运行以下命令,必须登录到帐户所有者的主目录(默认在该目录中创建订阅)。 To run the following commands, you must be logged in to the Account Owner's home directory, which is the directory that subscriptions are created in by default.

若要列出有权访问的所有注册帐户的请求:Request to list all enrollment accounts you have access to:

GET https://management.azure.com/providers/Microsoft.Billing/enrollmentAccounts?api-version=2018-03-01-preview

Azure 使用有访问权限的所有注册帐户列表做出响应:Azure responds with a list of all enrollment accounts you have access to:

{
  "value": [
    {
      "id": "/providers/Microsoft.Billing/enrollmentAccounts/747ddfe5-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "name": "747ddfe5-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "type": "Microsoft.Billing/enrollmentAccounts",
      "properties": {
        "principalName": "SignUpEngineering@contoso.com"
      }
    },
    {
      "id": "/providers/Microsoft.Billing/enrollmentAccounts/4cd2fcf6-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "name": "4cd2fcf6-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "type": "Microsoft.Billing/enrollmentAccounts",
      "properties": {
        "principalName": "BillingPlatformTeam@contoso.com"
      }
    }
  ]
}

使用 principalName 属性标识想要对其收取订阅费用的帐户。Use the principalName property to identify the account that you want subscriptions to be billed to. 复制name的该帐户。Copy the name of that account. 例如,如果你想要创建下的订阅SignUpEngineering@contoso.com注册帐户,会将复制```747ddfe5-xxxx-xxxx-xxxx-xxxxxxxxxxxx```。For example, if you wanted to create subscriptions under the SignUpEngineering@contoso.com enrollment account, you'd copy 747ddfe5-xxxx-xxxx-xxxx-xxxxxxxxxxxx. 这是注册帐户的对象 ID。This is the object ID of the enrollment account. 将此值粘贴到某个位置,以便可以使用它作为在下一步enrollmentAccountObjectIdPaste this value somewhere so that you can use it in the next step as enrollmentAccountObjectId.

在特定注册帐户下创建订阅Create subscriptions under a specific enrollment account

下面的示例创建名为的订阅开发团队订阅在上一步中选择的注册帐户。The following example creates a subscription named Dev Team Subscription in the enrollment account selected in the previous step. 订阅产品/服务MS-条-0017 P (常规 Microsoft 企业协议)。The subscription offer is MS-AZR-0017P (regular Microsoft Enterprise Agreement). 它也选择性地添加两个用户作为订阅的 RBAC 所有者。It also optionally adds two users as RBAC Owners for the subscription.

下面的请求,请替换<enrollmentAccountObjectId>name复制的第一步 (747ddfe5-xxxx-xxxx-xxxx-xxxxxxxxxxxx)。Make the following request, replacing <enrollmentAccountObjectId> with the name copied from the first step (747ddfe5-xxxx-xxxx-xxxx-xxxxxxxxxxxx). 如果你想要指定所有者,了解如何获取用户对象 IdIf you'd like to specify owners, learn how to get user object IDs.

POST https://management.azure.com/providers/Microsoft.Billing/enrollmentAccounts/<enrollmentAccountObjectId>/providers/Microsoft.Subscription/createSubscription?api-version=2018-03-01-preview

{
  "displayName": "Dev Team Subscription",
  "offerType": "MS-AZR-0017P",
  "owners": [
    {
      "objectId": "<userObjectId>"
    },
    {
      "objectId": "<servicePrincipalObjectId>"
    }
  ]
}
元素名称Element Name 必选Required TypeType 描述Description
displayName No StringString 订阅的显示名称。The display name of the subscription. 如果未指定,则将其设置为产品/服务名称,例如“Microsoft Azure Enterprise”。If not specified, it's set to the name of the offer, like "Microsoft Azure Enterprise."
offerType Yes StringString 订阅的套餐。The offer of the subscription. EA 的两个选项是 MS-AZR-0017P(生产用)和 MS-AZR-0148P(开发/测试用,需要使用 EA 门户启用)。The two options for EA are MS-AZR-0017P (production use) and MS-AZR-0148P (dev/test, needs to be turned on using the EA portal).
owners No StringString 希望在订阅创建时作为 RBAC 所有者添加到订阅上的任意用户的对象 ID。The Object ID of any user that you'd like to add as an RBAC Owner on the subscription when it's created.

在响应中,返回 subscriptionOperation 对象进行监视。In the response, you get back a subscriptionOperation object for monitoring. 完成订阅创建后,subscriptionOperation 对象将返回有订阅 ID 的 subscriptionLink 对象。When the subscription creation is finished, the subscriptionOperation object would return a subscriptionLink object, which has the subscription ID.

对创建 Azure Enterprise 订阅的 API 限制Limitations of Azure Enterprise subscription creation API

  • 仅 Azure Enterprise 订阅可以使用此 API 进行创建。Only Azure Enterprise subscriptions can be created using this API.
  • 一个初始限制为 50 个订阅每个注册帐户,但你可以创建支持请求若要将限制增加到 200。There's an initial limit of 50 subscriptions per enrollment account, but you can create a support request to increase the limit to 200. 之后,可以仅创建订阅通过帐户中心。After that, subscriptions can only be created through the Account Center.
  • 帐户下至少需要一个 EA 或 EA 开发/测试,这意味着帐户所有者至少经历过一次手动注册。There needs to be at least one EA or EA Dev/Test subscriptions under the account, which means the Account Owner has gone through manual sign-up at least once.
  • 不是帐户所有者但通过 RBAC 添加到合约帐户的用户不能使用帐户中心创建订阅。Users who aren't Account Owners, but were added to an enrollment account via RBAC, can't create subscriptions using Account Center.
  • 不能选择要在其中创建订阅的租户。You can't select the tenant for the subscription to be created in. 订阅始终在帐户所有者的主租户中进行创建。The subscription is always created in the home tenant of the Account Owner. 若要将订阅移到不同的租户,请参阅更改订阅租户To move the subscription to a different tenant, see change subscription tenant.

后续步骤Next steps