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

Mohamed Sahbi 51 Reputation points
2022-11-18T08:36:08.107+00:00

Hello,

I ran into this error when I try to add new row while using the ConnectedAccount context rather than a key based authentication.

MethodInvocationException: Exception calling "Execute" with "1" argument(s): "The specified resource does not exist."  

This is the script code:

Connect-AzAccount  
Set-AzContext -Subscription "<subscription name>"  
$storageAccount = Get-AzStorageAccount -ResourceGroupName "<resoruce group name" -Name "<storage account name>"  
$Context = New-AzStorageContext -StorageAccountName "<storage account name>" -UseConnectedAccount  
$tableName = "testTable"  
New-AzStorageTable –Name $tableName –Context $Context   
      
Get-AzStorageTable –Context $Context | select Name  
$storageTable = Get-AzStorageTable –Name $tableName –Context $Context  
$cloudTable = $storageTable.CloudTable  
$partitionKey1 = "partition1"  
$partitionKey2 = "partition2"  
      
Add-AzTableRow `  
    -table $cloudTable `  
    -partitionKey $partitionKey1 `  
    -rowKey ("CA") -Property @{"username" = "Dude"; "userid" = 1 }  
      
Add-AzTableRow `  
    -table $cloudTable `  
    -partitionKey $partitionKey2 `  
    -rowKey (XY) -property @{"username" = "Christine"; "userid" = 3 }  

How to fix this error?

Thank you.

Azure Table Storage
Azure Table Storage
An Azure service that stores structured NoSQL data in the cloud.
162 questions
Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
2,875 questions
{count} vote

Accepted answer
  1. SaiKishor-MSFT 17,216 Reputation points
    2022-11-18T21:35:13.637+00:00

    @Mohamed Sahbi From Authorizing table data operations:

    The AzTable PowerShell module supports authorization with the account access key via Shared Key authorization. The examples in this article show how to authorize table data operations via Shared Key.

    Azure Table Storage supports authorization with Azure AD. However, the AzTable PowerShell module does not natively support authorization with Azure AD. Using Azure AD with the AzTable module requires that you call methods in the .NET client library from PowerShell.

    Hope this helps. Please let us know if you have any more questions and we will be glad to assist you further. Thank you!

    Remember:

    Please accept an answer if correct. Original posters help the community find answers faster by identifying the correct answer. Here is how.

    Want a reminder to come back and check responses? Here is how to subscribe to a notification.


0 additional answers

Sort by: Most helpful