Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add-AzTableRow command is not available in Azure Cloud Shell

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}
like image 444
Sivakumar Avatar asked Mar 27 '20 19:03

Sivakumar


People also ask

What can you use to launch the Azure cloud shell?

You can access the Cloud Shell in three ways: Direct link: Open a browser to https://shell.azure.com. The Try It button opens the Cloud Shell directly alongside the documentation using Bash (for Azure CLI snippets) or PowerShell (for Azure PowerShell snippets).

How do I reset my Azure cloud shell?

Restart Cloud ShellClick the restart icon in the Cloud Shell toolbar to reset machine state. Restarting Cloud Shell will reset machine state and any files not persisted by your Azure file share will be lost.


1 Answers

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

like image 183
Jim Xu Avatar answered Nov 15 '22 10:11

Jim Xu