Is it possible to get Azure Subscription Offer, or offerId, using Powershell? Through the portal this would be Subscription -> properties -> Offer or offer ID?
I've been searching for a while, but I can't see it.
Thanks,
Is it possible to get Azure Subscription Offer, or offerId, using Powershell? Through the portal this would be Subscription -> properties -> Offer or offer ID?
I've been searching for a while, but I can't see it.
Thanks,
There is an unofficial possibility to get the offer id which is used by the Azure Portal itself. I tested it with my subscription and it worked. It may lead to issues for specific offer ids. Please provide feedback on that.
These are the required steps:
Acquire an Bearer authentication token
Assemble a POST REST call
{ "subscriptionId": "########-####-####-####-############" }
The result looks like this:
{ "accountInfo": { "userRole": 6, "billingSystemType": 2, "isAccountAdmin": true, "isTokenMatch": false, "locale": "en-US", "currency": "EUR", "countryCode": "DE", "accountAdminEmail": "****@****.com", "commerceAccountId": "########-####-####-####-############", "currencyMigrationInfo": null, "displaySpecifiedRole": false }, "essentials": { "offerId": "MS-AZR-0063P", "roles": { "2": null, "4": { "isDirectCancel": true }, "5": null }, "freeMetersEndDate": null, "provisioningStatus": 1, "hasPendingTransfer": false } }
This can now be done from the Portal using the Resource Graph Explorer with a query similar to:
resourcecontainers
| where type == "microsoft.resources/subscriptions"
| project name, properties.subscriptionPolicies.quotaId
There is an official way to get offer id using Azure REST API. Make sure to use API version as api-version=2019-10-01
Endpoint: GET https://management.azure.com/{scope}/providers/Microsoft.Consumption/usageDetails?api-version=2019-10-01
You can run\try try by hitting below url: https://learn.microsoft.com/en-us/rest/api/consumption/usagedetails/list#code-try-0
Of Course, you need to login with your Azure user id and password to try\test it.
You will get response as shown below with offer id:
For more detail, please refer Usage Details - List API: https://learn.microsoft.com/en-us/rest/api/consumption/usagedetails/list.
Note: Its not PowerShell way but you can invoke REST Api using PowerShell/curl. Ref. https://mauridb.medium.com/calling-azure-rest-api-via-curl-eb10a06127
Depends what do you need it for. There is no point in getting OfferTypes via PS script as you won't be creating the new subscription like this. The process is more complicated than that. Although, if you just need a list, it is available on the MS website: https://azure.microsoft.com/en-us/support/legal/offer-details/
Unfortunally, I don't think it is possible. I think it would be wise to find a work around solution for your problem.
And maybe you could add a request to add this functionality in the future: https://github.com/Azure/azure-docs-powershell/blob/master/azuresmps-4.0.0/AzureRM.Profile/Get-AzureRmSubscription.md