Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run get-azstorageblob cmdlet in vscode pwsh 7 or ISE terminals #26839

Open
sethmgray opened this issue Dec 5, 2024 · 3 comments
Open
Assignees
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. customer-reported needs-author-feedback More information is needed from author to address the issue. no-recent-activity There has been no recent activity on this issue. Storage

Comments

@sethmgray
Copy link

Description

Developing simple download tool and getting held up by get-azstorageblob not working in any VSCode nor ISE.
I was able to fix all issues old fashioned like and run script in both powershell.exe and pwsh.exe , but not being able to run attached debugger is pretty terrible.

Simply running this in powershell ISE will error, vscode will error as well when running in pwsh terminals.

$storagecontainer='maintenance'
$azureprodsqlmaintenancesas='...'
$blob='###*'
$azcontext=New-AzStorageContext -StorageAccountName #### -SasToken $azureprodsqlmaintenancesas
$debugpreference="silentlycontinue"
get-azstorageblob -Container $storagecontainer -Context $azcontext -blob $blob -Debug

Save that to a script and run it in powershell and pwsh7 and it works.

Issue script & Debug output

$storagecontainer='maintenance' 
$azureprodsqlmaintenancesas='...'
$blob='###*'
$azcontext=New-AzStorageContext -StorageAccountName #### -SasToken $azureprodsqlmaintenancesas
$debugpreference="silentlycontinue"
get-azstorageblob -Container $storagecontainer -Context $azcontext -blob $blob -Debug

DEBUG: 5:12:26 PM - NewAzureStorageContext begin processing with ParameterSet 'SasToken'.
DEBUG: AzureQoSEvent:  Module: Az.Storage:8.0.0; CommandName: New-AzStorageContext; PSVersion: 5.1.17763.6530; IsSuccess: True; Duration: 00:00:00.0124458; SanitizeDuration: 00:00:00.0000653
DEBUG: 5:12:26 PM - NewAzureStorageContext end processing.
DEBUG: 5:12:26 PM - Init Operation Context for 'GetAzureStorageBlobCommand' with client request id  Azure-Storage-PowerShell-28b112f9-f014-487f-9b20-395a58f69f2d. If you want to get more details, please add "-Debug" to your command.
DEBUG: 5:12:29 PM - GetAzureStorageBlobCommand begin processing with ParameterSet 'BlobName'.
DEBUG: 5:12:29 PM - Use storage account '#####' from storage context.
get-azstorageblob : Method not found: 'Azure.Response`1<Azure.Storage.Blobs.Models.BlobProperties> Azure.Storage.Blobs.Specialized.BlobBaseClient.GetProperties(Azure.Storage.Blobs.Models.BlobRequestConditions, System.Threading.CancellationToken)'.
At line:7 char:1
+ get-azstorageblob -Container $storagecontainer -Context $azcontext -b ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Get-AzStorageBlob], MissingMethodException
    + FullyQualifiedErrorId : MissingMethodException,Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet.GetAzureStorageBlobCommand

Environment data

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

also

Module versions

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     4.0.0                 Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzConte…
Script     8.0.0                 Az.Storage                          {Add-AzRmStorageContainerLegalHold, Add-AzStorage

Error output

HistoryId: 1


Message        : Method not found: 'Azure.Response`1<Azure.Storage.Blobs.Models.BlobProperties> Azure.Storage.Blobs.Specialized.BlobBaseClient.GetProperties(Azure.Storage.Blobs.Models.BlobRequestConditions, System.Threading.CancellationToken)'.
StackTrace     :    at Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet.GetAzureStorageBlobCommand.<ListBlobsByName>d__51.MoveNext()
                    at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
                    at Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet.GetAzureStorageBlobCommand.ListBlobsByName(Int64 taskId, IStorageBlobManagement localChannel, String containerName, String blobName, Boolean includeDeleted, Boolean includeVersion)
                    at Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet.GetAzureStorageBlobCommand.<>c__DisplayClass55_2.<ExecuteCmdlet>b__1(Int64 taskId)
                    at Microsoft.WindowsAzure.Commands.Storage.Common.LimitedConcurrencyTaskScheduler.RunTask(Func`2 taskGenerator)
                    at Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet.GetAzureStorageBlobCommand.ExecuteCmdlet()
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception      : System.MissingMethodException
InvocationInfo : {Get-AzStorageBlob}
Line           :     $azblobs=get-azstorageblob -Container $storagecontainer -Context $azcontext -blob $blob | %{[PSCustomObject] @{name=$_.name; context=$azcontext; container=$storagecontainer; filecreate=$($_.name -match "2[0-9]{7}_[0-9]{6}" | out-null; $datestr=$matches[0];$template = 'yyyyMMdd_HHmmss';[datetime]::ParseExact($datestr,$template,$null))}}
                 
Position       : At D:\Utilities\cority.ems.senddb\senddb.ps1:570 char:14
                 + ...    $azblobs=get-azstorageblob -Container $storagecontainer -Context $ ...
                 +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 1
@sethmgray sethmgray added bug This issue requires a change to an existing behavior in the product in order to be resolved. needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Dec 5, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added customer-reported needs-triage This is a new issue that needs to be triaged to the appropriate team. and removed needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Dec 5, 2024
@blueww blueww self-assigned this Dec 5, 2024
@blueww
Copy link
Member

blueww commented Dec 5, 2024

@sethmgray

I really can't repro this issue in both PowerShell ISE and VSC, with very similar script as yours, with same Az.Accounts and Az.Storage module version. (See attached picture)
Although the PSH version is a little different, but this might not be matter, since the error is .net SDK method not found (PSH based on .net SDK).

Would you like to check if any other module/SDK is already loaded? (Is there any other module show in Get-Module?)
Would you like open a new Powershell console, and run your repro script at first (without run any other command run before it). And see if this issue still repro? If still not work, try to remove and reinstall Az.Accounts and Az.Storage module, then open a new PSH console and run it again.

Besides that, does this repro on any other machine on your side?
Can you run any other Storage cmdlet like Get-AzStorageContainer, Get-AzStorageBlobTag?
How do you build the SAS token used in the script?

BTW, We have test set to cover this scenario, and as I know this cmdlet is widely used by many customers, so if there's any blocking issue, normally we should get more customer reported issues than only this one. So this issue is very possible be your environment issue.

Powershell ISE:

Image

VSC:
Image

@VeryEarly VeryEarly added Storage needs-author-feedback More information is needed from author to address the issue. and removed needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Dec 5, 2024
@VeryEarly
Copy link
Contributor

are there other modules were imported beside Az.Accounts and Az.Storage?

@microsoft-github-policy-service microsoft-github-policy-service bot added the no-recent-activity There has been no recent activity on this issue. label Dec 12, 2024
Copy link
Contributor

Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. customer-reported needs-author-feedback More information is needed from author to address the issue. no-recent-activity There has been no recent activity on this issue. Storage
Projects
None yet
Development

No branches or pull requests

3 participants