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

Siv*_*mar 6 azure-storage azure-table-storage azure-cloud-shell

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

块引用

 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.
Run Code Online (Sandbox Code Playgroud)

块引用

下面是命令:

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


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

Jim*_* Xu 7

根据错误提示,您似乎没有安装模块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}
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明