get subscription offer id from cli
We have lots of subscriptions with different offer ID ( enterprise or dev/test MS-AZR-0148P or others ).
It would be nice if we can get the offer id for each subscription from "az account list" result.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 9abfaa54-0895-29f7-f3bb-ff604912b2ac
- Version Independent ID: d1ff3478-8a86-59e4-62ef-449900132a67
- Content: az account
- Content Source: src/azure-cli/azure/cli/command_modules/profile/_help.py
- Service: azure
- GitHub Login: @rloutlaw
- Microsoft Alias: routlaw
@jiasli pleaase take a look.
CLI uses Subscriptions - Get REST API to retrieve subscription details. This API doesn't have information about offer ID. Azure Portal fetches offer ID from https://s2.billing.ext.azure.com/api/Billing/Subscription/Subscription?api-version=2019-01-14.
@achandmsft, do you think this is a feature we need to implement with billing team?
Here's a real-world scenario where "something" would be useful ... Global Administrators (and others with permissions at Tenant Root) can view all subscriptions associated with the AAD tenant. In a scenario where we want to programmatically detect the creation of non-EA subscriptions or simply to run a query against these subscriptions, we currently have no means of doing so via CLI (without querying the REST API ... thanks for adding that). I'd rather stick to using a single toolset, if possible, though.
A user with enough permission on subscriptions level can see the subscriptions offer ID from Azure portal. On the other hand, most user don't have permission to access the billing API.
We fall back on Azure Resource Graph to make up for many of these shortcomings:
az graph query -q 'resourcecontainers | where type == "microsoft.resources/subscriptions" | where properties.state != "Disabled" | project subscriptionId, name, properties.subscriptionPolicies.quotaId'
The so-called quotaId isn't the same text as the OfferID, but can be mapped directly to it.
As mentioned above, offer ID is a billing construct so it is not available through the Subscription - Get API. The API does have quota ID, which can be used to differentiate subscriptions of different types (Ex: Microsoft Azure Enterprise, Pay as you go, etc.).
The so-called quotaId isn't the same text as the OfferID, but can be mapped directly to it.
That is not always the case when considering older subscriptions and multiple tenants in multiple countries.
As mentioned above, offer ID is a billing construct so it is not available through the Subscription - Get API
@amberbhargava 100%, it is required by some of the Pricesheet API, which are still required until Microsoft.Consumption and Microsoft.CostManagement providers fully supported all usage scenarios.
There's currently no workaround when managing multiple enrollements and subscriptions (100+) or when leveraging the partner ecosystem (3rd Party Solution to read/analyze costs, where manually mapping the OfferId is not possible).
The feature request on UserVoice is among the most popular, It would be incredibly useful for the bigger organisation and the partner ecosystem to have something along the lines of https://s2.billing.ext.azure.com/api/Billing/Subscription/Subscription?api-version=2019-01-14 available through a REST Api.
The API does have quota ID, which can be used to differentiate subscriptions of different types (Ex: Microsoft Azure Enterprise, Pay as you go, etc.).
Where is mapping from quotaId to offerId?
The feature request on UserVoice is among the most popular, It would be incredibly useful for the bigger organisation and the partner ecosystem to have something along the lines
Anyone has a new link for this? Looks like google does not find it anymore. (That's one way to solve feedback items.)
Same here.
My colleague finally found that Billing Subscriptions - List By Billing Account API includes the OfferId field.
az rest --url "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/{BillingAccountName}/billingSubscriptions?api-version=2024-04-01"
{
"totalCount": 25,
"value": [
{
"id": "/providers/Microsoft.Billing/billingAccounts/XXXXXXXX/billingSubscriptions/XXXXXXXX",
"name": "Name of subscription",
"properties": {
"displayName": "Name of subscription",
"offerId": "MS-AZR-0136P", <-------------- HERE
"operationStatus": "None",
"productCategory": "UsageBased",
"purchaseDate": "0001-01-01T00:00:00.0000000Z",
"status": "Active",
"subscriptionId": "Subscription Id",
"suspensionReasonDetails": [],
"suspensionReasons": []
},
"type": "Microsoft.Billing/billingAccounts/billingSubscriptions"
},