Raw New Markdown
Generating updated version of doc...
Rendered New Markdown
Generating updated version of doc...
---
title: Programmatically create Azure subscriptions for a Microsoft Partner Agreement with the latest APIs
description: Learn how to create Azure subscriptions for a Microsoft Partner Agreement programmatically using the latest versions of REST API, Azure CLI, Azure PowerShell, and Azure Resource Manager templates.
author: Nicholak-MS
ms.author: nicholak
ms.reviewer: nicholak
ms.service: cost-management-billing
ms.subservice: billing
ms.topic: how-to
ms.date: 12/29/2025
ms.custom: devx-track-azurepowershell, devx-track-azurecli, devx-track-arm-template, devx-track-bicep
service.tree.id: b69a7832-2929-4f60-bf9d-c6784a865ed8
---
# Programmatically create Azure subscriptions for a Microsoft Partner Agreement with the latest APIs
This article helps you programmatically create Azure subscriptions for a Microsoft Partner Agreement using the most recent API versions. If you are still using the older preview version, see [Programmatically create Azure subscriptions with legacy APIs](programmatically-create-subscription-preview.md).
In this article, you learn how to create subscriptions programmatically using Azure Resource Manager.
When you create an Azure subscription programmatically, that subscription is governed by the agreement under which you obtained Azure services from Microsoft or an authorized reseller. For more information, see [Microsoft Azure Legal Information](https://azure.microsoft.com/support/legal/).
[!INCLUDE [updated-for-az](~/reusable-content/ce-skilling/azure/includes/updated-for-az.md)]
You can't create support plans programmatically. You can buy a new support plan or upgrade one in the Azure portal. Navigate to **Help + support** and then at the top of the page, select **Choose the right support plan**.
## Prerequisites
You must have an Admin Agent role in your organization's cloud solution provider account to create subscription for your billing account. For more information, see [Partner Center - Assign users roles and permissions](/partner-center/permissions-overview).
If you don't know whether you have access to a Microsoft Partner Agreement account, see [Check access to a Microsoft Partner Agreement](mpa-request-ownership.md#check-access-to-a-microsoft-partner-agreement).
The following examples use REST APIs. Currently, PowerShell and Azure CLI aren't supported.
## Find the billing accounts that you have access to
Make the following request to list all billing accounts that you have access to.
### [REST](#tab/rest)
```json
GET https://management.azure.com/providers/Microsoft.Billing/billingaccounts/?api-version=2020-05-01
```
The API response lists the billing accounts.
```json
{
"value": [
{
"id": "/providers/Microsoft.Billing/billingAccounts/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx",
"name": "aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx",
"properties": {
"accountStatus": "Active",
"accountType": "Partner",
"agreementType": "MicrosoftPartnerAgreement",
"billingProfiles": {
"hasMoreResults": false
},
"displayName": "Contoso",
"hasReadAccess": true
},
"type": "Microsoft.Billing/billingAccounts"
}
]
}
```
Use the `displayName` property to identify the billing account for which you want to create subscriptions. Ensure, the agreementType of the account is *MicrosoftPartnerAgreement*. Copy the `name` for the account. For example, to create a subscription for the `Contoso` billing account, copy `aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx`. Paste the value somewhere so that you can use it in the next step.
### [PowerShell](#tab/azure-powershell)
Please use either Azure CLI or REST API to get this value.
### [Azure CLI](#tab/azure-cli)
```azurecli
az billing account list
```
You will get back a list of all billing accounts that you have access to.
```json
[
{
"accountStatus": "Active",
"accountType": "Partner",
"agreementType": "MicrosoftPartnerAgreement",
"billingProfiles": {
"hasMoreResults": false,
"value": null
},
"departments": null,
"displayName": "Contoso",
"enrollmentAccounts": null,
"enrollmentDetails": null,
"hasReadAccess": true,
"id": "/providers/Microsoft.Billing/billingAccounts/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx",
"name": "aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx",
"soldTo": null,
"type": "Microsoft.Billing/billingAccounts"
}
]
```
Use the displayName property to identify the billing account for which you want to create subscriptions. Ensure, the agreementType of the account is MicrosoftPartnerAgreement. Copy the name for the account. For example, to create a subscription for the Contoso billing account, copy aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx. Paste the value somewhere so that you can use it in the next step.
---
## Find customers that have Azure plans
Make the following request, with the `name` copied from the first step (```aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx```) to list all customers in the billing account for whom you can create Azure subscriptions.
### [REST](#tab/rest)
```json
GET https://management.azure.com/providers/Microsoft.Billing/billingAccounts/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers?api-version=2020-05-01
```
The API response lists the customers in the billing account with Azure plans. You can create subscriptions for these customers.
```json
{
"totalCount": 2,
"value": [
{
"id": "/providers/Microsoft.Billing/billingAccounts/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f",
"name": "bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f",
"properties": {
"billingProfileDisplayName": "Fabrikam toys Billing Profile",
"billingProfileId": "/providers/Microsoft.Billing/billingAccounts/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/billingProfiles/YL4M-xxxx-xxx-xxx",
"displayName": "Fabrikam toys"
},
"type": "Microsoft.Billing/billingAccounts/customers"
},
{
"id": "/providers/Microsoft.Billing/billingAccounts/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/acba85c9-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"name": "acba85c9-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"properties": {
"billingProfileDisplayName": "Contoso toys Billing Profile",
"billingProfileId": "/providers/Microsoft.Billing/billingAccounts/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/billingProfiles/YL4M-xxxx-xxx-xxx",
"displayName": "Contoso toys"
},
"type": "Microsoft.Billing/billingAccounts/customers"
}
]
}
```
Use the `displayName` property to identify the customer for which you want to create subscriptions. Copy the `id` for the customer. For example, to create a subscription for `Fabrikam toys`, copy `/providers/Microsoft.Billing/billingAccounts/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f`. Paste the value somewhere to use it in later steps.
### [PowerShell](#tab/azure-powershell)
Please use either Azure CLI or REST API to get this value.
### [Azure CLI](#tab/azure-cli)
```azurecli
az billing customer list --account-name aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx
```
The API response lists the customers in the billing account with Azure plans. You can create subscriptions for these customers.
```json
[
{
"billingProfileDisplayName": "Fabrikam toys Billing Profile",
"billingProfileId": "providers/Microsoft.Billing/billingAccounts/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f",
"displayName": "Fabrikam toys",
"id": "providers/Microsoft.Billing/billingAccounts/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f",
"name": "acba85c9-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"resellers": null,
"type": "Microsoft.Billing/billingAccounts/customers"
},
{
"billingProfileDisplayName": "Contoso toys Billing Profile",
"billingProfileId": "/providers/Microsoft.Billing/billingAccounts/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/acba85c9-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"displayName": "Contoso toys",
"id": "/providers/Microsoft.Billing/billingAccounts/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/acba85c9-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"name": "aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e",
"resellers": null,
"type": "Microsoft.Billing/billingAccounts/customers"
}
]
```
Use the `displayName` property to identify the customer for which you want to create subscriptions. Copy the `id` for the customer. For example, to create a subscription for `Fabrikam toys`, copy `/providers/Microsoft.Billing/billingAccounts/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f`. Paste the value somewhere to use it in later steps.
---
## Get the resellers for a customer
This section is optional for Indirect providers only.
If you're an Indirect provider in the CSP two-tier model, you can specify a reseller while creating subscriptions for customers.
### [REST](#tab/rest)
Make the following request, with the `id` copied from the second step (```/providers/Microsoft.Billing/billingAccounts/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/2281f543-xxxx-xxxx-xxxx-xxxxxxxxxxxx```) to list all resellers that are available for a customer.
```json
GET "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/99a13315-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/2281f543-xxxx-xxxx-xxxx-xxxxxxxxxxxx?$expand=resellers&api-version=2020-05-01"
```
The API response lists the resellers for the customer:
```json
{
"value": [{
"id": "/providers/Microsoft.Billing/billingAccounts/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/2ed2c490-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"name": "2ed2c490-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"type": "Microsoft.Billing/billingAccounts/customers",
"properties": {
"billingProfileDisplayName": "Fabrikam toys Billing Profile",
"billingProfileId": "/providers/Microsoft.Billing/billingAccounts/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/billingProfiles/YL4M-xxxx-xxx-xxx",
"displayName": "Fabrikam toys",
"resellers": [
{
"resellerId": "3xxxxx",
"description": "Wingtip"
}
]
}
}]
}
```
Use the `description` property to identify the reseller who is associated with the subscription. Copy the `resellerId` for the reseller. For example, to associate `Wingtip`, copy `3xxxxx`. Paste the value somewhere so that you can use it in the next step.
### [PowerShell](#tab/azure-powershell)
Please use either Azure CLI or REST API to get this value.
### [Azure CLI](#tab/azure-cli)
Make the following request, with the `name` copied from the first step (```aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx```) and customer `name` copied from the previous step (```acba85c9-xxxx-xxxx-xxxx-xxxxxxxxxxxx```).
```azurecli
az billing customer show --expand "enabledAzurePlans,resellers" --account-name "aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx" --name "acba85c9-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
```
The API response lists the resellers for the customer:
```json
{
"billingProfileDisplayName": "Fabrikam toys Billing Profile",
"billingProfileId": "/providers/Microsoft.Billing/billingAccounts/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/billingProfiles/YL4M-xxxx-xxx-xxx",
"displayName": "Fabrikam toys",
"enabledAzurePlans": [
{
"skuDescription": "Microsoft Azure Plan",
"skuId": "0001"
}
],
"id": "/providers/Microsoft.Billing/billingAccounts/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/2ed2c490-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"name": "2ed2c490-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"resellers": [
{
"description": "Wingtip",
"resellerId": "3xxxxx"
}
],
"type": "Microsoft.Billing/billingAccounts/customers"
}
```
Use the `description` property to identify the reseller who is associated with the subscription. Copy the `resellerId` for the reseller. For example, to associate `Wingtip`, copy `3xxxxx`. Paste the value somewhere so that you can use it in the next step.
---
## Create a subscription for a customer
The following example creates a subscription named *Dev Team subscription* for *Fabrikam toys* and associate *Wingtip* reseller to the subscription. You use the copied billing scope from previous step: `/providers/Microsoft.Billing/billingAccounts/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/2281f543-xxxx-xxxx-xxxx-xxxxxxxxxxxx`.
### [REST](#tab/rest)
```json
PUT https://management.azure.com/providers/Microsoft.Subscription/aliases/{{guid}}?api-version=2021-10-01api-version=2021-10-01
```
### Request body
```json
{
"properties":
{
"billingScope": "/providers/Microsoft.Billing/billingAccounts/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/2281f543-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"DisplayName": "Dev Team subscription",
"Workload": "Production"
}
}
```
### Response
```json
{
"id": "/providers/Microsoft.Subscription/aliases/sampleAlias",
"name": "sampleAlias",
"type": "Microsoft.Subscription/aliases",
"properties": {
"subscriptionId": "aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e",
"provisioningState": "Accepted"
}
}
```
You can do a GET on the same URL to get the status of the request.
### Request
```json
GET https://management.azure.com/providers/Microsoft.Subscription/aliases/{{guid}}?api-version=2021-10-01
```
### Response
```json
{
"id": "/providers/Microsoft.Subscription/aliases/sampleAlias",
"name": "sampleAlias",
"type": "Microsoft.Subscription/aliases",
"properties": {
"subscriptionId": "cccc2c2c-dd3d-ee4e-ff5f-aaaaaa6a6a6a",
"provisioningState": "Succeeded"
}
}
```
An in-progress status is returned as an `Accepted` state under `provisioningState`.
Pass the optional *resellerId* copied from the second step in the request body of the API.
### [PowerShell](#tab/azure-powershell)
To install the version of the module that contains the `New-AzSubscriptionAlias` cmdlet, in below example run `Install-Module Az.Subscription -RequiredVersion 0.9.0`. To install version 0.9.0 of PowerShellGet, see [Get PowerShellGet Module](/powershell/gallery/powershellget/install-powershellget).
Run the following New-AzSubscriptionAlias command, using the billing scope `"/providers/Microsoft.Billing/billingAccounts/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/2281f543-xxxx-xxxx-xxxx-xxxxxxxxxxxx"`.
```azurepowershell
New-AzSubscriptionAlias -AliasName "sampleAlias" -SubscriptionName "Dev Team Subscription" -BillingScope "/providers/Microsoft.Billing/billingAccounts/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/2281f543-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -Workload 'Production"
```
You get the subscriptionId as part of the response from the command.
```json
{
"id": "/providers/Microsoft.Subscription/aliases/sampleAlias",
"name": "sampleAlias",
"properties": {
"provisioningState": "Succeeded",
"subscriptionId": "aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e"
},
"type": "Microsoft.Subscription/aliases"
}
```
Pass the optional *resellerId* copied from the second step in the `New-AzSubscriptionAlias` call.
### [Azure CLI](#tab/azure-cli)
First, install the extension by running `az extension add --name account` and `az extension add --name alias`.
Run the following [az account alias create](/cli/azure/account/alias#az-account-alias-create) command.
```azurecli
az account alias create --name "sampleAlias" --billing-scope "/providers/Microsoft.Billing/billingAccounts/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/2281f543-xxxx-xxxx-xxxx-xxxxxxxxxxxx" --display-name "Dev Team Subscription" --workload "Production"
```
You get the subscriptionId as part of the response from command.
```json
{
"id": "/providers/Microsoft.Subscription/aliases/sampleAlias",
"name": "sampleAlias",
"properties": {
"provisioningState": "Succeeded",
"subscriptionId": "aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e"
},
"type": "Microsoft.Subscription/aliases"
}
```
Pass the optional *resellerId* copied from the second step in the `az account alias create` call.
---
## Use ARM template or Bicep
The previous section showed how to create a subscription with PowerShell, CLI, or REST API. If you need to automate creating subscriptions, consider using an Azure Resource Manager template (ARM template) or [Bicep file](../../azure-resource-manager/bicep/overview.md).
The following ARM template creates a subscription. For `billingScope`, provide the customer ID. The subscription is created in the root management group. After creating the subscription, you can move it to another management group.
```json
{
"$schema": "https://schema.management.azure.com/schemas/2019-08-01/managementGroupDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"subscriptionAliasName": {
"type": "string",
"metadata": {
"description": "Provide a name for the alias. This name will also be the display name of the subscription."
}
},
"billingScope": {
"type": "string",
"metadata": {
"description": "Provide the full resource ID of billing scope to use for subscription creation."
}
}
},
"resources": [
{
"scope": "/",
"name": "[parameters('subscriptionAliasName')]",
"type": "Microsoft.Subscription/aliases",
"apiVersion": "2021-10-01",
"properties": {
"workLoad": "Production",
"displayName": "[parameters('subscriptionAliasName')]",
"billingScope": "[parameters('billingScope')]"
}
}
],
"outputs": {}
}
```
Or, use a Bicep file to create the subscription.
```bicep
targetScope = 'managementGroup'
@description('Provide a name for the alias. This name will also be the display name of the subscription.')
param subscriptionAliasName string
@description('Provide the full resource ID of billing scope to use for subscription creation.')
param billingScope string
resource subscriptionAlias 'Microsoft.Subscription/aliases@2021-10-01' = {
scope: tenant()
name: subscriptionAliasName
properties: {
workload: 'Production'
displayName: subscriptionAliasName
billingScope: billingScope
}
}
```
Deploy the template at the [management group level](../../azure-resource-manager/templates/deploy-to-management-group.md). The following examples show deploying the JSON ARM template, but you can deploy a Bicep file instead.
### [REST](#tab/rest)
```json
PUT https://management.azure.com/providers/Microsoft.Management/managementGroups/mg1/providers/Microsoft.Resources/deployments/exampledeployment?api-version=2020-06-01
```
With a request body:
```json
{
"location": "eastus",
"properties": {
"templateLink": {
"uri": "http://mystorageaccount.blob.core.windows.net/templates/template.json"
},
"parameters": {
"subscriptionAliasName": {
"value": "sampleAlias"
},
"billingScope": {
"value": "/providers/Microsoft.Billing/billingAccounts/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/2281f543-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
},
"mode": "Incremental"
}
}
```
### [PowerShell](#tab/azure-powershell)
```azurepowershell
New-AzManagementGroupDeployment `
-Name exampledeployment `
-Location eastus `
-ManagementGroupId mg1 `
-TemplateFile azuredeploy.json `
-subscriptionAliasName sampleAlias `
-billingScope "/providers/Microsoft.Billing/billingAccounts/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/2281f543-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
```
### [Azure CLI](#tab/azure-cli)
```azurecli
az deployment mg create \
--name exampledeployment \
--location eastus \
--management-group-id mg1 \
--template-file azuredeploy.json \
--parameters subscriptionAliasName='sampleAlias' billingScope='/providers/Microsoft.Billing/billingAccounts/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/2281f543-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
```
---
To move a subscription to a new management group, use the following ARM template.
```json
{
"$schema": "https://schema.management.azure.com/schemas/2019-08-01/managementGroupDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"targetMgId": {
"type": "string",
"metadata": {
"description": "Provide the ID of the management group that you want to move the subscription to."
}
},
"subscriptionId": {
"type": "string",
"metadata": {
"description": "Provide the ID of the existing subscription to move."
}
}
},
"resources": [
{
"scope": "/",
"type": "Microsoft.Management/managementGroups/subscriptions",
"apiVersion": "2020-05-01",
"name": "[concat(parameters('targetMgId'), '/', parameters('subscriptionId'))]",
"properties": {
}
}
],
"outputs": {}
}
```
Or, the following Bicep file.
```bicep
targetScope = 'managementGroup'
@description('Provide the ID of the management group that you want to move the subscription to.')
param targetMgId string
@description('Provide the ID of the existing subscription to move.')
param subscriptionId string
resource subToMG 'Microsoft.Management/managementGroups/subscriptions@2020-05-01' = {
scope: tenant()
name: '${targetMgId}/${subscriptionId}'
}
```
## Next steps
* Now that you've created a subscription, you can grant that ability to other users and service principals. For more information, see [Grant access to create Azure Enterprise subscriptions (preview)](grant-access-to-create-subscription.md).
* For more information about managing large numbers of subscriptions using management groups, see [Organize your resources with Azure management groups](../../governance/management-groups/overview.md).
* For advanced subscription creation scenarios using REST API, see [Alias - Create](/rest/api/subscription/2021-10-01/alias/create).