2

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,

Gene Laisne
  • 120
  • 1
  • 7
  • Could you include details such as, "I searched X Y and Z modules" or "I could not identify the web request at X/Y"? – Jacob Colvin Oct 01 '18 at 15:08
  • I did web searches with no luck. I attempted to look into subscriptions, subscription context the AzureRM.Billing module had some promis, but didn't work out. I looked into the equivalent rest API (billing) and the offerID is there but is more tied to the resource, than the subscription. Does that help? – Gene Laisne Oct 01 '18 at 15:47

6 Answers6

2

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:

  1. Acquire an Bearer authentication token

  2. Assemble a POST REST call

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
    }
}
  • I've managed to come back around to this. Unfortunately, I wasn't able to get this to work. thanks for you time anyways. – Gene Laisne Mar 08 '19 at 19:50
  • If you use the token that that is assigned to you when logging in the Azure Portal it's going to work. If you have an actual Application that uses the https://management.core.windows.net/user_impersonation scope, you will get unauthorized on the https://s2.billing.ext.azure.com endpoint, since only the Azure Portal AppId is authorized. – Alexandre Aug 13 '20 at 17:13
2

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
fostejo
  • 36
  • 2
1

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.

enter image description here

You will get response as shown below with offer id:

enter image description here

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

Nikunj Banker
  • 717
  • 7
  • 7
0

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/

John Bull
  • 933
  • 1
  • 12
  • 20
  • 1
    So, I have 60+ subscriptions, and we, from time to time, do M&As where the subscription should be under MSDN or Enterprise. I want to have a script which can pull the offer out of existing subscriptions so I know if I have to move them to the proper subscription. – Gene Laisne Oct 01 '18 at 19:57
0

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

Msalvatori
  • 37
  • 1
  • 7
0

No, but there is already a feature request, please vote for it.

Tomas Kubes
  • 23,880
  • 18
  • 111
  • 148