1

Im getting the below error when i tried to fetch the data from Azure Table storage using Get-AzTableRow -table

Get-AzTableRow -table $table -customFilter $filter1

Error message:

Method invocation failed because [Microsoft.WindowsAzure.Commands.Common.Storage.ResourceModel.AzureStorageTable] does not contain a method named 'ExecuteQuerySegmentedAsync'.

Modules:

Install-PackageProvider -Name NuGet -Force -Scope CurrentUser
Install-Module -Name Az.Storage -MinimumVersion 1.1.0 -Force -Scope CurrentUser
Install-Module -Name AzTable -Force -Scope CurrentUser
Install-Module -Name Az.Resources -MinimumVersion 1.2.0 -Force -Scope CurrentUser

I tried many ways by removing all modules then imported Az module alone and did one by one

[string]$filter1 = [Microsoft.Azure.Cosmos.Table.TableQuery]::GenerateFilterCondition("PartitionKey",[Microsoft.Azure.Cosmos.Table.QueryComparisons]::Equal,$partitionKeyColumnValue)


$setting = Get-AzTableRow -table $table -customFilter $filter1
Michael B.
  • 558
  • 3
  • 11
Sajiv Sriraam
  • 189
  • 1
  • 2
  • 9
  • Try to update the module Az.Storage into 1.3.0 version. Do not forget to update the current module in use. – Charles Xu Jun 04 '19 at 01:45
  • @CharlesXu this commandlet is not from Az.Storage - it comes from AzTable module. And it doesn't work in the latest version. – Hardoman Sep 23 '21 at 09:13

2 Answers2

1

The cmdlet Get-AzTableRow parameter -table should accept type "CloudTable", but the output of cmdlet Get-AzStorageTable is in type "AzureStorageTable", so they are not match.

If you are curious you can check that it's CosmosDB table type:

$cloudTable | gm


   TypeName: Microsoft.Azure.Cosmos.Table.CloudTable

Name                       MemberType Definition                                                                                                                                         
----                       ---------- ----------                                                                                                                                         
Create                     Method     void Create(System.Nullable[Microsoft.Azure.Cosmos.IndexingMode] indexingMode, System.Nullable[int] throughput, System.Nullable[int] defaultTime...
CreateAsync                Method     System.Threading.Tasks.Task CreateAsync(), System.Threading.Tasks.Task CreateAsync(System.Threading.CancellationToken cancellationToken), System...
CreateIfNotExists          Method     bool CreateIfNotExists(Microsoft.Azure.Cosmos.IndexingMode indexingMode, System.Nullable[int] throughput, System.Nullable[int] defaultTimeToLive...
CreateIfNotExistsAsync     Method     System.Threading.Tasks.Task[bool] CreateIfNotExistsAsync(), System.Threading.Tasks.Task[bool] CreateIfNotExistsAsync(System.Threading.Cancellati...
CreateQuery                Method     Microsoft.Azure.Cosmos.Table.TableQuery[TElement] CreateQuery[TElement]()                                                                          
Delete                     Method     void Delete(Microsoft.Azure.Cosmos.Table.TableRequestOptions requestOptions, Microsoft.Azure.Cosmos.Table.OperationContext operationContext)       
DeleteAsync                Method     System.Threading.Tasks.Task DeleteAsync(), System.Threading.Tasks.Task DeleteAsync(System.Threading.CancellationToken cancellationToken), System...
DeleteIfExists             Method     bool DeleteIfExists(Microsoft.Azure.Cosmos.Table.TableRequestOptions requestOptions, Microsoft.Azure.Cosmos.Table.OperationContext operationCont...
DeleteIfExistsAsync        Method     System.Threading.Tasks.Task[bool] DeleteIfExistsAsync(), System.Threading.Tasks.Task[bool] DeleteIfExistsAsync(System.Threading.CancellationToke...
Equals                     Method     bool Equals(System.Object obj)                                                                                                                     
Execute                    Method     Microsoft.Azure.Cosmos.Table.TableResult Execute(Microsoft.Azure.Cosmos.Table.TableOperation operation, Microsoft.Azure.Cosmos.Table.TableReques...
ExecuteAsync               Method     System.Threading.Tasks.Task[Microsoft.Azure.Cosmos.Table.TableResult] ExecuteAsync(Microsoft.Azure.Cosmos.Table.TableOperation operation), Syste...
ExecuteBatch               Method     Microsoft.Azure.Cosmos.Table.TableBatchResult ExecuteBatch(Microsoft.Azure.Cosmos.Table.TableBatchOperation batch, Microsoft.Azure.Cosmos.Table....
ExecuteBatchAsync          Method     System.Threading.Tasks.Task[Microsoft.Azure.Cosmos.Table.TableBatchResult] ExecuteBatchAsync(Microsoft.Azure.Cosmos.Table.TableBatchOperation ba...
ExecuteQuery               Method     System.Collections.Generic.IEnumerable[Microsoft.Azure.Cosmos.Table.DynamicTableEntity] ExecuteQuery(Microsoft.Azure.Cosmos.Table.TableQuery que...
ExecuteQuerySegmented      Method     Microsoft.Azure.Cosmos.Table.TableQuerySegment[Microsoft.Azure.Cosmos.Table.DynamicTableEntity] ExecuteQuerySegmented(Microsoft.Azure.Cosmos.Tab...
ExecuteQuerySegmentedAsync Method     System.Threading.Tasks.Task[Microsoft.Azure.Cosmos.Table.TableQuerySegment[Microsoft.Azure.Cosmos.Table.DynamicTableEntity]] ExecuteQuerySegment...
Exists                     Method     bool Exists(Microsoft.Azure.Cosmos.Table.TableRequestOptions requestOptions, Microsoft.Azure.Cosmos.Table.OperationContext operationContext)       
ExistsAsync                Method     System.Threading.Tasks.Task[bool] ExistsAsync(), System.Threading.Tasks.Task[bool] ExistsAsync(System.Threading.CancellationToken cancellationTo...
GetHashCode                Method     int GetHashCode()                                                                                                                                  
GetPermissions             Method     Microsoft.Azure.Cosmos.Table.TablePermissions GetPermissions(Microsoft.Azure.Cosmos.Table.TableRequestOptions requestOptions, Microsoft.Azure.Co...
GetPermissionsAsync        Method     System.Threading.Tasks.Task[Microsoft.Azure.Cosmos.Table.TablePermissions] GetPermissionsAsync(), System.Threading.Tasks.Task[Microsoft.Azure.Co...
GetSharedAccessSignature   Method     string GetSharedAccessSignature(Microsoft.Azure.Cosmos.Table.SharedAccessTablePolicy policy), string GetSharedAccessSignature(Microsoft.Azure.Co...
GetType                    Method     type GetType()                                                                                                                                     
SetPermissions             Method     void SetPermissions(Microsoft.Azure.Cosmos.Table.TablePermissions permissions, Microsoft.Azure.Cosmos.Table.TableRequestOptions requestOptions, ...
SetPermissionsAsync        Method     System.Threading.Tasks.Task SetPermissionsAsync(Microsoft.Azure.Cosmos.Table.TablePermissions permissions), System.Threading.Tasks.Task SetPermi...
ToString                   Method     string ToString()                                                                                                                                  
Name                       Property   string Name {get;}                                                                                                                                 
ServiceClient              Property   Microsoft.Azure.Cosmos.Table.CloudTableClient ServiceClient {get;}                                                                                 
StorageUri                 Property   Microsoft.Azure.Cosmos.Table.StorageUri StorageUri {get;}                                                                                          
Uri                        Property   uri Uri {get;}         

So, first you need to get the reference to this object type with:

$cloudTable = (Get-AzStorageTable –Name $tableName –Context $ctx).CloudTable

and then use it in the command:

Get-AzTableRow -Table $cloudTable

Please refer to the official docs: https://learn.microsoft.com/en-us/azure/storage/tables/table-storage-how-to-use-powershell#reference-cloudtable-property-of-a-specific-table

Hardoman
  • 254
  • 1
  • 13
-1

Try using PowerShell core. It might quickly resolve your issue. If so it's your PowerShell version.

https://learn.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-2.1.0

  • This is completely irrelevant to PS version and it doesn't work in neither PS core nor in PS 7.1.4 modern app. – Hardoman Sep 23 '21 at 09:14