Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.21k stars 3.82k forks source link

Set-AzStorageBlobContent not terminate and seems blocked by New-Object System.Windows.Forms.Form #15556

Closed jeromezliu closed 3 years ago

jeromezliu commented 3 years ago

Description

When use Set-AzStorageBlobContent after New-Object System.Windows.Forms.Form, the upload command will never stop as the screenshot below.

image

The upload operation is successful actually. image

Please find the sample code below.

Steps to reproduce

sample code


$ctx = New-AzStorageContext -StorageAccountName $storage_account_name -StorageAccountKey $storage_account_key
# bug
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$UserAdminForm = New-Object System.Windows.Forms.Form
# upload
Set-AzStorageBlobContent -Context $ctx -Container "fileupload" -File ".\file.png" -Debug

Environment data

PowerShell Version

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

Module versions

Az.Storage Version

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     3.9.0      Az.Storage                          {Get-AzStorageAccount, Get-AzStorageAccountKey, New-AzStorageAccount, New-AzStorageAccountKey...}

Debug output

Please find in the screenshot below.

Other

Please let me know if you need any other information. jerome.liu@microsoft.com

jeromezliu commented 3 years ago

Additionally, if Set-AzStorageBlobContent executed before New-Object System.Windows.Forms.Form, everything is good.

blueww commented 3 years ago

@lzy8513 Thanks for reporting this issue! I can repro this issue locally. It looks the hang happens on a depends library of Azure Powershell. I will need more time to look deeper into it.

There's a workaround, in my test if you run the cmdlet async with -Asjob, then wait for upload complete, the job won't hang:

$task = Set-AzStorageBlobContent -Container $containerName -Blob $blobName -File $localSrcFile -Context $ctx -Force -asjob 
$task  | Wait-Job
jeromezliu commented 3 years ago

@blueww Thanks for the help. It works in my end.

ghost commented 3 years ago

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

Issue Details
## Description When use **Set-AzStorageBlobContent** after **New-Object System.Windows.Forms.Form**, the upload command will never stop as the screenshot below. ![image](https://user-images.githubusercontent.com/10989739/127089925-3e4a769f-7c02-466f-8f6b-e83ee42ae368.png) The upload operation is successful actually. ![image](https://user-images.githubusercontent.com/10989739/127090411-6ce324a4-2499-4fe8-9c6e-8481c8489537.png) Please find the sample code below. ## Steps to reproduce sample code ```powershell $ctx = New-AzStorageContext -StorageAccountName $storage_account_name -StorageAccountKey $storage_account_key # bug [void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") $UserAdminForm = New-Object System.Windows.Forms.Form # upload Set-AzStorageBlobContent -Context $ctx -Container "fileupload" -File ".\file.png" -Debug ``` ## Environment data PowerShell Version ``` Name Value ---- ----- PSVersion 5.1.19041.1023 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.19041.1023 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 ``` ## Module versions Az.Storage Version ```powershell ModuleType Version Name ExportedCommands ---------- ------- ---- ---------------- Script 3.9.0 Az.Storage {Get-AzStorageAccount, Get-AzStorageAccountKey, New-AzStorageAccount, New-AzStorageAccountKey...} ``` ## Debug output Please find in the screenshot below. ## Other Please let me know if you need any other information. jerome.liu@microsoft.com
Author: lzy8513
Assignees: blueww
Labels: `Service Attention`, `Storage`, `customer-reported`, `question`
Milestone: -
blueww commented 3 years ago

@EmmaZhu

Would you please help to follow up the hang issue?

EmmaZhu commented 3 years ago

We suspect this is an issue in .Net framework, and we made a simple repro and opened an issue in .Net repository: https://github.com/dotnet/sdk/issues/19494