Add-AzTableRow 命令在 Azure 云中不可用 Shell

Add-AzTableRow command is not available in Azure Cloud Shell

我正在尝试使用 Azure Cloud Shell 在我的 table 存储中插入新行,但我遇到了以下异常。所以让我知道我们需要用来插入的任何其他命令。

Blockquote

 Add-AzTableRow: The term 'Add-AzTableRow' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Blockquote

命令如下:

$partitionKey1 = "partition1"
$partitionKey2 = "partition2"


Add-AzTableRow `
    -table $cloudTable `
    -partitionKey $partitionKey1 `
    -rowKey ("CA") -property @{"username"="Chris";"userid"=1}

根据错误,您似乎没有安装模块AzTable。请运行 命令Get-InstalledModule 检查您是否安装了该模块。

如果您还没有安装该模块,请运行命令Install-Module -Name AzTable -Force进行安装。

例如

Install-Module -Name AzTable -Force
Import-Module AzTable
$resourceGroup = "<your group name>"
$storageAccountName ="<your account name>"
$storageAccount=Get-AzStorageAccount -ResourceGroupName $resourceGroup -Name $storageAccountName
$ctx = $storageAccount.Context
$tableName = "<table name>"
$cloudTable = (Get-AzStorageTable –Name $tableName –Context $ctx).CloudTable

$partitionKey1 = "partition1"
Add-AzTableRow -table $cloudTable -partitionKey $partitionKey1 -rowKey ("CA") -property @{"username"="Chris";"userid"=1}