azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

"Offer id MS-AZR-0017P is not supported" error from Get-AzureRMBillingInvoice

Open LRSFC-DanJ opened this issue 8 years ago • 18 comments

Description

When attempting to get a list of Azure billing invoices using Get-AzureRmBillingInvoice, I receive an error as follows:

"WARNING: Offer id MS-AZR-0017P is not supported."

Script/Steps for Reproduction

I connect to AzureRM on our Azure tenant using Connect-AzureRmAccount and a previously created PSCredential object which contains the credentials for our tenant administrator account.

Connect-AzureRmAccount -Credential $cred -TenantId <our tenant ID redacted>

I am able to get a list of the Billing Periods using Get-AzureRmBillingPeriod, however if I try to use Get-AzureRmBillingInvoice I receive the above mentioned error.

Module Version

Get-Module -Name AzureRM -ListAvailable

    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     6.9.0      AzureRM

Environment Data

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.14393.2189
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.2189
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Debug Output

$DebugPreference = "Continue"
Get-AzureRMBillingInvoice
DEBUG: 10:51:07 - GetAzureRmBillingInvoice begin processing with ParameterSet 'List'.
DEBUG: 10:51:07 - using account id 'REDACTED'...
DEBUG: [Common.Authentication]: Authenticating using Account: 'REDACTED', environment:
'AzureCloud', tenant: 'REDACTED'
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/26/2018 09:51:07: 248bcd21-e964-4474-bb92-c65db4e319a6 - AcquireTokenHandlerBase: === Token Acquisition
started:
 Authority: https://login.microsoftonline.com/930756ea-99b7-4f82-b300-93cb3f6f112e/
 Resource: https://management.core.windows.net/
 ClientId: 1950a258-227b-4e31-a9cf-717495945fc2
 CacheType: Microsoft.Azure.Commands.Common.Authentication.ProtectedFileTokenCache (1 items)
 Authentication Target: User

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/26/2018 09:51:07:  - TokenCache: Deserialized 1 items to token cache.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 09/26/2018 09:51:07: 248bcd21-e964-4474-bb92-c65db4e319a6 - TokenCache: Looking up cache for a token...
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/26/2018 09:51:07: 248bcd21-e964-4474-bb92-c65db4e319a6 - TokenCache: An item matching the requested resource
was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 09/26/2018 09:51:07: 248bcd21-e964-4474-bb92-c65db4e319a6 - TokenCache: 9.29783442166667 minutes left until
token in cache expires
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/26/2018 09:51:07: 248bcd21-e964-4474-bb92-c65db4e319a6 - TokenCache: A matching item (access token or refresh
 token or both) was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/26/2018 09:51:07: 248bcd21-e964-4474-bb92-c65db4e319a6 - AcquireTokenHandlerBase: === Token Acquisition
finished successfully. An access token was retuned:
 Access Token Hash: d1jMhVvV6KV5KhIMINA5ppYAiAC+3VbfZ4VD+ujYYRA=
 Refresh Token Hash: rMT1PjTZrIeEqE0Qv4hC2n/luigdpcVMhq9Qjeswg2o=
 Expiration Time: 09/26/2018 10:00:24 +00:00
 User Hash: +YH6u+fO3TyQffcnUTLAxqA5UDniYg5RPbuepxFe+ak=

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/26/2018 09:51:07: 584d429b-ba31-44fc-b4d1-f66f6a517996 - AcquireTokenHandlerBase: === Token Acquisition
started:
 Authority: https://login.microsoftonline.com/930756ea-99b7-4f82-b300-93cb3f6f112e/
 Resource: https://management.core.windows.net/
 ClientId: 1950a258-227b-4e31-a9cf-717495945fc2
 CacheType: Microsoft.Azure.Commands.Common.Authentication.ProtectedFileTokenCache (1 items)
 Authentication Target: User

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/26/2018 09:51:07:  - TokenCache: Deserialized 1 items to token cache.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 09/26/2018 09:51:07: 584d429b-ba31-44fc-b4d1-f66f6a517996 - TokenCache: Looking up cache for a token...
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/26/2018 09:51:07: 584d429b-ba31-44fc-b4d1-f66f6a517996 - TokenCache: An item matching the requested resource
was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 09/26/2018 09:51:07: 584d429b-ba31-44fc-b4d1-f66f6a517996 - TokenCache: 9.29780077 minutes left until token in
cache expires
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/26/2018 09:51:07: 584d429b-ba31-44fc-b4d1-f66f6a517996 - TokenCache: A matching item (access token or refresh
 token or both) was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/26/2018 09:51:07: 584d429b-ba31-44fc-b4d1-f66f6a517996 - AcquireTokenHandlerBase: === Token Acquisition
finished successfully. An access token was retuned:
 Access Token Hash: d1jMhVvV6KV5KhIMINA5ppYAiAC+3VbfZ4VD+ujYYRA=
 Refresh Token Hash: rMT1PjTZrIeEqE0Qv4hC2n/luigdpcVMhq9Qjeswg2o=
 Expiration Time: 09/26/2018 10:00:24 +00:00
 User Hash: +YH6u+fO3TyQffcnUTLAxqA5UDniYg5RPbuepxFe+ak=

DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.azure.com/subscriptions/dfe9fd61-a6da-481c-a3a7-b4d37d88bc22/providers/Microsoft.Billing/invoices?ap
i-version=2018-03-01-preview

Headers:
x-ms-client-request-id        : 169ecc54-75dd-48a5-b9f9-0ffb164853f2
accept-language               : en-US

Body:


DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
BadRequest

Headers:
Pragma                        : no-cache
Strict-Transport-Security     : max-age=31536000; includeSubDomains
x-ms-ratelimit-remaining-subscription-resource-requests: 99
x-ms-request-id               : 3756c7fb-d7c5-4a90-943d-327f7003cb5a
x-ms-correlation-request-id   : 3756c7fb-d7c5-4a90-943d-327f7003cb5a
x-ms-routing-request-id       : UKSOUTH:20180926T095101Z:3756c7fb-d7c5-4a90-943d-327f7003cb5a
X-Content-Type-Options        : nosniff
Cache-Control                 : no-cache
Date                          : Wed, 26 Sep 2018 09:51:01 GMT
Server                        : Microsoft-IIS/8.5
X-AspNet-Version              : 4.0.30319
X-Powered-By                  : ASP.NET

Body:
{
  "error": {
    "code": "UnsupportedSubscriptionType",
    "target": "MS-AZR-0017P",
    "message": "Offer id MS-AZR-0017P is not supported."
  }
}

WARNING: Offer id MS-AZR-0017P is not supported.
DEBUG: AzureQoSEvent: CommandName - Get-AzureRmBillingInvoice; IsSuccess - True; Duration - 00:00:04.2179353; Exception
 - ;
DEBUG: Finish sending metric.
DEBUG: 10:51:12 - GetAzureRmBillingInvoice end processing.
DEBUG: 10:51:12 - GetAzureRmBillingInvoice end processing.

Other notes: I already tried assigning the "Billing Reader" role to the user account I am trying to use for this, but that did not solve the issue.

Thanks, Dan Jackson (Senior ITServices Technician) Long Road Sixth Form College Cambridge, UK.

LRSFC-DanJ avatar Sep 26 '18 09:09 LRSFC-DanJ

The issue also occurs if I just use Connect-AzureRmAccount by itself and use an interactive login, then try to do Get-AzureRmBillingInvoice.

LRSFC-DanJ avatar Sep 26 '18 13:09 LRSFC-DanJ

@wilcobmsft would you mind taking a look at this issue?

cormacpayne avatar Sep 26 '18 15:09 cormacpayne

I'm also experiencing this issue. Same AzureRM and PS version as Dan.

robinmalik avatar Oct 24 '18 17:10 robinmalik

I'm also experiencing this issue. Same AzureRM and PS version as Dan.

It's also not fixed in version 6.10.0 which I believe came out this month.

LRSFC-DanJ avatar Oct 25 '18 07:10 LRSFC-DanJ

Same issue

PS Z:\scripts> Get-AzureRmBillingInvoice -Latest WARNING: Offer id MS-AZR-0017P is not supported.

PS Z:\scripts> Get-Module AzureRM.Billing

ModuleType Version Name ExportedCommands


Script 0.14.0 AzureRM.Billing {Get-AzureRmBillingInvoice, Get-AzureRmBillingPeriod}

Sambsamb avatar Oct 29 '18 22:10 Sambsamb

Same issue for me, any update?

ninocrudele avatar Nov 02 '18 14:11 ninocrudele

I solved the issue using a different subscription type, I used the type MS-AZR-0003p, but I also used Web API call and not PowerShell. Using the same API call and using MS-AZR-0017P I get the error below:

An error occurred! The service returned: StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.StreamContent, Headers: { Pragma: no-cache X-MS-Correlation-Id: adbb24b9-70bd-0001-ea4a-beadbd70d401 X-Content-Type-Options: nosniff x-ms-ratelimit-remaining-subscription-reads: 11999 x-ms-request-id: 1af98cc1-9cc8-40e3-8ac2-55f10e8d8514 x-ms-correlation-request-id: 1af98cc1-9cc8-40e3-8ac2-55f10e8d8514 x-ms-routing-request-id: UKSOUTH2:20181104T194336Z:1af98cc1-9cc8-40e3-8ac2-55f10e8d8514 Strict-Transport-Security: max-age=31536000; includeSubDomains Cache-Control: no-cache Date: Sun, 04 Nov 2018 19:43:36 GMT Server: Microsoft-IIS/10.0 Content-Length: 86 Content-Type: application/json; charset=utf-8 Expires: -1 }Content: {"Message":"Invalid offer durable Id MS-AZR-00017P\r\nParameter name: offerDurableId"}

Below the list of not supported subscription types, https://azure.microsoft.com/en-us/blog/enhancements-to-cost-management-apis/ I don't see it on that list, why the PWS call is supposing to use that type? Does exist a way to specify a specific subscription type in the PWS call?

Thanks Nino

ninocrudele avatar Nov 04 '18 19:11 ninocrudele

Offer MS-AZR-0017P relates to an Enterprise Agreement Offer and I think that you can only use the EA portal for billing queries

kilasuit avatar Nov 05 '18 01:11 kilasuit

ok I can essentially use Get-AzureRmConsumptionUsageDetail from the portal only, I tried that and it works. Using from the client I get as below PS C:\Windows\system32> Get-AzureRmConsumptionUsageDetail WARNING: Offer id MS-AZR-0017P is not supported.

ninocrudele avatar Nov 05 '18 10:11 ninocrudele

ok I can essentially use Get-AzureRmConsumptionUsageDetail from the portal only, I tried that and it works. Using from the client I get as below PS C:\Windows\system32> Get-AzureRmConsumptionUsageDetail WARNING: Offer id MS-AZR-0017P is not supported.

Presumably using it from the portal though, it's not possible to use a script to do things with the retrieved billing data?

LRSFC-DanJ avatar Nov 05 '18 10:11 LRSFC-DanJ

ok I can essentially use Get-AzureRmConsumptionUsageDetail from the portal only, I tried that and it works. Using from the client I get as below PS C:\Windows\system32> Get-AzureRmConsumptionUsageDetail WARNING: Offer id MS-AZR-0017P is not supported.

Presumably using it from the portal though, it's not possible to use a script to do things with the retrieved billing data?

I don't know, I would like to have an official answer on that, I don't see anything in the documentation around, not clear for me....

ninocrudele avatar Nov 05 '18 11:11 ninocrudele

I definitely solved the issue by updating all modules executing the command below Install-Module -Name AzureRM -Repository PSGallery -Force Now I am able to exclude any command from AzureRM.Consuption like Get-AzureRmConsumptionPriceSheet without get the exception below. WARNING: Offer id MS-AZR-0017P is not supported.

Hope this can help.

ninocrudele avatar Nov 05 '18 13:11 ninocrudele

I definitely solved the issue by updating all modules executing the command below Install-Module -Name AzureRM -Repository PSGallery -Force Now I am able to exclude any command from AzureRM.Consuption like Get-AzureRmConsumptionPriceSheet without get the exception below. WARNING: Offer id MS-AZR-0017P is not supported.

Hope this can help.

I am trying to use Get-AzureRMBillingInvoice however, which is still showing this error.

LRSFC-DanJ avatar Nov 05 '18 14:11 LRSFC-DanJ

I definitely solved the issue by updating all modules executing the command below Install-Module -Name AzureRM -Repository PSGallery -Force Now I am able to exclude any command from AzureRM.Consuption like Get-AzureRmConsumptionPriceSheet without get the exception below. WARNING: Offer id MS-AZR-0017P is not supported. Hope this can help.

I am trying to use Get-AzureRMBillingInvoice however, which is still showing this error.

I think I am starting understanding the issue here... I had this error executing Get-AzureRmConsumptionUsageDetail (AzureRM.Consumption) on my laptop, but I was able to run this Cmdlet in the Azure Portal. I solved the problem with updating the PowerShell modules.

If I tried to execute the Get-AzureRMBillingInvoice I get your same exception, even executing the same command in the Azure Portal. I think this is an issue in the AzureRM.Billing module that needs to be solved. The MS-AZR-0017Pis just the EA offer, I am EA, so it should work as is working the other calls now.

Make sense?

ninocrudele avatar Nov 05 '18 14:11 ninocrudele

I can confirm that this issue still exists for me with version 6.13.1 of the AzureRM module.

LRSFC-DanJ avatar Nov 22 '18 08:11 LRSFC-DanJ

Still on AzureRm 6.13.1. Still a problem in June 2019.

Same result with Az 2.2.0.

robinmalik avatar Jun 06 '19 14:06 robinmalik

On Azure Python SDK 4.0.0 and this is still a problem. (August 1st 2019)

I have no problems with UsageDetail however, but all cost values are 0 no matter what I do.

pmontanaro avatar Aug 01 '19 01:08 pmontanaro

As mentioned in the discussion, MS-AZR-0017P is EA Offer and the api-version 2018-03-01-preview does not support EA Invoices.

Newer version of APIs are available that support all offer types. (i.e 2020-05-01).

New Billing commands will be available tentatively end of 2022.

muazmian avatar May 09 '22 17:05 muazmian