You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/storage/tables/table-storage-how-to-use-powershell.md
+30-22Lines changed: 30 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ author: roygara
5
5
6
6
ms.service: storage
7
7
ms.topic: article
8
-
ms.date: 04/05/2019
8
+
ms.date: 06/23/2022
9
9
ms.author: rogarana
10
10
ms.subservice: tables
11
11
ms.custom: devx-track-azurepowershell
@@ -26,32 +26,36 @@ This how-to article covers common Azure Table storage operations. You learn how
26
26
> * Delete table entities
27
27
> * Delete a table
28
28
29
-
This how-to article shows you how to create a new Azure Storage account in a new resource group so you can easily remove it when you're done. If you'd rather use an existing Storage account, you can do that instead.
29
+
This how-to article shows you how to create a new storage account in a new resource group so you can easily remove it when you're done. You can also use an existing storage account.
30
30
31
31
The examples require Az PowerShell modules `Az.Storage (1.1.0 or greater)` and `Az.Resources (1.2.0 or greater)`. In a PowerShell window, run `Get-Module -ListAvailable Az*` to find the version. If nothing is displayed, or you need to upgrade, see [Install Azure PowerShell module](/powershell/azure/install-az-ps).
32
32
33
33
> [!IMPORTANT]
34
-
> Using this Azure feature from PowerShell requires that you have the `Az` module installed. The current version of `AzTable` is not compatible with the older AzureRM module.
35
-
> Follow the [latest install instructions for installing Az module](/powershell/azure/install-az-ps) if needed.
34
+
> Using this Azure feature from PowerShell requires that you have the `Az` module installed. The current version of `AzTable` is not compatible with the older AzureRM module. Follow the [latest install instructions for installing Az module](/powershell/azure/install-az-ps) if needed.
35
+
>
36
+
> For module name compatibility reasons, this module is also published under the previous name `AzureRmStorageTables` in PowerShell Gallery. This document will reference the new name only.
36
37
37
38
After Azure PowerShell is installed or updated, you must install module **AzTable**, which has the commands for managing the entities. To install this module, run PowerShell as an administrator and use the **Install-Module** command.
38
39
39
-
> [!IMPORTANT]
40
-
> For module name compatibility reasons we are still publishing this same module under the old name `AzureRmStorageTables` in PowerShell Gallery. This document will reference the new name only.
41
-
42
40
```powershell
43
41
Install-Module AzTable
44
42
```
45
43
46
-
## Sign in to Azure
44
+
## Authorizing table data operations
45
+
46
+
The AzTable PowerShell module supports authorization with the account key via Shared Key authorization. For examples that show how to use Shared Key authorization for data access with the AzTable module, see [Use Shared Key authorization with the AzTable module](#use-shared-key-authorization-with-the-aztable-module).
47
+
48
+
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.
47
49
48
-
Sign in to your Azure subscription with the `Add-AzAccount` command and follow the on-screen directions.
50
+
## Use Shared Key authorization with the AzTable module
51
+
52
+
To get started, sign in to your Azure subscription with the `Add-AzAccount` command and follow the on-screen directions.
49
53
50
54
```powershell
51
55
Add-AzAccount
52
56
```
53
57
54
-
## Retrieve list of locations
58
+
###Retrieve list of locations
55
59
56
60
If you don't know which location you want to use, you can list the available locations. After the list is displayed, find the one you want to use. These examples use **eastus**. Store this value in the variable **location** for future use.
Create a resource group with the [New-AzResourceGroup](/powershell/module/az.resources/new-azresourcegroup) command.
69
+
Create a resource group with the [New-AzResourceGroup](/powershell/module/az.resources/new-azresourcegroup) command.
66
70
67
71
An Azure resource group is a logical container into which Azure resources are deployed and managed. Store the resource group name in a variable for future use. In this example, a resource group named *pshtablesrg* is created in the *eastus* region.
Create a standard general-purpose storage account with locally redundant storage (LRS) using [New-AzStorageAccount](/powershell/module/az.storage/New-azStorageAccount). Be sure to specify a unique storage account name. Next, get the context that represents the storage account. When acting on a storage account, you can reference the context instead of repeatedly providing your credentials.
To create a table, use the [New-AzStorageTable](/powershell/module/az.storage/New-AzStorageTable) cmdlet. In this example, the table is called `pshtesttable`.
92
96
@@ -95,36 +99,36 @@ $tableName = "pshtesttable"
95
99
New-AzStorageTable –Name $tableName –Context $ctx
96
100
```
97
101
98
-
## Retrieve a list of tables in the storage account
102
+
###Retrieve a list of tables in the storage account
99
103
100
104
Retrieve a list of tables in the storage account using [Get-AzStorageTable](/powershell/module/az.storage/Get-AzStorageTable).
101
105
102
106
```powershell
103
107
Get-AzStorageTable –Context $ctx | select Name
104
108
```
105
109
106
-
## Retrieve a reference to a specific table
110
+
###Retrieve a reference to a specific table
107
111
108
112
To perform operations on a table, you need a reference to the specific table. Get a reference using [Get-AzStorageTable](/powershell/module/az.storage/Get-AzStorageTable).
## Reference CloudTable property of a specific table
118
+
###Reference the CloudTable property of a specific table
115
119
116
120
> [!IMPORTANT]
117
-
> Usage of CloudTableis mandatory when working with **AzTable** PowerShell module. Call the **Get-AzStorageTable** command to get the reference to this object. This command also creates the table if it does not already exist.
121
+
> Using the **CloudTable** property is mandatory when working with table data via the**AzTable** PowerShell module. Call the **Get-AzStorageTable** command to get the reference to this object. This command also creates the table if it does not already exist.
118
122
119
-
To perform operations on a table using **AzTable**, you need a reference to CloudTable property of a specific table.
123
+
To perform operations on a table using **AzTable**, return a reference to the **CloudTable** property of a specific table. The **CloudTable** property exposes the .NET methods available for managing table data from PowerShell.
To delete a table, use [Remove-AzStorageTable](/powershell/module/az.storage/Remove-AzStorageTable). This cmdlet removes the table, including all of its data.
If you created a new resource group and storage account at the beginning of this how-to, you can remove all of the assets you have created in this exercise by removing the resource group. This command deletes all resources contained within the group as well as the resource group itself.
0 commit comments