It is possible to get the Azure Subscription offer, or offerId with PowerShell?

谁说我不能喝 提交于 2019-12-02 07:12:05

问题


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,


回答1:


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

    • https://docs.microsoft.com/en-us/rest/api/azure/#acquire-an-access-token
  2. Assemble a POST REST call

    • URL: https://s2.billing.ext.azure.com/api/Billing/Subscription/Subscription
    • Headers: Add the authorization header with your Bearer token (Authorization: Bearer ej...)
    • Request Body Type: application/json
    • Request Body Content:
      {
      "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
    }
}



回答2:


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/




回答3:


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



来源:https://stackoverflow.com/questions/52593867/it-is-possible-to-get-the-azure-subscription-offer-or-offerid-with-powershell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!