"Not Found" 在 Get-AzTableTable 之后立即调用 Get-AzTableRow 时 AzureRmStorageTableCoreHelper.psm1 出现异常
"Not Found" exception from AzureRmStorageTableCoreHelper.psm1 when calling Get-AzTableRow immediately after Get-AzTableTable
我有一个 PowerShell 脚本,我在其中依次调用 Get-AzTableTable、Get-AzTableRow 和 Add-AzTableRow。有时(但不总是),我从 Get-AzTableRow 收到以下错误:
Exception calling "Execute" with "1" argument(s): "Not Found"
At C:\Program Files\WindowsPowerShell\Modules\AzTable.0.2\AzureRmStorageTableCoreHelper.psm1:239 char:10
+ ... return ($Table.Execute([Microsoft.Azure.Cosmos.Table.TableOperat ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : StorageException
这似乎仅在 table 不存在时才会发生。我认为正在发生的事情是 Get-AzTableTable 正在异步创建它(通过 $Table.CreateIfNotExistsAsync()),而我在创建 table 之前调用 Get-AzTableRow。
这个问题的解决方案是什么?在检查行是否存在之前,如何确保 table 已创建?
在使用 $Table.CreateIfNotExistsAsync()
.
创建 table 之后,您可以只使用循环(如 while)来确定 table 是否存在
示例代码如下:
#create the table using $Table.CreateIfNotExistsAsync()
#here check if the table create or not
# Since I cannot see all your code, note that if $Table does not have a method Exists(), you can try use $Table.CloudTable.Exists()
while(!($Table.Exists()))
{
Start-Sleep -Seconds 2;
Write-Output "the table does not create, please wait."
}
#if the table exists, you can do other operation.
我有一个 PowerShell 脚本,我在其中依次调用 Get-AzTableTable、Get-AzTableRow 和 Add-AzTableRow。有时(但不总是),我从 Get-AzTableRow 收到以下错误:
Exception calling "Execute" with "1" argument(s): "Not Found"
At C:\Program Files\WindowsPowerShell\Modules\AzTable.0.2\AzureRmStorageTableCoreHelper.psm1:239 char:10
+ ... return ($Table.Execute([Microsoft.Azure.Cosmos.Table.TableOperat ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : StorageException
这似乎仅在 table 不存在时才会发生。我认为正在发生的事情是 Get-AzTableTable 正在异步创建它(通过 $Table.CreateIfNotExistsAsync()),而我在创建 table 之前调用 Get-AzTableRow。
这个问题的解决方案是什么?在检查行是否存在之前,如何确保 table 已创建?
在使用 $Table.CreateIfNotExistsAsync()
.
示例代码如下:
#create the table using $Table.CreateIfNotExistsAsync()
#here check if the table create or not
# Since I cannot see all your code, note that if $Table does not have a method Exists(), you can try use $Table.CloudTable.Exists()
while(!($Table.Exists()))
{
Start-Sleep -Seconds 2;
Write-Output "the table does not create, please wait."
}
#if the table exists, you can do other operation.