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

Get-AzureRMResource not returning properties.

Open dnewsholme opened this issue 8 years ago • 15 comments

Description

DocumentDB Properties no longer returned via Get-AzureRMResource

Properties is always returned as null.

However browsing the api via https://resources.azure.com it shows that the properties value should be returned.

If trying by resource ID it still fails with an error.

Get-AzureRmResource -ResourceId /subscriptions/$((Get-Context).Subscription.id)/providers/Microsoft.DocumentDB/databaseAccounts -ApiVersion 2015-04-08

DEBUG: AzureQoSEvent: CommandName - Get-AzureRmResource; IsSuccess - False; Duration - 00:00:00.3413286; Exception - System.ArgumentException: Invalid format of the resource identifier. Parameter name: idFromServer at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components.ResourceIdentifier..ctor(String idFromServer) at Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkClient.ResourceManagerSdkClient.GetById(String resourceId, String apiVersion) at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.GetAzureResourceCmdlet.OnProcessRecord() at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.ResourceManagerCmdletBase.ExecuteCmdlet() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.ResourceManagerCmdletBase.HandleException(ExceptionDispatchInfo capturedException) at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.ResourceManagerCmdletBase.ExecuteCmdlet() at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord(); DEBUG: Finish sending metric.

Script/Steps for Reproduction

Get-AzureRmResource -ResourceType "Microsoft.DocumentDb/databaseAccounts"

Module Version

ModuleType Version Name ExportedCommands


Script 6.2.1 AzureRM Script 6.1.1 AzureRM

Environment Data

Name Value


PSVersion 5.1.14393.2125 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.14393.2125 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1

dnewsholme avatar Jun 12 '18 09:06 dnewsholme

@ratchetnclank Hey Daryl, would you mind setting $DebugPreference="Continue" and giving us the debug output from the above call?

cormacpayne avatar Jun 12 '18 15:06 cormacpayne

Same issue here. My existing script on getting AzureRM objects are failing with Invalid format of the resource identifier. All with parameter -ResourceId

DEBUG: AzureQoSEvent: CommandName - Get-AzureRmResource; IsSuccess - False; Duration - 00:00:04.8376631; Exception - System.ArgumentEx ception: Invalid format of the resource identifier. Parameter name: idFromServer at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components.ResourceIdentifier..ctor(String idFromServer) at Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkClient.ResourceManagerSdkClient.GetById(String resourceId, String apiVersion ) at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.GetAzureResourceCmdlet.OnProcessRecord() at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.ResourceManagerCmdletBase.ExecuteCmdlet() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.ResourceManagerCmdletBase.HandleException(ExceptionDispatchInfo capturedException) at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.ResourceManagerCmdletBase.ExecuteCmdlet() at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord(); DEBUG: Finish sending metric. DEBUG: 9:59:56 AM - GetAzureResourceCmdlet end processing. DEBUG: 9:59:56 AM - GetAzureResourceCmdlet end processing.

MathieuRietman avatar Jun 13 '18 08:06 MathieuRietman

Is a duplicate issue #6300 Get-AzureRmResource returns Get-AzureRmResource : Invalid format of the resource identifier. Parameter name: idFromServer on some resources Azure PS Team #6300

MathieuRietman avatar Jun 13 '18 08:06 MathieuRietman

This is a dupe of #6300, Closing this in favor of #6300.

praries880 avatar Jun 14 '18 18:06 praries880

Trying to understand the linked (and now closed) issue #6300 I don't see how I can resolve the clear problem statement in the title: Get-AzureRMResource not returning properties.

How do I get the properties of a resource with type Microsoft.DocumentDB/databaseAccounts? This task seems to no longer be possible using Azure PowerShell. The linked issue explains that It appears that "recommendations" are not tracked resources in Azure, and therefore do not appear when we make the GET call. However, does the same explanation apply to a Cosmos DB resource?

Liversage avatar Jun 27 '18 13:06 Liversage

@Liversage Use the command below.

Get-AzureRmResource -ResourceType "Microsoft.DocumentDb/databaseAccounts" -ExpandProperties

The error in #6300 only occurs when using resourceID parameter.

dnewsholme avatar Jun 27 '18 14:06 dnewsholme

@Liversage Hey Martin, sorry about the confusion. The error Invalid format of the resource identifier was seen from the first cmdlet call provided in the body of the original comment above, which is the same error seen in https://github.com/Azure/azure-powershell/issues/6300, so we closed the issue for that reason, but we should've left this issue open to track the status of the "no properties returned" issue that was being seen. As mentioned above by @ratchetnclank, providing the -ExpandProperties switch parameter with the DocumentDB resource type will return a list of DocumentDB resources with the properties field populated. The issue with the Invalid format of the resource identifier was discussed and resolved in https://github.com/Azure/azure-powershell/issues/6300 if you need any more information on that error. Please let me know if you have any other questions!

cormacpayne avatar Jun 27 '18 16:06 cormacpayne

@ratchetnclank @cormacpayne Thank you for your feedback. That was very useful.

Liversage avatar Jun 28 '18 08:06 Liversage

Cannot get properties to expand regardless of call or parameters:

$expandedResource = Get-AzureRmResource -ResourceGroupName $res.ResourceGroupName -Name $res.Name -ResourceType $res.ResourceType -ExpandProperties

$expandedResource = Find-AzureRmResource -ResourceGroupNameEquals $res.ResourceGroupName -ResourceNameEquals $res.Name -ResourceType $res.ResourceType -ExpandProperties

It doesn't matter if I use [Get|Find]-AzureRmResource properties always come back as null.

grecoe avatar Jan 15 '19 14:01 grecoe

I am also facing the same issue with Get-AzureRmResource -ResourceId $LabId -ApiVersion $ApiVersion for some resources its not returning mandatoryArtifactsResourceIdsWindows and for some it does

PrasadSudama avatar Jan 25 '19 14:01 PrasadSudama

I am also having an issue with Get-AzureRmResource. I am expecting the Get command to return false since the resource doesn't exist and i want to use that check to see weather i want to create the resource or not. Event though I have the ErrorAction set to "Silently Continue", I keep getting the error (Resource not found), and it stops processing, instead of it setting the $resourcevariable and letting me use that as a check further below. How can i get past this?

$resource = Get-AzureRmResource -ResourceName 'AppInsights' -ResourceType 'Microsoft.Insights/components' -ResourceGroupName 'AppInsights_RG' -ErrorAction SilentlyContinue Get-AzureRmResource : ResourceNotFound : The Resource 'Microsoft.Insights/componentsAppInsights' under resource group 'AppInsights_RG' was not found. At line:1 char:13

  • $resource = Get-AzureRmResource -ResourceName 'AppInsigh ...
  •         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    

afaruqi avatar Feb 04 '19 14:02 afaruqi

@afaruqi, I was facing issue with older module version 5.1.1 once I upgraded module in VSTS build pipeline to 6.7.0 for azure powershell task, Issue got resolved, may be you can give a try.

PrasadSudama avatar Feb 05 '19 07:02 PrasadSudama

I was able to get properties this way... dunno why... first call does not fetch properties but second yes... si i would be able to Enable/Disable all my availabilityTest at deploy time.

$AvailabitlyTests = Get-AzureRMResource -ResourceGroupName "myRG" -ResourceType microsoft.insights/webtests

foreach($Test in $AvailabitlyTests) { $WebTest = Get-AzureRMResource -ResourceGroupName "myRG" -ResourceType microsoft.insights/webtests -ResourceName $Test.Name

$WebTest.Properties.Enabled = !$WebTest.Properties.Enabled
$WebTest | Set-AzureRMResource -Force

}

perreaultd avatar Apr 05 '19 18:04 perreaultd

I am facing similar issue, the following command does not fetch "Sku" properties for a specific app service plan resource (while all other resources seem to get this info), have observed this behavior from last few months

Get-AzureRmResource -ResourceGroup $RGNAME -ResourceName $RESOURCENAME| Format-List -Property *

pvvdurgaprasad avatar Apr 08 '19 04:04 pvvdurgaprasad

  • AzureRm.Resources module is already available in 6.7.3

  • By looking at suggestion given in #6300 , have updated logic to use additional ResourceType input parameter to get Sku information and it worked!

pvvdurgaprasad avatar Apr 08 '19 05:04 pvvdurgaprasad