Azure / azure-powershell

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

Get-AzStorageBlobByTag - Method not found: 'System.Collections.Generic.IAsyncEnumerable' #17713

Open rybal06 opened 2 years ago

rybal06 commented 2 years ago

Description

While executing this cmdlet:

Get-AzStorageBlobByTag -Context $storageCTX -TagFilterSqlExpression """IsLatest""='true'" 

The following is returned:

Get-AzStorageBlobByTag: Method not found: 'System.Collections.Generic.IAsyncEnumerable`1<Azure.Page`1<!0>> Azure.AsyncPageable`1.AsPages(System.String, System.Nullable`1<Int32>)'

In reading the docs, it seems like the TagFilterExpression synax being used is correct:

get-help Get-AzStorageBlobByTag -Examples

    Example 3: List all blobs match a specific blob tag, across containers, and get the blob properties.

    PS C:\> Get-AzStorageBlobByTag -TagFilterSqlExpression """tag1""='value1'" -GetBlobProperty

Issue script & Debug output

Get-AzStorageBlobByTag -Context $storageCTX -TagFilterSqlExpression """IsLatest""='true'" -Debug
DEBUG: 5:27:48 PM - Init Operation Context for 'GetAzureStorageBlobByTagCommand' with client request id  Azure-Storage-PowerShell-9b05ab1e-b1d0-4878-8e64-ecf41814f1da. If you want to get more details, please add "-Debug" to your command.
DEBUG: 5:27:48 PM - GetAzureStorageBlobByTagCommand begin processing with ParameterSet '__AllParameterSets'.
DEBUG: 5:27:48 PM - Use storage account 'devopsagenthubsa' from storage context.
Get-AzStorageBlobByTag: Method not found: 'System.Collections.Generic.IAsyncEnumerable`1<Azure.Page`1<!0>> Azure.AsyncPageable`1.AsPages(System.String, System.Nullable`1<Int32>)'.
Get-AzStorageBlobByTag task status : [Total: 1. Successful: 0. Failed: 0. Active: 0.                                 ]

Environment data

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.2.2
PSEdition                      Core
GitCommitId                    7.2.2
OS                             Darwin 21.4.0 Darwin Kernel Version 21.4.0: Mon Feb 21 20:34:37 PST 2022; root:xnu-8020.101.4~2/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

Get-Module -ListAvailable | where name -like 'Az*' | select version, name

Version   Name
-------   ----
7.3.2     Az
2.7.4     Az.Accounts
1.1.2     Az.Advisor
3.1.2     Az.Aks
1.1.4     Az.AnalysisServices
2.3.1     Az.ApiManagement
1.0.0     Az.AppConfiguration
1.3.0     Az.ApplicationInsights
1.0.0     Az.Attestation
1.7.3     Az.Automation
3.1.1     Az.Batch
2.0.0     Az.Billing
1.8.1     Az.Cdn
1.1.0     Az.CloudService
1.10.0    Az.CognitiveServices
4.24.1    Az.Compute
3.0.1     Az.ContainerInstance
2.2.3     Az.ContainerRegistry
1.5.1     Az.CosmosDB
1.1.0     Az.DataBoxEdge
1.2.0     Az.Databricks
1.16.4    Az.DataFactory
1.0.2     Az.DataLakeAnalytics
1.3.0     Az.DataLakeStore
1.0.1     Az.DataShare
1.1.0     Az.DeploymentManager
3.1.0     Az.DesktopVirtualization
1.0.2     Az.DevTestLabs
1.1.2     Az.Dns
1.3.0     Az.EventGrid
1.11.0    Az.EventHub
1.9.0     Az.FrontDoor
4.0.1     Az.Functions
5.0.0     Az.HDInsight
1.3.2     Az.HealthcareApis
2.7.4     Az.IotHub
4.3.0     Az.KeyVault
2.0.0     Az.Kusto
1.5.0     Az.LogicApp
1.1.3     Az.MachineLearning
1.2.0     Az.Maintenance
3.0.0     Az.ManagedServices
1.0.2     Az.MarketplaceOrdering
1.1.1     Az.Media
1.1.2     Az.Migrate
3.0.1     Az.Monitor
1.0.0     Az.MySql
4.15.0    Az.Network
1.1.1     Az.NotificationHubs
3.0.1     Az.OperationalInsights
1.5.0     Az.PolicyInsights
1.0.0     Az.PostgreSql
1.1.2     Az.PowerBIEmbedded
1.0.3     Az.PrivateDns
5.2.0     Az.RecoveryServices
1.6.0     Az.RedisCache
1.0.0     Az.RedisEnterpriseCache
1.0.3     Az.Relay
1.1.0     Az.ResourceMover
5.4.0     Az.Resources
1.1.1     Az.Security
1.1.0     Az.SecurityInsights
1.8.0     Az.ServiceBus
3.0.1     Az.ServiceFabric
1.4.1     Az.SignalR
3.7.1     Az.Sql
1.1.0     Az.SqlVirtualMachine
1.1.0     Az.StackHCI
4.3.0     Az.Storage
1.7.0     Az.StorageSync
2.0.0     Az.StreamAnalytics
1.0.0     Az.Support
1.1.0     Az.Synapse
1.1.0     Az.TrafficManager
2.10.0    Az.Websites

Error output

Resolve-AzError                                                              
DEBUG: 5:29:19 PM - ResolveError begin processing with ParameterSet 'AnyErrorParameterSet'.
DEBUG: 5:29:19 PM - using account id '<removed>'...
WARNING: Upcoming breaking changes in the cmdlet 'Resolve-AzError' :
The `Resolve-Error` alias will be removed in a future release.  Please change any scripts that use this alias to use `Resolve-AzError` instead.
Note : Go to https://aka.ms/azps-changewarnings for steps to suppress this breaking change warning, and other information on breaking changes in Azure PowerShell.

   HistoryId: 145

Message        : Method not found: 'System.Collections.Generic.IAsyncEnumerable`1<Azure.Page`1<!0>> Azure.AsyncPageable`1.AsPages(System.String, System.Nullable`1<Int32>)'.
StackTrace     :    at Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet.GetAzureStorageBlobByTagCommand.ListBlobsByTag(Int64 taskId, IStorageBlobManagement localChannel, 
                 String tagFilterSqlExpression)
                    at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
                    at Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet.GetAzureStorageBlobByTagCommand.ListBlobsByTag(Int64 taskId, IStorageBlobManagement localChannel, 
                 String tagFilterSqlExpression)
                    at Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet.GetAzureStorageBlobByTagCommand.<>c__DisplayClass24_0.<ExecuteCmdlet>b__0(Int64 taskId)
                    at Microsoft.WindowsAzure.Commands.Storage.Common.LimitedConcurrencyTaskScheduler.RunTask(Func`2 taskGenerator)
                    at Microsoft.WindowsAzure.Commands.Storage.Common.StorageCloudCmdletBase`1.RunTask(Func`2 taskGenerator)
                    at Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet.GetAzureStorageBlobByTagCommand.ExecuteCmdlet()
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.<>c__3`1.<ExecuteSynchronouslyOrAsJob>b__3_0(T c)
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet, Action`1 executor)
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet)
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception      : System.MissingMethodException
InvocationInfo : {Get-AzStorageBlobByTag}
Line           : Get-AzStorageBlobByTag -Context $storageCTX -TagFilterSqlExpression """IsLatest""='true'" -Debug
Position       : At line:1 char:1
                 + Get-AzStorageBlobByTag -Context $storageCTX -TagFilterSqlExpression " …
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 145
ghost commented 2 years ago

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

SaurabhSharma-MSFT commented 2 years ago

@rybal06 We are looking into it and get back to you for any additional information.

robbinscp commented 2 years ago

Seeing the same thing here, using Az.Storage version 4.4.0 and Azure Cloud Shell.

PS /home/christopher> Get-Module -ListAvailable | where name -like 'Az*' | select version, name                         

Version   Name
-------   ----
7.4.0     Az
2.7.5     Az.Accounts
1.1.2     Az.Advisor
3.1.2     Az.Aks
1.1.4     Az.AnalysisServices
2.3.1     Az.ApiManagement
1.1.0     Az.AppConfiguration
1.3.1     Az.ApplicationInsights
1.0.0     Az.Attestation
1.7.3     Az.Automation
3.1.1     Az.Batch
2.0.0     Az.Billing
1.8.2     Az.Cdn
1.1.0     Az.CloudService
1.10.0    Az.CognitiveServices
4.25.0    Az.Compute
3.0.1     Az.ContainerInstance
2.2.3     Az.ContainerRegistry
1.7.0     Az.CosmosDB
1.1.0     Az.DataBoxEdge
1.2.0     Az.Databricks
1.16.5    Az.DataFactory
1.0.2     Az.DataLakeAnalytics
1.3.0     Az.DataLakeStore
1.0.1     Az.DataShare
1.1.0     Az.DeploymentManager
3.1.0     Az.DesktopVirtualization
1.0.2     Az.DevTestLabs
1.1.2     Az.Dns
1.3.0     Az.EventGrid
1.11.0    Az.EventHub
1.9.0     Az.FrontDoor
4.0.2     Az.Functions
0.10.8    Az.GuestConfiguration
5.0.1     Az.HDInsight
1.3.2     Az.HealthcareApis
2.7.4     Az.IotHub
4.3.1     Az.KeyVault
2.0.0     Az.Kusto
1.5.0     Az.LogicApp
1.1.3     Az.MachineLearning
1.2.0     Az.Maintenance
3.0.0     Az.ManagedServices
1.0.2     Az.MarketplaceOrdering
1.1.1     Az.Media
1.1.2     Az.Migrate
3.0.1     Az.Monitor
1.0.0     Az.MySql
4.16.0    Az.Network
1.1.1     Az.NotificationHubs
3.1.0     Az.OperationalInsights
1.5.0     Az.PolicyInsights
1.1.0     Az.PostgreSql
1.1.2     Az.PowerBIEmbedded
1.0.3     Az.PrivateDns
5.3.0     Az.RecoveryServices
1.6.0     Az.RedisCache
1.0.0     Az.RedisEnterpriseCache
1.0.3     Az.Relay
1.1.0     Az.ResourceMover
5.5.0     Az.Resources
1.1.1     Az.Security
1.1.0     Az.SecurityInsights
1.8.1     Az.ServiceBus
3.0.2     Az.ServiceFabric
1.4.1     Az.SignalR
3.8.0     Az.Sql
1.1.0     Az.SqlVirtualMachine
1.1.0     Az.StackHCI
4.4.0     Az.Storage
1.7.0     Az.StorageSync
2.0.0     Az.StreamAnalytics
1.0.0     Az.Support
1.2.0     Az.Synapse
1.1.0     Az.TrafficManager
2.11.0    Az.Websites
0.1.599.7 AzureAD.Standard.Preview
0.9.3     AzurePSDrive
blueww commented 2 years ago

@dingmeng-xue It looks the method from Azure.core 1.22.0 not work in PSH 7. 'System.Collections.Generic.IAsyncEnumerable1<Azure.Page1<!0>> Azure.AsyncPageable1.AsPages(System.String, System.Nullable1)'.

I have raised a workaround fix to change the async call to sync call. https://github.com/Azure/azure-powershell/pull/17724 However, do you have any idea why the asyc call not work?

blueww commented 2 years ago

@rybal06 Az.Storage 4.4.1 is already release to fix this issue. https://github.com/Azure/azure-powershell/releases/tag/Az.Storage-v4.4.1 Please upgrade Az.Storage to the latest version and try again.

blueww commented 2 years ago

@robbinscp

For CloudShell, you can run "Install-Module Az.Storage -RequiredVersion 4.4.1 -Force" in CloudShell, to make sure Az.Storage 4.4.1 is installed, then close and reopen cloudshell to load Az.Storage 4.4.1.