Add-AzTableRow throws error: The specified resource does not exist

AxelC 56 Reputation points
2022-09-06T08:53:52.487+00:00

Hello,

I am trying to manage Azure Storage Tables using PowerShell. I have installed the latest version of the Az and AzTable modules to do so.

For test purposes, I am currently only trying to add an entity in an existing table, following the documentation my code looks like this :

Connect-AzAccount  
  
$StorageAccountName = "stgorageaccountname"  
  
$Ctx = New-AzStorageContext -StorageAccountName $StorageAccountName  
  
$Table = (Get-AzStorageTable -Name "TableName" -Context $ctx).CloudTable  
  
Add-AzTableRow -Table $Table -PartitionKey "PK1" -RowKey "RK1" -property @{"Name"="John";"LastName"="Doe"}  

This code throws the error "The specified resource does not exist", yet it exists.

I can retrieve this table using the command Get-AzStorageTable.
I also am able to create a new table, but adding an entity to the newly created table throws the same error that the resource does not exist.

Is there something that I am missing ?

Thank you in advance for your kind support.

Axel

Azure Table Storage
Azure Table Storage
An Azure service that stores structured NoSQL data in the cloud.
171 questions
0 comments No comments
{count} votes

Accepted answer
  1. Anurag Sharma 17,606 Reputation points
    2022-09-06T10:53:54.027+00:00

    Hi @AxelC , welcome to Microsoft Q&A forum.

    Could you please try below script by replacing the placeholders with the correct values

    Connect-AzAccount  
    Set-AzContext -Subscription "<your subscription name>"  
    $storageAccountName ="<your storage account name>"  
    $resourceGroup = "<your resource group name>"  
    $storageAccount=Get-AzStorageAccount -ResourceGroupName $resourceGroup -Name $storageAccountName  
    $ctx = $storageAccount.Context  
    $tableName = "TableName"  
    $cloudTable = (Get-AzStorageTable –Name $tableName –Context $ctx).CloudTable  
    Add-AzTableRow -table $cloudTable -partitionKey "PK2" -rowKey ("CA") -property @{"username"="Chris";"userid"=1}  
    

    Reference Article: Add-AzTableRow

    Please let us know if this helps or else we can discuss further.

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.