Azure / Azure/azure-powershell

New-azdisk / new-azdiskconfig fails in powershell workflow

Open
#19,386 21 comments 0 reactions 0 assignees View on GitHub
act-codegen-extensibility-squad Automation bug customer-reported needs-team-attention Service Attention
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
3d 14h
Merged PRs (30d)
54

Description

### Description

weird problem im getting in a powershell workflwo call trying to create an azure disk using New-AZDisk the command will absolutely not run in a powershell workflow works fine NOT in a powershell workflow.
```
$vmRSG = Get-AZResourceGroup -name Test
$labName = "dhcp"
$location = "westus3"
$labServers = @("DC1","DC2","DHCP1")
$snapshotRSG = "DOD-LabVMSnapShots"
Workflow t {
param ($snapshotRSG, $labServers, $labName, $location, $vmRSG)
foreach -parallel ($d in $labServers){
$d
$snapshotRSG
$s = Get-AzSnapshot -ResourceGroupName "$snapshotRSG" -SnapshotName "$($d)-$($labName)-Snapshot" | ? {$_.Tags['Active'] -eq "Yes" -and $_.Tags['Lab'] -eq $labName}
$s.Name
$dConfig = New-AzDiskConfig -Location "$location" -SourceResourceId $s.Id -CreateOption Copy
$dconfig
$disk1 = New-AzDisk -ResourceGroupName $vmRSG.ResourceGroupName -DiskName "Hello" -Disk $dconfig
}
}
t $snapshotRSG $labServers $labName $location $vmRSG `
```

The errors that get thrown are:
```
Microsoft.PowerShell.Utility\Write-Error : Cannot bind parameter 'Disk'. Cannot convert value "Microsoft.Azure.Commands.Compute.Automation.Models.PSDisk" to type "Microsoft.Azure.Commands.Compute.Automation.Models.PSDisk".
Error: "Cannot convert the "Microsoft.Azure.Commands.Compute.Automation.Models.PSDisk" value of type "Deserialized.Microsoft.Azure.Commands.Compute.Automation.Models.PSDisk" to type
"Microsoft.Azure.Commands.Compute.Automation.Models.PSDisk"."
At t:10 char:10
+
    + CategoryInfo          : NotSpecified: (:) [Write-Error], RemoteException
    + FullyQualifiedErrorId : System.Management.Automation.RemoteException,Microsoft.PowerShell.Commands.WriteErrorCommand
    + PSComputerName        : [localhost]
```
### Issue script & Debug output

```PowerShell
$vmRSG = Get-AZResourceGroup -name Test
$labName = "dhcp"
$location = "westus3"
$labServers = @("DC1","DC2","DHCP1")
$snapshotRSG = "DOD-LabVMSnapShots"
Workflow t {
param ($snapshotRSG, $labServers, $labName, $location, $vmRSG)
foreach -parallel ($d in $labServers){
$d
$snapshotRSG
$s = Get-AzSnapshot -ResourceGroupName "$snapshotRSG" -SnapshotName "$($d)-$($labName)-Snapshot" | ? {$_.Tags['Active'] -eq "Yes" -and $_.Tags['Lab'] -eq $labName}
$s.Name
$dConfig = New-AzDiskConfig -Location "$location" -SourceResourceId $s.Id -CreateOption Copy
$dconfig
$disk1 = New-AzDisk -ResourceGroupName $vmRSG.ResourceGroupName -DiskName "Hello" -Disk $dconfig
}
}
t $snapshotRSG $labServers $labName $location $vmRSG
```

### Environment data

```PowerShell
5.1
```

### Module versions

```PowerShell
Az.Compute Module 4.30.0
```

### Error output

```PowerShell
Microsoft.PowerShell.Utility\Write-Error : Cannot bind parameter 'Disk'. Cannot convert value "Microsoft.Azure.Commands.Compute.Automation.Models.PSDisk" to type "Microsoft.Azure.Commands.Compute.Automation.Models.PSDisk".
Error: "Cannot convert the "Microsoft.Azure.Commands.Compute.Automation.Models.PSDisk" value of type "Deserialized.Microsoft.Azure.Commands.Compute.Automation.Models.PSDisk" to type
"Microsoft.Azure.Commands.Compute.Automation.Models.PSDisk"."
At t:10 char:10
+
    + CategoryInfo          : NotSpecified: (:) [Write-Error], RemoteException
    + FullyQualifiedErrorId : System.Management.Automation.RemoteException,Microsoft.PowerShell.Commands.WriteErrorCommand
    + PSComputerName        : [localhost]
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the supplied PowerShell 5.1 workflow with Az.Compute 4.30.0, then inspect New-AzDiskConfig and New-AzDisk around the workflow's serialization boundary. Done means the workflow can pass the disk configuration to New-AzDisk without the Deserialized.PSDisk conversion error, with coverage for this workflow scenario.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, powershell
Domain
cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.