user13696433
user13696433

Reputation: 143

How do you get and storage data from the usage details api using powershell in azure?

A bit farther along now.

I've done the following:

  1. Set up an app registration in Azure.
  2. use a get request to query the usage details api using thunder client.

I am now trying to put this into a powershell script. I get a "Cannnot bind parameter Uri" error with my invoke-restmethod. I have successfully gotten my access token and this is the next step I am stuck at.

$Param = @{
   Method = 'Get'
   Uri = "https://management.azure.com/______/Microsoft.Consumption/usageDetails?..."
   Body = @{
         Authorization = $AccessToken
   }
}

$Execute = Invoke-RestMethod $Param

Help?

Edit: changed Invoke-RestMethod $Param to @Param with a new error: code Authentication failed authorization header missing.

Upvotes: 0

Views: 138

Answers (1)

user13696433
user13696433

Reputation: 143

Body should be Headers. Access Token Variable should have Bearer in front of it when using https://management.azure.com.

Upvotes: -1

Related Questions