Не удается найти перегрузку для «ExecuteQuerySegmentedAsync» и количества аргументов: «2» в Get-AzTableRow - PullRequest
0 голосов
/ 31 мая 2019

Я пытаюсь использовать Get-AzTableRow для получения строки таблицы Azure с последующим ее обновлением.Но командлет выдает следующие ошибки:

  PS C:\WINDOWS\system32> Get-AzTableRow -ColumnName "NsgName" -Value "subnet1invnet4-nsg" -Operator "Equal"
  You cannot call a method on a null-valued expression.
  At C:\Users\sayghosh\Documents\WindowsPowerShell\Modules\AzTable\2.0.2\AzureRmStorageTableCoreHelper.psm1:52 char:4
   +             $Results = $Table.ExecuteQuerySegmentedAsync($TableQuery, ...
   +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
   + FullyQualifiedErrorId : InvokeMethodOnNull

PS C:\WINDOWS\system32> Get-AzTableRow -table $storageCloudTable
Cannot find an overload for "ExecuteQuerySegmentedAsync" and the argument count: "2".
At C:\Users\sayghosh\Documents\WindowsPowerShell\Modules\AzTable\2.0.2\AzureRmStorageTableCoreHelper.psm1:52 char:4
 +             $Results = $Table.ExecuteQuerySegmentedAsync($TableQuery, ...
 +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 + CategoryInfo          : NotSpecified: (:) [], MethodException
 + FullyQualifiedErrorId : MethodCountCouldNotFindBest

Любой вывод здесь будет полезен.

1 Ответ

0 голосов
/ 14 июня 2019

Проверьте приведенный ниже скрипт для установки контекста хранилища и использования cloudtable для чтения строки таблицы и ее обновления.

#To install the AzTable module if not already installed
#Install-Module AzTable
#set the subscription contenxt if not already set
#Set-AzContext -Subscription "Subscription Name"

$storageAccountName = "storageaccountName"
$tableName = "storagetableName"
$partitionKey1 = "partitionKey"
$resourceGroup = "ResourceGroup Name"


$storageAccount = Get-AzStorageAccount -ResourceGroupName $resourceGroup -Name  $storageAccountName

# Get the Storage Contenxt
$ctx = $storageAccount.Context

# Usage of CloudTable is mandatory when working with AzTable PowerShell module.
$cloudTable = (Get-AzStorageTable -Name $tableName -Context $ctx ).CloudTable

# different ways to get the table row
#Get-AzTableRow -table $cloudTable -customFilter "(username eq 'bob2')"
#Get-AzTableRow -Table $cloudTable -ColumnName "username" -Value "bob2" -Operator Equal

#Create a filter and get the entity to be updated.
[string]$filter =    [Microsoft.Azure.Cosmos.Table.TableQuery]::GenerateFilterCondition("username",       
[Microsoft.Azure.Cosmos.Table.QueryComparisons]::Equal,"bob2")

$user = Get-AzTableRow  -table $cloudTable -customFilter $filter

# Change the entity.
$user.username = "james"

# To commit the change, pipe the updated record into the update cmdlet.
$user | Update-AzTableRow -table $cloudTable

# To see the new record, query the table.
Get-AzTableRow -table $cloudTable -customFilter "(username eq 'james')"`

Дополнительная справочная документация

Надеюсь, это поможет.

...