1

当我尝试使用从 Azure 表存储中获取数据时出现以下错误Get-AzTableRow -table

Get-AzTableRow -table $table -customFilter $filter1

错误信息:

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

模块:

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

我尝试了很多方法,删除所有模块,然后单独导入 Az 模块并一一进行

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


$setting = Get-AzTableRow -table $table -customFilter $filter1
4

2 回答 2

1

cmdletGet-AzTableRow参数 -table 应接受类型“CloudTable”,但 cmdlet Get-AzStorageTable 的输出类型为“AzureStorageTable”,因此它们不匹配。

如果您好奇,可以检查它是 CosmosDB 表类型:

$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;}         

因此,首先您需要通过以下方式获取对此对象类型的引用:

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

然后在命令中使用它:

Get-AzTableRow -Table $cloudTable

请参考官方文档: https ://docs.microsoft.com/en-us/azure/storage/tables/table-storage-how-to-use-powershell#reference-cloudtable-property-of-a-specific -桌子

于 2021-09-23T09:25:44.977 回答
-1

尝试使用 PowerShell 核心。它可能会很快解决您的问题。如果是这样,那就是您的 PowerShell 版本。

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

于 2019-06-03T13:44:40.403 回答