7

I'm trying to insert new row in my table storage by using Azure Cloud Shell but I'm facing below exception. So let me know any other command that we need to use to insert.

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

Below are the command:

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


Add-AzTableRow `
    -table $cloudTable `
    -partitionKey $partitionKey1 `
    -rowKey ("CA") -property @{"username"="Chris";"userid"=1}
Jim Xu
  • 21,610
  • 2
  • 19
  • 39
Sivakumar
  • 345
  • 4
  • 14
  • 1
    Do you have any other concerns? if you have no other concerns, could you please accept the answer? It may help more people – Jim Xu Mar 31 '20 at 00:56

1 Answers1

12

According to the error, it seems that you do not install the module AzTable. Please run the command Get-InstalledModule to check if you have installed the module. enter image description here

If you have not installed the module, please run the command Install-Module -Name AzTable -Force to install it.

For example

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}

enter image description here

Jim Xu
  • 21,610
  • 2
  • 19
  • 39