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

New-azdisk / new-azdiskconfig fails in powershell workflow

Open mialtamo opened this issue 2 years ago • 1 comments

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

$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

5.1

Module versions

Az.Compute Module 4.30.0 

Error output

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]

mialtamo avatar Sep 02 '22 18:09 mialtamo

Thank you for your feedback. This has been routed to the support team for assistance.

ghost avatar Sep 03 '22 01:09 ghost

@dingmeng-xue any status on this?

mialtamo avatar Oct 14 '22 21:10 mialtamo

@navba-MSFT , could you ask team to look into it? Or involve service team.

dingmeng-xue avatar Oct 15 '22 02:10 dingmeng-xue

@dingmeng-xue Thanks for letting me know.

@mialtamo Apologies for the late reply. Thanks for reaching out to us and reporting this issue. We are looking into this issue and we will provide an update.

navba-MSFT avatar Oct 17 '22 03:10 navba-MSFT

Awesome if you need any further details or help with the problem just let me know!

Get Outlook for iOShttps://aka.ms/o0ukef


From: navba-MSFT @.> Sent: Sunday, October 16, 2022 8:12:51 PM To: Azure/azure-powershell @.> Cc: Mike Altamore (AZURE,M365) @.>; Mention @.> Subject: Re: [Azure/azure-powershell] New-azdisk / new-azdiskconfig fails in powershell workflow (Issue #19386)

@dingmeng-xuehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdingmeng-xue&data=05%7C01%7CMichael.Altamore%40microsoft.com%7C8007fc594f5840fd2d7808daafed7a36%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638015731748855288%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=%2FLC6TQiankEaZM06CCB0n%2BzR0upAPuz2skweCijPPW8%3D&reserved=0 Thanks for letting me know.

@mialtamohttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmialtamo&data=05%7C01%7CMichael.Altamore%40microsoft.com%7C8007fc594f5840fd2d7808daafed7a36%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638015731748855288%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=E7VR0L7eEt%2BZrJhWyTTskLbpAItaPwqvD243FpZQPz0%3D&reserved=0 Apologies for the late reply. Thanks for reaching out to us and reporting this issue. We are looking into this issue and we will provide an update.

— Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAzure%2Fazure-powershell%2Fissues%2F19386%23issuecomment-1280218661&data=05%7C01%7CMichael.Altamore%40microsoft.com%7C8007fc594f5840fd2d7808daafed7a36%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638015731748855288%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=PoIaVND4lL1K0POvKUNYDub9hs%2BY9x26uqeS%2Fgx94Hk%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FANDTOM63HT7T244B2JCBK53WDS73HANCNFSM6AAAAAAQDPUIPM&data=05%7C01%7CMichael.Altamore%40microsoft.com%7C8007fc594f5840fd2d7808daafed7a36%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638015731748855288%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=eU0q5huhlq0BUgq8veHgzs9RpqrBshtZdvdhKVlKWTo%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.***>

mialtamo avatar Oct 17 '22 03:10 mialtamo

@mialtamo I am able to reproduce this issue at my end. I am working with the Product Owners further on this. I will keep you posted on this.

navba-MSFT avatar Oct 18 '22 09:10 navba-MSFT

Great news!

Get Outlook for iOShttps://aka.ms/o0ukef


From: navba-MSFT @.> Sent: Tuesday, October 18, 2022 2:22:25 AM To: Azure/azure-powershell @.> Cc: Mike Altamore (AZURE,M365) @.>; Mention @.> Subject: Re: [Azure/azure-powershell] New-azdisk / new-azdiskconfig fails in powershell workflow (Issue #19386)

@mialtamohttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmialtamo&data=05%7C01%7CMichael.Altamore%40microsoft.com%7C88a7b6c41641421fb16008dab0ea4537%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638016817489334497%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=BLixX6wcFar0edLaiBBzJRCWLVshPthmSh3RtXeNsRA%3D&reserved=0 I am able to reproduce this issue at my end. I am working with the Product Owners further on this. I will keep you posted on this.

— Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAzure%2Fazure-powershell%2Fissues%2F19386%23issuecomment-1282084920&data=05%7C01%7CMichael.Altamore%40microsoft.com%7C88a7b6c41641421fb16008dab0ea4537%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638016817489334497%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=B3TKD1wTuGaYQXXANP6iG5maZSQn2CI6MOFUXIwRfO0%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FANDTOMYTVVCSU6IJ4QWG3XDWDZT5DANCNFSM6AAAAAAQDPUIPM&data=05%7C01%7CMichael.Altamore%40microsoft.com%7C88a7b6c41641421fb16008dab0ea4537%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638016817489334497%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=N6o6kAwHqT4C5Lt7AUNjMaZzwv24RagZphZ0%2FMH1fu8%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.***>

mialtamo avatar Oct 18 '22 16:10 mialtamo

@mialtamo I am following up with the Product Owners and yet to hear from them. I will keep you posted. We appreciate your patience on this.

navba-MSFT avatar Oct 25 '22 03:10 navba-MSFT

Sounds good thanks for the update!

Michael R Altamore Senior Cloud Solution Architect -Engineering - Azure & SharePoint & Project Server | Microsoft Federal Office/Cell: (305) 219-5245 Corporate E-Mail: @.@.> | Federal Email: @.@.>

US Time Zone: PST

[Microsoft logo, gray text version]

From: navba-MSFT @.> Sent: Monday, October 24, 2022 8:57 PM To: Azure/azure-powershell @.> Cc: Mike Altamore (AZURE,M365) @.>; Mention @.> Subject: Re: [Azure/azure-powershell] New-azdisk / new-azdiskconfig fails in powershell workflow (Issue #19386)

@mialtamohttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmialtamo&data=05%7C01%7CMichael.Altamore%40microsoft.com%7C3ef0d10ff7c945652a8e08dab63cfe21%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638022670335675454%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=w08k%2BBXBwlOzDMSKdfgk%2F3jLqM%2BupGKkGh0N%2FBlTdiM%3D&reserved=0 I am following up with the Product Owners and yet to hear from them. I will keep you posted. We appreciate your patience on this.

Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAzure%2Fazure-powershell%2Fissues%2F19386%23issuecomment-1289943211&data=05%7C01%7CMichael.Altamore%40microsoft.com%7C3ef0d10ff7c945652a8e08dab63cfe21%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638022670335675454%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Vc7KquCGlNkwZX3zHXeK9TJWuxlierO1y1%2B%2F80uqqsE%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FANDTOM7E6HUVTMTDFBHVKRDWE5LBNANCNFSM6AAAAAAQDPUIPM&data=05%7C01%7CMichael.Altamore%40microsoft.com%7C3ef0d10ff7c945652a8e08dab63cfe21%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638022670335675454%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=pjeTAd3wV2rWmt2xJs5myK05UPdxVVdoZzX7jzPA7FQ%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.@.>>

mialtamo avatar Oct 25 '22 03:10 mialtamo

@mialtamo Apologies for the late reply. Workflow commonly deserializes objects, which then makes the method unavailable. Do should put the two lines in an InlineScript like below :

$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

InlineScript{
$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 `

More Info here. Please test this and let us know the update.

navba-MSFT avatar Nov 04 '22 04:11 navba-MSFT

Hi @mialtamo. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.

ghost avatar Nov 04 '22 04:11 ghost

Hi @mialtamo, since you haven’t asked that we “/unresolve” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “/unresolve” to reopen the issue.

ghost avatar Nov 11 '22 06:11 ghost

Apologies for late reply so yea in line scripting will work however in line doesn't woke in azure powershell runbook unless it's a workflow run book which i suppose is doable but a lot of things then don't work comparative in wf runbooks to graphical runbooks.

So, it would be nice for a more complete solution to the problem but understand if this isn't possible.

Get Outlook for iOShttps://aka.ms/o0ukef


From: msftbot[bot] @.> Sent: Thursday, November 10, 2022 10:03:47 PM To: Azure/azure-powershell @.> Cc: Mike Altamore (AZURE,M365) @.>; Mention @.> Subject: Re: [Azure/azure-powershell] New-azdisk / new-azdiskconfig fails in powershell workflow (Issue #19386)

Hi @mialtamohttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmialtamo&data=05%7C01%7CMichael.Altamore%40microsoft.com%7C48fdf13cc19f45b5b64e08dac3aa7f65%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638037434294718216%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=5qg6rJKGzjESBajfdoGozxgOu%2BR9IXxGltB5sLDg6d0%3D&reserved=0, since you haven’t asked that we “/unresolve” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “/unresolve” to reopen the issue.

— Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAzure%2Fazure-powershell%2Fissues%2F19386%23issuecomment-1311266248&data=05%7C01%7CMichael.Altamore%40microsoft.com%7C48fdf13cc19f45b5b64e08dac3aa7f65%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638037434294718216%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=zf%2BQZwEnPVWYX8uL71FMTh0HBWU1RNJDL6BLae%2FDpKc%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FANDTOM65WYN346PZ6MBAVWDWHXOUHANCNFSM6AAAAAAQDPUIPM&data=05%7C01%7CMichael.Altamore%40microsoft.com%7C48fdf13cc19f45b5b64e08dac3aa7f65%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638037434294718216%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=KP8hQaj0yAUKORF%2Brvs6eSccUk9vhD4B4seLqprTw%2FA%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.***>

mialtamo avatar Nov 18 '22 17:11 mialtamo

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Drewm3, @avirishuv, @vaibhav-agar, @amjads1.

Issue Details

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

$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

5.1

Module versions

Az.Compute Module 4.30.0 

Error output

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]
Author: mialtamo
Assignees: -
Labels:

Compute, Service Attention, bug, customer-reported, needs-team-attention

Milestone: -

ghost avatar Nov 28 '22 04:11 ghost

@mialtamo Thanks for getting back. I am adding Service team to look into this further.

@Drewm3, @avirishuv, @Vaibhav-Agar, @amjads1. Could you please look into this once you get a chance ? Thanks in advance.

navba-MSFT avatar Nov 28 '22 04:11 navba-MSFT

@navba-MSFT, could you outline why you feel this is an issue with the service? This seems to be an issue specific to PowerShell workflows.

Drewm3 avatar Nov 28 '22 07:11 Drewm3

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @jaspkaur28.

Issue Details

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

$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

5.1

Module versions

Az.Compute Module 4.30.0 

Error output

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]
Author: mialtamo
Assignees: -
Labels:

Automation, Compute, Service Attention, bug, customer-reported, needs-team-attention

Milestone: -

ghost avatar Nov 28 '22 07:11 ghost

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @jaspkaur28.

Issue Details

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

$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

5.1

Module versions

Az.Compute Module 4.30.0 

Error output

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]
Author: mialtamo
Assignees: -
Labels:

Automation, Service Attention, bug, customer-reported, needs-team-attention

Milestone: -

ghost avatar Nov 28 '22 07:11 ghost

@navba-MSFT This does not seem to be an Azure Automation issue. Is the script not working as a runbook ?

jaspkaur28 avatar Jan 28 '23 14:01 jaspkaur28

This may be by design from Microsoft but it will only work in a workflow run book and not a non workflow run book. Which i suppose is fine but it's weird that the nonwork flow run books support some "workflow" commandlets but not that one in particular. But at the end of the day it will work in a workflow run book successfully!

Get Outlook for iOShttps://aka.ms/o0ukef


From: Jaspreet Kaur @.> Sent: Saturday, January 28, 2023 6:32:59 AM To: Azure/azure-powershell @.> Cc: Mike Altamore (AZURE,M365) @.>; Mention @.> Subject: Re: [Azure/azure-powershell] New-azdisk / new-azdiskconfig fails in powershell workflow (Issue #19386)

@navba-MSFThttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnavba-MSFT&data=05%7C01%7CMichael.Altamore%40microsoft.com%7C28a4e3407182455c203308db013c8e4b%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638105131825665326%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=j9UGK7OYAATWZtvrNgGotZm%2FoMNcJtUNLjJeihg9f1k%3D&reserved=0 This does not seem to be an Azure Automation issue. Is the script not working as a runbook ?

— Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAzure%2Fazure-powershell%2Fissues%2F19386%23issuecomment-1407411210&data=05%7C01%7CMichael.Altamore%40microsoft.com%7C28a4e3407182455c203308db013c8e4b%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638105131825665326%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=ISagMxyUYhWiJJKwlfob%2Fb%2FRnI2%2BMubgBNT9xZQnV2Q%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FANDTOM3VE4F37TKEXZJET5DWUUUZXANCNFSM6AAAAAAQDPUIPM&data=05%7C01%7CMichael.Altamore%40microsoft.com%7C28a4e3407182455c203308db013c8e4b%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638105131825821622%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=7V3Q1qSWADBL7gC1ciA3aPHxqX%2FG%2B54OAIdB3FWf34I%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.***>

mialtamo avatar Jan 28 '23 17:01 mialtamo