gpt4 book ai didi

azure - 使用 Get-AzTable Powershell 脚本访问 Azure 表中的数据时出错

转载 作者:行者123 更新时间:2023-12-03 02:50:20 26 4
gpt4 key购买 nike

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

Get-AzTableRow -table $table -customFilter $filter1

错误消息:

方法调用失败,因为 [Microsoft.WindowsAzure.Commands.Common.Storage.ResourceModel.AzureStorageTable] 不包含名为“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

最佳答案

cmdlet Get-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://learn.microsoft.com/en-us/azure/storage/tables/table-storage-how-to-use-powershell#reference-cloudtable-property-of-a-specific-table

关于azure - 使用 Get-AzTable Powershell 脚本访问 Azure 表中的数据时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56426253/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com