Skip to content

Get-AzureRmResource: Unable to cast object of type 'Newtonsoft.Json.Linq.JValue' to type 'Newtonsoft.Json.Linq.JObject' #5652

Open
@JaDevGuy

Description

@JaDevGuy

The Azure Resource Explorer shows this command should give me my admin token for my azure function

Get-AzureRmResource -ResourceGroupName contosoFunc -ResourceType "Microsoft.Web/sites/functions/token" -ResourceName "demofunct1/admin" -ApiVersion 2016-08-01

However running this cmdlet gives the error "Unable to cast object of type 'Newtonsoft.Json.Linq.JValue' to type 'Newtonsoft.Json.Linq.JObject'."

This is my current setup:

PS C:\WINDOWS\system32> get-module AzureRM -ListAvailable
    Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     5.4.1      AzureRM

PS C:\WINDOWS\system32> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.16299.248
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.16299.248
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1


Message        : Unable to cast object of type 'Newtonsoft.Json.Linq.JValue' to type 'Newtonsoft.Json.Linq.JObject'.
StackTrace     :    at Newtonsoft.Json.JsonSerializer.Deserialize[T](JsonReader reader)
                    at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Extensions.JsonExtensions.FromJson[T](Stream
                 stream)
                    at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Extensions.HttpMessageExtensions.<ReadContentAs
                 JsonAsync>d__0`1.MoveNext()
                 --- End of stack trace from previous location where exception was thrown ---
                    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                    at Microsoft.Azure.Commands.ResourceManager.Cmdlets.RestClients.ResourceManagerRestClientBase.<Send
                 RequestAsync>d__7`1.MoveNext()
                 --- End of stack trace from previous location where exception was thrown ---
                    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                    at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.GetAzureResourceCmdlet.<GetResou
                 rce>d__66.MoveNext()
                 --- End of stack trace from previous location where exception was thrown ---
                    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                    at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.GetAzureResourceCmdlet.<GetResou
                 rces>d__65.MoveNext()
Exception      : System.InvalidCastException
InvocationInfo : {Get-AzureRmResource}
Line           : Get-AzureRmResource -ResourceGroupName contosoFunc -ResourceType "Microsoft.Web/sites/functions/token" -ResourceName "demofunct1/admin" -ApiVersion 2016-08-01
Position       : At line:1 char:1
                 + Get-AzureRmResource -ResourceGroupName contosoFunc -ResourceType Micro ...
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 2

Metadata

Metadata

Assignees

Labels

ARMARM - CoreARM - Core TriagedService AttentionThis issue is responsible by Azure service team.bugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reported

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions