Skip to content

Commit 3100641

Browse files
[Storage] blob, fileshare, and queue README and samples clean-up (Azure#29002)
* Blob samples + readme * File-share readme * Queue readme & samples
1 parent 66f3395 commit 3100641

File tree

5 files changed

+29
-29
lines changed

5 files changed

+29
-29
lines changed

sdk/storage/azure-storage-blob/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ Create a container from where you can upload or download blobs.
219219
```python
220220
from azure.storage.blob import ContainerClient
221221

222-
container_client = ContainerClient.from_connection_string(conn_str="<connection_string>", container_name="my_container")
222+
container_client = ContainerClient.from_connection_string(conn_str="<connection_string>", container_name="mycontainer")
223223

224224
container_client.create_container()
225225
```
@@ -229,7 +229,7 @@ Use the async client to upload a blob
229229
```python
230230
from azure.storage.blob.aio import ContainerClient
231231

232-
container_client = ContainerClient.from_connection_string(conn_str="<connection_string>", container_name="my_container")
232+
container_client = ContainerClient.from_connection_string(conn_str="<connection_string>", container_name="mycontainer")
233233

234234
await container_client.create_container()
235235
```
@@ -240,7 +240,7 @@ Upload a blob to your container
240240
```python
241241
from azure.storage.blob import BlobClient
242242

243-
blob = BlobClient.from_connection_string(conn_str="<connection_string>", container_name="my_container", blob_name="my_blob")
243+
blob = BlobClient.from_connection_string(conn_str="<connection_string>", container_name="mycontainer", blob_name="my_blob")
244244

245245
with open("./SampleSource.txt", "rb") as data:
246246
blob.upload_blob(data)
@@ -251,7 +251,7 @@ Use the async client to upload a blob
251251
```python
252252
from azure.storage.blob.aio import BlobClient
253253

254-
blob = BlobClient.from_connection_string(conn_str="<connection_string>", container_name="my_container", blob_name="my_blob")
254+
blob = BlobClient.from_connection_string(conn_str="<connection_string>", container_name="mycontainer", blob_name="my_blob")
255255

256256
with open("./SampleSource.txt", "rb") as data:
257257
await blob.upload_blob(data)
@@ -263,7 +263,7 @@ Download a blob from your container
263263
```python
264264
from azure.storage.blob import BlobClient
265265

266-
blob = BlobClient.from_connection_string(conn_str="my_connection_string", container_name="my_container", blob_name="my_blob")
266+
blob = BlobClient.from_connection_string(conn_str="<connection_string>", container_name="mycontainer", blob_name="my_blob")
267267

268268
with open("./BlockDestination.txt", "wb") as my_blob:
269269
blob_data = blob.download_blob()
@@ -275,7 +275,7 @@ Download a blob asynchronously
275275
```python
276276
from azure.storage.blob.aio import BlobClient
277277

278-
blob = BlobClient.from_connection_string(conn_str="my_connection_string", container_name="my_container", blob_name="my_blob")
278+
blob = BlobClient.from_connection_string(conn_str="<connection_string>", container_name="mycontainer", blob_name="my_blob")
279279

280280
with open("./BlockDestination.txt", "wb") as my_blob:
281281
stream = await blob.download_blob()
@@ -289,7 +289,7 @@ List the blobs in your container
289289
```python
290290
from azure.storage.blob import ContainerClient
291291

292-
container = ContainerClient.from_connection_string(conn_str="my_connection_string", container_name="my_container")
292+
container = ContainerClient.from_connection_string(conn_str="<connection_string>", container_name="mycontainer")
293293

294294
blob_list = container.list_blobs()
295295
for blob in blob_list:
@@ -301,7 +301,7 @@ List the blobs asynchronously
301301
```python
302302
from azure.storage.blob.aio import ContainerClient
303303

304-
container = ContainerClient.from_connection_string(conn_str="my_connection_string", container_name="my_container")
304+
container = ContainerClient.from_connection_string(conn_str="<connection_string>", container_name="mycontainer")
305305

306306
blob_list = []
307307
async for blob in container.list_blobs():

sdk/storage/azure-storage-blob/samples/blob_samples_authentication_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ async def auth_default_azure_credential(self):
133133
# [END create_blob_service_client_oauth_default_credential]
134134

135135
# Get account information for the Blob Service
136-
account_info = blob_service_client.get_service_properties()
136+
account_info = await blob_service_client.get_service_properties()
137137

138138
async def main():
139139
sample = AuthSamplesAsync()

sdk/storage/azure-storage-file-share/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ Create a file share to store your files
172172
```python
173173
from azure.storage.fileshare import ShareClient
174174

175-
share = ShareClient.from_connection_string(conn_str="<connection_string>", share_name="my_share")
175+
share = ShareClient.from_connection_string(conn_str="<connection_string>", share_name="myshare")
176176
share.create_share()
177177
```
178178

@@ -181,7 +181,7 @@ Use the async client to create a file share
181181
```python
182182
from azure.storage.fileshare.aio import ShareClient
183183

184-
share = ShareClient.from_connection_string(conn_str="<connection_string>", share_name="my_share")
184+
share = ShareClient.from_connection_string(conn_str="<connection_string>", share_name="myshare")
185185
await share.create_share()
186186
```
187187

@@ -191,7 +191,7 @@ Upload a file to the share
191191
```python
192192
from azure.storage.fileshare import ShareFileClient
193193

194-
file_client = ShareFileClient.from_connection_string(conn_str="<connection_string>", share_name="my_share", file_path="my_file")
194+
file_client = ShareFileClient.from_connection_string(conn_str="<connection_string>", share_name="myshare", file_path="my_file")
195195

196196
with open("./SampleSource.txt", "rb") as source_file:
197197
file_client.upload_file(source_file)
@@ -202,7 +202,7 @@ Upload a file asynchronously
202202
```python
203203
from azure.storage.fileshare.aio import ShareFileClient
204204

205-
file_client = ShareFileClient.from_connection_string(conn_str="<connection_string>", share_name="my_share", file_path="my_file")
205+
file_client = ShareFileClient.from_connection_string(conn_str="<connection_string>", share_name="myshare", file_path="my_file")
206206

207207
with open("./SampleSource.txt", "rb") as source_file:
208208
await file_client.upload_file(source_file)
@@ -214,7 +214,7 @@ Download a file from the share
214214
```python
215215
from azure.storage.fileshare import ShareFileClient
216216

217-
file_client = ShareFileClient.from_connection_string(conn_str="<connection_string>", share_name="my_share", file_path="my_file")
217+
file_client = ShareFileClient.from_connection_string(conn_str="<connection_string>", share_name="myshare", file_path="my_file")
218218

219219
with open("DEST_FILE", "wb") as file_handle:
220220
data = file_client.download_file()
@@ -226,7 +226,7 @@ Download a file asynchronously
226226
```python
227227
from azure.storage.fileshare.aio import ShareFileClient
228228

229-
file_client = ShareFileClient.from_connection_string(conn_str="<connection_string>", share_name="my_share", file_path="my_file")
229+
file_client = ShareFileClient.from_connection_string(conn_str="<connection_string>", share_name="myshare", file_path="my_file")
230230

231231
with open("DEST_FILE", "wb") as file_handle:
232232
data = await file_client.download_file()
@@ -239,7 +239,7 @@ List all directories and files under a parent directory
239239
```python
240240
from azure.storage.fileshare import ShareDirectoryClient
241241

242-
parent_dir = ShareDirectoryClient.from_connection_string(conn_str="<connection_string>", share_name="my_share", directory_path="parent_dir")
242+
parent_dir = ShareDirectoryClient.from_connection_string(conn_str="<connection_string>", share_name="myshare", directory_path="parent_dir")
243243

244244
my_list = list(parent_dir.list_directories_and_files())
245245
print(my_list)
@@ -250,7 +250,7 @@ List contents of a directory asynchronously
250250
```python
251251
from azure.storage.fileshare.aio import ShareDirectoryClient
252252

253-
parent_dir = ShareDirectoryClient.from_connection_string(conn_str="<connection_string>", share_name="my_share", directory_path="parent_dir")
253+
parent_dir = ShareDirectoryClient.from_connection_string(conn_str="<connection_string>", share_name="myshare", directory_path="parent_dir")
254254

255255
my_files = []
256256
async for item in parent_dir.list_directories_and_files():

sdk/storage/azure-storage-queue/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,15 @@ Create a queue in your storage account
194194
```python
195195
from azure.storage.queue import QueueClient
196196

197-
queue = QueueClient.from_connection_string(conn_str="<connection_string>", queue_name="my_queue")
197+
queue = QueueClient.from_connection_string(conn_str="<connection_string>", queue_name="myqueue")
198198
queue.create_queue()
199199
```
200200

201201
Use the async client to create a queue
202202
```python
203203
from azure.storage.queue.aio import QueueClient
204204

205-
queue = QueueClient.from_connection_string(conn_str="<connection_string>", queue_name="my_queue")
205+
queue = QueueClient.from_connection_string(conn_str="<connection_string>", queue_name="myqueue")
206206
await queue.create_queue()
207207
```
208208

@@ -212,7 +212,7 @@ Send messages to your queue
212212
```python
213213
from azure.storage.queue import QueueClient
214214

215-
queue = QueueClient.from_connection_string(conn_str="<connection_string>", queue_name="my_queue")
215+
queue = QueueClient.from_connection_string(conn_str="<connection_string>", queue_name="myqueue")
216216
queue.send_message("I'm using queues!")
217217
queue.send_message("This is my second message")
218218
```
@@ -223,7 +223,7 @@ Send messages asynchronously
223223
import asyncio
224224
from azure.storage.queue.aio import QueueClient
225225

226-
queue = QueueClient.from_connection_string(conn_str="<connection_string>", queue_name="my_queue")
226+
queue = QueueClient.from_connection_string(conn_str="<connection_string>", queue_name="myqueue")
227227
await asyncio.gather(
228228
queue.send_message("I'm using queues!"),
229229
queue.send_message("This is my second message")
@@ -236,7 +236,7 @@ Receive and process messages from your queue
236236
```python
237237
from azure.storage.queue import QueueClient
238238

239-
queue = QueueClient.from_connection_string(conn_str="<connection_string>", queue_name="my_queue")
239+
queue = QueueClient.from_connection_string(conn_str="<connection_string>", queue_name="myqueue")
240240
response = queue.receive_messages()
241241

242242
for message in response:
@@ -253,7 +253,7 @@ Receive and process messages in batches
253253
```python
254254
from azure.storage.queue import QueueClient
255255

256-
queue = QueueClient.from_connection_string(conn_str="<connection_string>", queue_name="my_queue")
256+
queue = QueueClient.from_connection_string(conn_str="<connection_string>", queue_name="myqueue")
257257
response = queue.receive_messages(messages_per_page=10)
258258

259259
for message_batch in response.by_page():
@@ -267,7 +267,7 @@ Receive and process messages asynchronously
267267
```python
268268
from azure.storage.queue.aio import QueueClient
269269

270-
queue = QueueClient.from_connection_string(conn_str="<connection_string>", queue_name="my_queue")
270+
queue = QueueClient.from_connection_string(conn_str="<connection_string>", queue_name="myqueue")
271271
response = queue.receive_messages()
272272

273273
async for message in response:

sdk/storage/azure-storage-queue/samples/queue_samples_message_async.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ async def send_and_receive_messages_async(self):
152152
async def receive_one_message_from_queue(self):
153153
# Instantiate a queue client
154154
from azure.storage.queue.aio import QueueClient
155-
queue = QueueClient.from_connection_string(self.connection_string, "myqueue3")
155+
queue = QueueClient.from_connection_string(self.connection_string, "myqueue4")
156156

157157
# Create the queue
158158
async with queue:
@@ -182,7 +182,7 @@ async def receive_one_message_from_queue(self):
182182
async def delete_and_clear_messages_async(self):
183183
# Instantiate a queue client
184184
from azure.storage.queue.aio import QueueClient
185-
queue = QueueClient.from_connection_string(self.connection_string, "myqueue4")
185+
queue = QueueClient.from_connection_string(self.connection_string, "myqueue5")
186186

187187
# Create the queue
188188
async with queue:
@@ -218,7 +218,7 @@ async def delete_and_clear_messages_async(self):
218218
async def peek_messages_async(self):
219219
# Instantiate a queue client
220220
from azure.storage.queue.aio import QueueClient
221-
queue = QueueClient.from_connection_string(self.connection_string, "myqueue5")
221+
queue = QueueClient.from_connection_string(self.connection_string, "myqueue6")
222222

223223
# Create the queue
224224
async with queue:
@@ -253,7 +253,7 @@ async def peek_messages_async(self):
253253
async def update_message_async(self):
254254
# Instantiate a queue client
255255
from azure.storage.queue.aio import QueueClient
256-
queue = QueueClient.from_connection_string(self.connection_string, "myqueue6")
256+
queue = QueueClient.from_connection_string(self.connection_string, "myqueue7")
257257

258258
# Create the queue
259259
async with queue:
@@ -283,7 +283,7 @@ async def update_message_async(self):
283283
async def receive_messages_with_max_messages(self):
284284
# Instantiate a queue client
285285
from azure.storage.queue.aio import QueueClient
286-
queue = QueueClient.from_connection_string(self.connection_string, "myqueue7")
286+
queue = QueueClient.from_connection_string(self.connection_string, "myqueue8")
287287

288288
# Create the queue
289289
async with queue:

0 commit comments

Comments
 (0)