@@ -33,10 +33,10 @@ or [Azure CLI](https://docs.microsoft.com/azure/storage/common/storage-quickstar
33
33
``` bash
34
34
# Create a new resource group to hold the storage account -
35
35
# if using an existing resource group, skip this step
36
- az group create --name my-resource-group --location westus2
36
+ az group create --name MyResourceGroup --location westus2
37
37
38
38
# Create the storage account
39
- az storage account create -n my-storage-account-name -g my-resource-group
39
+ az storage account create -n mystorageaccount -g MyResourceGroup
40
40
```
41
41
42
42
### Create the client
@@ -48,7 +48,7 @@ you to access the storage account:
48
48
``` python
49
49
from azure.table import TableServiceClient
50
50
51
- service = TableServiceClient(account_url = " https://<my-storage-account-name >.table.core.windows.net/" , credential = credential)
51
+ service = TableServiceClient(account_url = " https://<mystorageaccount >.table.core.windows.net/" , credential = credential)
52
52
```
53
53
54
54
#### Looking up the account URL
@@ -59,7 +59,7 @@ or [Azure CLI](https://docs.microsoft.com/cli/azure/storage/account?view=azure-c
59
59
60
60
``` bash
61
61
# Get the table service URL for the storage account
62
- az storage account show -n my-storage-account-name -g my-resource-group --query " primaryEndpoints.table"
62
+ az storage account show -n mystorageaccount -g MyResourceGroup --query " primaryEndpoints.table"
63
63
```
64
64
65
65
#### Types of credentials
@@ -89,7 +89,7 @@ The `credential` parameter may be provided in a number of different forms, depen
89
89
(aka account key or access key), provide the key as a string. This can be found in the Azure Portal under the " Access Keys"
90
90
section or by running the following Azure CLI command:
91
91
92
- ```az storage account keys list - g MyResourceGroup - n MyStorageAccount ```
92
+ ```az storage account keys list - g MyResourceGroup - n mystorageaccount ```
93
93
94
94
Use the key as the credential parameter to authenticate the client:
95
95
```python
@@ -112,7 +112,7 @@ service = TableServiceClient.from_connection_string(conn_str=connection_string)
112
112
The connection string to your storage account can be found in the Azure Portal under the "Access Keys" section or by running the following CLI command:
113
113
114
114
``` bash
115
- az storage account show-connection-string -g MyResourceGroup -n MyStorageAccount
115
+ az storage account show-connection-string -g MyResourceGroup -n mystorageaccount
116
116
```
117
117
118
118
## Key concepts
@@ -158,16 +158,16 @@ Create a table in your storage account
158
158
``` python
159
159
from azure.table import TableServiceClient
160
160
161
- table = TableServiceClient.from_connection_string(conn_str = " <connection_string>" )
162
- table .create_table(table_name = " myTable" )
161
+ table_service_client = TableServiceClient.from_connection_string(conn_str = " <connection_string>" )
162
+ table_service_client .create_table(table_name = " myTable" )
163
163
```
164
164
165
165
Use the async client to create a table
166
166
``` python
167
167
from azure.table.aio import TableServiceClient
168
168
169
- table = TableServiceClient.from_connection_string(conn_str = " <connection_string>" )
170
- await table .create_table(table_name = " myTable" )
169
+ table_service_client = TableServiceClient.from_connection_string(conn_str = " <connection_string>" )
170
+ await table_service_client .create_table(table_name = " myTable" )
171
171
```
172
172
173
173
### Creating entities
@@ -178,19 +178,25 @@ from azure.table import TableClient
178
178
179
179
my_entity = {' PartitionKey' :' part' ,' RowKey' :' row' }
180
180
181
- table = TableClient.from_connection_string(conn_str = " <connection_string>" , table_name = " my_table " )
182
- entity = table .create_entity(table_entity_properties = my_entity)
181
+ table_client = TableClient.from_connection_string(conn_str = " <connection_string>" , table_name = " myTable " )
182
+ entity = table_client .create_entity(entity = my_entity)
183
183
```
184
184
185
185
Create entities asynchronously
186
186
187
187
``` python
188
188
from azure.table.aio import TableClient
189
189
190
- my_entity = {' PartitionKey' :' part' ,' RowKey' :' row' }
190
+ my_entity = {
191
+ ' PartitionKey' : ' color' ,
192
+ ' RowKey' : ' brand' ,
193
+ ' text' : ' Marker' ,
194
+ ' color' : ' Purple' ,
195
+ ' price' : ' 5' ,
196
+ }
191
197
192
- table = TableClient.from_connection_string(conn_str = " <connection_string>" , table_name = " my_table " )
193
- entity = await table .create_entity(table_entity_properties = my_entity)
198
+ table_client = TableClient.from_connection_string(conn_str = " <connection_string>" , table_name = " mytable " )
199
+ entity = await table_client .create_entity(entity = my_entity)
194
200
```
195
201
196
202
### Querying entities
@@ -199,17 +205,21 @@ Querying entities in the table
199
205
``` python
200
206
from azure.table import TableClient
201
207
202
- table = TableClient.from_connection_string(conn_str = " <connection_string>" , table_name = " my_table" )
203
- entity = table.query_entities(results_per_page = 3 )
208
+ my_filter = " text eq Marker"
209
+
210
+ table_client = TableClient.from_connection_string(conn_str = " <connection_string>" , table_name = " mytable" )
211
+ entity = table_client.query_entities(filter = my_filter)
204
212
```
205
213
206
214
Querying entities asynchronously
207
215
208
216
``` python
209
217
from azure.table.aio import TableClient
210
218
211
- table = TableClient.from_connection_string(conn_str = " <connection_string>" , table_name = " my_table" )
212
- entity = await table.query_entities(results_per_page = 3 )
219
+ my_filter = " text eq Marker"
220
+
221
+ table_client = TableClient.from_connection_string(conn_str = " <connection_string>" , table_name = " mytable" )
222
+ entity = await table_client.query_entities(filter = my_filter)
213
223
```
214
224
215
225
## Optional Configuration
0 commit comments