If you’ve ever tried to create Azure Subscriptions with Terraform, AZ cli or via ARM api you’ll know that it was not possible up until recently. Previously you had to open a different UI to choose a billing model and create a new Subscription (even if it was bound to the same AD Tenant as your existing Subscription). Terrform and AZ work in the context of a Subscription so it was assumed you would have one before you started, however sometimes we need to create these automatically.
It looks like Microsoft are addressing this issue and converging their services and have introduced an API (preview) for programmatically creating subscriptions on the fly. According to this blog post in May it should be possible to use the AZ cli. However, there are a few traps for young players which I encountered so the following may help you:
Firstly, make sure you are on the latest version of AZ (at time of writing it is 2.0.45):
To install the Subscription module use:
Referencing the docs, you should now be able to create new Azure subscriptions with:
az --versionand upgrade if necessary. The command to create a Subscription lives in the Account module, however, if you try to run:
az account –helpYou’ll probably see there is no “create” command. At first I thought I had an old version of AZ but it turns out that AZ can be extended with extra modules via an extensions package manager. Who knew?! To see what AZ extensions you have installed you can run:
az extension list-available --output tableYour output will look something like the below, depending on what extensions you have installed.

az extension add --name subscriptionYou should now have the extension installed if you run this again:
az extension list-available --output tableNow if you get help on the AZ account you’ll see the “create” command:
az account –help

az account create --enrollment-account-name --offer-type {MS-AZR-0017P, MS-AZR-0148P}You can see your enrolment accounts with AZ billing module:
az billing enrollment-account listThere only seems to be 2 types of Subscriptions available for now – Enterprise and devTest (get better prices on your Azure resources in dev!), but this service is only in preview, so may change. Note: If you are within a large enterprise your mileage may vary. It seems to depend on the EA or CSP agreement that a company has with Microsoft. You can test if you have the ability to create subscriptions by going to the Azure Portal -> Subscriptions and clicking on the Add button. If you can create a Subscription through the UI you should be able to do it via the CLI or api. Yet another note: Extensions are all open-source as you would expect from the “new” MS. Feel free to enhance them or write your own: https://github.com/Azure/azure-cli-extensions To upgrade AZ Extensions you can run:
az extension update --name webappLet me know if you have any comments or questions…
Azure-certified Data Architect with a focus on delivering business value and guiding customers through the maze of analytical architectures, design and implementation activities.
Experienced in setting up modern data platforms with advanced predictive analytic workloads. Brings strong people skills and a devops-centric, entrepreneurial approach to Enterprise software delivery.
Experienced in setting up modern data platforms with advanced predictive analytic workloads. Brings strong people skills and a devops-centric, entrepreneurial approach to Enterprise software delivery.
Latest posts by Rodney Joyce (see all)
- Hiring: Azure Software Engineer - January 12, 2023
- 10 reasons to use Azure SQL in your next analytics project - November 3, 2020
- A Developer’s Guide to Building AI Application - September 4, 2020
-33.8688197151.2092955