Azure Advisor API - receiving 404

Dan 0 Reputation points


I'm trying to create an Azure Advisor Recommendation digest using the API by following this process:

I'm using Powershell and Azure modules to interact with the REST API but I'm getting a 404. I've also tried through the "try it" link on that documentation page (where I can select my subscription from a dropdown list after I've authenticated) and I get the same issue.

My code is something like this:

$azContext = Get-AzContext
$azProfile = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile
$profileClient = New-Object -TypeName Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient -ArgumentList ($azProfile)
$token = $profileClient.AcquireAccessToken($azContext.Subscription.TenantId)
$authHeader = @{
    'Authorization'='Bearer ' + $token.AccessToken

$advisorDigestBody = @{

  "properties" = @{
      "lowCpuThreshold" = 5
      "duration" = "7"
      "exclude" = false
      "digests" = @(
          "name" = "test-digest"
          "actionGroupResourceId" = "/subscriptions/XXXXXXX-XXXX-XXXXXX-XXXXXX-XXXXX/resourceGroups/rg01/providers/Microsoft.Insights/actiongroups/my-action-group-01"
          "frequency" = 30
          "categories" = @(
        "language" = "en"
        "state" = "Active"
  } | ConvertTo-Json -Depth 5

$createRGUri = ""

Invoke-RestMethod -Uri $createRGUri -Method Put -Headers $authHeader -Body $advisorDigestBody

It's possibly I'm just not using the right kind of call to the API to do what I need, but I can't seem to get around this 404 issue. The Subscription and Resource Group definitely exist and my account has access to them. I can see them in the portal. I ran the Set-AZContext command before putting my script together so I'm also targetting the subscription as well.

Any ideas where I'm going wrong?

Azure Advisor
Azure Advisor
An Azure personalized recommendation engine that helps users follow best practices to optimize Azure deployments.
13 questions
{count} votes