Add-AzTableRow command is not available in Azure Cloud Shell
Asked Answered
C

1

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}
Corliss answered 27/3, 2020 at 19:5 Comment(1)
Do you have any other concerns? if you have no other concerns, could you please accept the answer? It may help more peopleGingras
G
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

Gingras answered 30/3, 2020 at 3:20 Comment(3)
Thanks Jim for exact solution, I forget to execute this command "Install-Module -Name AzTable -Force".Corliss
Is the -force parameter essential?Basil
@RenéNyffenegger You can do not use it. Without it, powershell will ask you whether to install the module. with it, powershell will directly install the module.Gingras

© 2022 - 2024 — McMap. All rights reserved.