0

We have created a resource group with a VMSS instance within.

When running the "az vmss list" command within the Cloud Shell, we are able to get the respective resource.

CloudShell CLI Command output

However, when running the exact same command in PS, it returns an empty list, even though the resource exists.

Powershell

We have also created a different naming convention and used the ARM Api call to test this and we got the same outcome. See the command below:

Invoke-RestMethod -Uri https://management.azure.com/subscriptions/***/resourceGroups/***-nodepool-prd-devtest/providers/Microsoft.Compute/virtualMachineScaleSets?api-version=2020-12-01 -Method GET -Headers $headers -ContentType 'application/json'

Output:

value
-----
{}

We have tried to add another VMSS to the same resource group as a test and noticed that made the other one pop up. Creation of another vmss resolves the issue

It looks to me as if it is a caching issue but I can't figure out how to resolve it. Any ideas?

Things to keep in mind:

  • using the same CLI version as Cloud Shell (2.23.0)
  • running the command from the pipeline returns an empty list
  • a team member is able to get the resource from their own machine
SSeeker
  • 21
  • 3

1 Answers1

0

I saw the similar issue when a specific subscription wasn't show up in a list of output. We used below ps commands to resolve the issue:

Disable-AzureRmContextAutosave
Disconnect-AzureRmAccount

As you use the Az module, please try these:

Disable-AzContextAutosave
Disconnect-AzAccount

Source: https://github.com/Azure/azure-powershell/issues/6289

PS: it seems you need to edit the title to the "Azure PS command returns empty list"

  • Thanks for your input on this. I have tried the solution that you mentioned above but no joy. We are still experiencing this on local and also when running an inline script query in the pipeline. – SSeeker May 27 '21 at 13:21