Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.27k stars 3.89k forks source link

Get-AzureRmVM -Status does not work within workflow #5578

Open gzaika opened 6 years ago

gzaika commented 6 years ago

Description

Script/Steps for Reproduction

1) created Runbook of type workflow in Azure Automation 2) added command

Select-AzureRMSubscription -SubscriptionName $SubscriptionName  # put your name
$ResourceGroups = @()
$ResourceGroups += "YourResourceGroupName"
ForEach -parallel  ($RGName in $ResourceGroups) {
$VMs = Get-AzureRmVM -ResourceGroupName $RGName -Status
}

It returns error

Module Version

Version - 5.2.0

Environment Data

$PSVersionTable

Name                           Value                                                                                                  
----                           -----                                                                                                  
PSVersion                      5.1.16299.98                                                                                           
PSEdition                      Desktop                                                                                                
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                
BuildVersion                   10.0.16299.98                                                                                          
CLRVersion                     4.0.30319.42000                                                                                        
WSManStackVersion              3.0                                                                                                    
PSRemotingProtocolVersion      2.3                                                                                                    
SerializationVersion           1.1.0.1                                                                                                

Debug Output

Here is the error output

Get-AzureRmVM : Missing type map configuration or unsupported mapping.

Mapping types:
AzureOperationResponse`1 -> PSVirtualMachineListStatus
Microsoft.Rest.Azure.AzureOperationResponse`1[[Microsoft.Rest.Azure.IPage`1[[Microsoft.Azure.Management.Compute.Models.V
irtualMachine, Microsoft.Azure.Management.Compute, Version=15.0.0.0, Culture=neutral, 
PublicKeyToken=31bf3856ad364e35]], Microsoft.Rest.ClientRuntime.Azure, Version=3.0.0.0, Culture=neutral, 
PublicKeyToken=31bf3856ad364e35]] -> Microsoft.Azure.Commands.Compute.Models.PSVirtualMachineListStatus

Destination path:
PSVirtualMachineListStatus

Source value:
Microsoft.Rest.Azure.AzureOperationResponse`1[Microsoft.Rest.Azure.IPage`1[Microsoft.Azure.Management.Compute.Models.Vir
tualMachine]]
At GaryTest:78 char:78
+ 
    + CategoryInfo          : CloseError: (:) [Get-AzureRmVM], AutoMapperMappingException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.GetAzureVMCommand

Get-AzureRmVM : Missing type map configuration or unsupported mapping.

Mapping types:
AzureOperationResponse`1 -> PSVirtualMachineListStatus
Microsoft.Rest.Azure.AzureOperationResponse`1[[Microsoft.Rest.Azure.IPage`1[[Microsoft.Azure.Management.Compute.Models.V
irtualMachine, Microsoft.Azure.Management.Compute, Version=15.0.0.0, Culture=neutral, 
PublicKeyToken=31bf3856ad364e35]], Microsoft.Rest.ClientRuntime.Azure, Version=3.0.0.0, Culture=neutral, 
PublicKeyToken=31bf3856ad364e35]] -> Microsoft.Azure.Commands.Compute.Models.PSVirtualMachineListStatus

Destination path:
PSVirtualMachineListStatus

Source value:
Microsoft.Rest.Azure.AzureOperationResponse`1[Microsoft.Rest.Azure.IPage`1[Microsoft.Azure.Management.Compute.Models.Vir
tualMachine]]
At GaryTest:78 char:78
+ 
    + CategoryInfo          : CloseError: (:) [Get-AzureRmVM], AutoMapperMappingException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.GetAzureVMCommand

Get-AzureRmVM : Missing type map configuration or unsupported mapping.

Mapping types:
AzureOperationResponse`1 -> PSVirtualMachineListStatus
Microsoft.Rest.Azure.AzureOperationResponse`1[[Microsoft.Rest.Azure.IPage`1[[Microsoft.Azure.Management.Compute.Models.V
irtualMachine, Microsoft.Azure.Management.Compute, Version=15.0.0.0, Culture=neutral, 
PublicKeyToken=31bf3856ad364e35]], Microsoft.Rest.ClientRuntime.Azure, Version=3.0.0.0, Culture=neutral, 
PublicKeyToken=31bf3856ad364e35]] -> Microsoft.Azure.Commands.Compute.Models.PSVirtualMachineListStatus

Destination path:
PSVirtualMachineListStatus

Source value:
Microsoft.Rest.Azure.AzureOperationResponse`1[Microsoft.Rest.Azure.IPage`1[Microsoft.Azure.Management.Compute.Models.Vir
tualMachine]]
At GaryTest:78 char:78
+ 
    + CategoryInfo          : CloseError: (:) [Get-AzureRmVM], AutoMapperMappingException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.GetAzureVMCommand

Runbooks-Info-Creating new runbook

Edit PowerShell Workflow Runbook*-Info-Saving the runbook

Test-Info-Submitting request to test the runbook.
cormacpayne commented 6 years ago

@gzaika a few additional questions:

(1) Are you seeing this issue outside of automation? I am unable to reproduce the above error in a normal PowerShell session

(2) Does it fail with the same error if you don't provide the -Status parameter?

(3) Would you mind turning on the debug stream by setting $DebugPreference="Continue" and returning the corresponding output?

gzaika commented 6 years ago

No, I can reproduce it only in Automation within Powershell workflow

gzaika commented 6 years ago

Without -Status it works fine

maddieclayton commented 6 years ago

@vrdmr Can you take a look at this issue?

andyw248 commented 5 years ago

Triaged: Needs more investigation, potentially in issue at the sandbox layer.