是否可以通过Azure获得Azure订阅要约或offerId?

时间:2018-10-01 14:59:24

标签: azure powershell subscription

是否可以使用Powershell获得Azure订阅要约或offerId?通过门户网站,这是订阅->属性->优惠还是优惠ID?

我已经搜索了一段时间,但看不到。

谢谢

6 个答案:

答案 0 :(得分:0)

取决于您需要什么。通过PS脚本获取OfferTypes没有意义,因为您不会像这样创建新的订阅。这个过程比这更复杂。虽然,如果您只需要列表,可以在MS网站上找到: https://azure.microsoft.com/en-us/support/legal/offer-details/

答案 1 :(得分:0)

不幸的是,我认为不可能。我认为找到解决您的问题的方法是明智的。

也许您将来可以添加一个请求以添加此功能: https://github.com/Azure/azure-docs-powershell/blob/master/azuresmps-4.0.0/AzureRM.Profile/Get-AzureRmSubscription.md

答案 2 :(得分:0)

有一种非正式的可能性来获取由Azure门户本身使用的商品ID。我通过订阅对其进行了测试,并且可以正常工作。这可能会导致特定商品ID出现问题。请对此提供反馈。

这些是必需的步骤:

  1. 获取承载身份验证令牌

  2. 组装POST REST呼叫

结果如下:

{
    "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
    }
}

答案 3 :(得分:0)

现在可以使用“资源图资源管理器”从门户网站执行以下查询:

resourcecontainers
| where type == "microsoft.resources/subscriptions"
| project name, properties.subscriptionPolicies.quotaId

答案 4 :(得分:0)

否,但是已经有功能请求please vote for it

答案 5 :(得分:0)

有一种使用 Azure REST API 获取优惠 ID 的官方方法。确保使用 API 版本作为 api-version=2019-10-01

端点: 获取https://management.azure.com/{scope}/providers/Microsoft.Consumption/usageDetails?api-version=2019-10-01

您可以通过点击以下网址运行\尝试: https://docs.microsoft.com/en-us/rest/api/consumption/usagedetails/list#code-try-0

当然,您需要使用您的 Azure 用户 ID 和密码登录才能试用\测试。

enter image description here

您将收到如下所示的响应,其中包含报价 ID:

enter image description here

更多详情,请参阅使用详情 - 列表 API:https://docs.microsoft.com/en-us/rest/api/consumption/usagedetails/list

注意:它不是 PowerShell 方式,但您可以使用 PowerShell/curl 调用 REST Api。参考https://mauridb.medium.com/calling-azure-rest-api-via-curl-eb10a06127