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/blobs/storage-quickstart-blobs-python.md
+10-17Lines changed: 10 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -152,7 +152,7 @@ From an empty directory, follow these steps to initialize the `azd` template, pr
152
152
153
153
## Run the sample code
154
154
155
-
At this point, the resources are deployed to Azure and the project is ready to run. Follow these steps to update the name of the storage account in the code and run the sample console app:
155
+
At this point, the resources are deployed to Azure and the code is ready to run. Follow these steps to update the name of the storage account in the code and run the sample console app:
156
156
157
157
- **Update the storage account name**: In the local directory, edit the file named **blob_quickstart.py**. Find the `<storage-account-name>` placeholder and replace it with the actual name of the storage account created by the `azd up` command. Save the changes.
158
158
- **Run the project**: Execute the following command to run the app: `python blob_quickstart.py`.
@@ -196,7 +196,7 @@ These example code snippets show you how to do the following tasks with the Azur
196
196
::: zone pivot="blob-storage-quickstart-template"
197
197
198
198
> [!NOTE]
199
-
> The Azure Developer CLI template includes a project with sample code already in place. The following examples provide detail foreach part of the sample code. The template implements the recommended passwordless authentication method, as describedin the [Authenticate to Azure](#authenticate-to-azure-and-authorize-access-to-blob-data) section. The connection string method is shown as an alternative, but isn't used in the template and isn't recommended for production code.
199
+
> The Azure Developer CLI template includes a file with sample code already in place. The following examples provide detail foreach part of the sample code. The template implements the recommended passwordless authentication method, as describedin the [Authenticate to Azure](#authenticate-to-azure-and-authorize-access-to-blob-data) section. The connection string method is shown as an alternative, but isn't used in the template and isn't recommended for production code.
Decide on a name for the new container. The code below appends a UUID value to the container name to ensure that it's unique.
325
-
326
-
> [!IMPORTANT]
327
-
> Container names must be lowercase. For more information about naming containers and blobs, see [Naming and Referencing Containers, Blobs, and Metadata](/rest/api/storageservices/naming-and-referencing-containers--blobs--and-metadata).
328
-
329
-
Call the [create_container](/python/api/azure-storage-blob/azure.storage.blob.blobserviceclient#create-container-name--metadata-none--public-access-none----kwargs-) method to actually create the container in your storage account.
324
+
Create a new container in your storage account by calling the [create_container](/python/api/azure-storage-blob/azure.storage.blob.blobserviceclient#azure-storage-blob-blobserviceclient-create-container) method on the `blob_service_client` object. In this example, the code appends a GUID value to the container name to ensure that it's unique.
330
325
331
326
::: zone pivot="blob-storage-quickstart-scratch"
332
327
@@ -338,14 +333,12 @@ Add this code to the end of the `try` block:
338
333
339
334
To learn more about creating a container, and to explore more code samples, see [Create a blob container with Python](storage-blob-container-create-python.md).
340
335
341
-
### Upload blobs to a container
336
+
> [!IMPORTANT]
337
+
> Container names must be lowercase. For more information about naming containers and blobs, see [Naming and Referencing Containers, Blobs, and Metadata](/rest/api/storageservices/naming-and-referencing-containers--blobs--and-metadata).
342
338
343
-
The following code snippet:
339
+
### Upload blobs to a container
344
340
345
-
1. Creates a local directory to hold data files.
346
-
1. Creates a text file in the local directory.
347
-
1. Gets a reference to a [BlobClient](/python/api/azure-storage-blob/azure.storage.blob.blobclient) object by calling the [get_blob_client](/python/api/azure-storage-blob/azure.storage.blob.containerclient#get-blob-client-blob--snapshot-none-) method on the [BlobServiceClient](/python/api/azure-storage-blob/azure.storage.blob.blobserviceclient) from the [Create a container](#create-a-container) section.
348
-
1. Uploads the local text file to the blob by calling the [upload_blob](/python/api/azure-storage-blob/azure.storage.blob.blobclient#upload-blob-data--blob-type--blobtype-blockblob---blockblob----length-none--metadata-none----kwargs-) method.
341
+
Upload a blob to a container using [upload_blob](/python/api/azure-storage-blob/azure.storage.blob.blobclient#azure-storage-blob-blobclient-upload-blob). The example code creates a text file in the local *data* directory to upload to the container.
349
342
350
343
::: zone pivot="blob-storage-quickstart-scratch"
351
344
@@ -359,7 +352,7 @@ To learn more about uploading blobs, and to explore more code samples, see [Uplo
359
352
360
353
### List the blobs in a container
361
354
362
-
List the blobs in the container by calling the [list_blobs](/python/api/azure-storage-blob/azure.storage.blob.containerclient#list-blobs-name-starts-with-none--include-none----kwargs-) method. In this case, only one blob has been added to the container, so the listing operation returns just that one blob.
355
+
List the blobs in the container by calling the [list_blobs](/python/api/azure-storage-blob/azure.storage.blob.containerclient#azure-storage-blob-containerclient-list-blobs) method. In this case, only one blob has been added to the container, so the listing operation returns just that one blob.
363
356
364
357
::: zone pivot="blob-storage-quickstart-scratch"
365
358
@@ -373,7 +366,7 @@ To learn more about listing blobs, and to explore more code samples, see [List b
373
366
374
367
### Download blobs
375
368
376
-
Download the previously created blob by calling the [download_blob](/python/api/azure-storage-blob/azure.storage.blob.blobclient#download-blob-offset-none--length-none----kwargs-) method. The example code adds a suffix of "DOWNLOAD" to the file name so that you can see both files in local file system.
369
+
Download the previously created blob by calling the [download_blob](/python/api/azure-storage-blob/azure.storage.blob.containerclient#azure-storage-blob-containerclient-download-blob) method. The example code adds a suffix of "DOWNLOAD" to the file name so that you can see both files in local file system.
377
370
378
371
::: zone pivot="blob-storage-quickstart-scratch"
379
372
@@ -387,7 +380,7 @@ To learn more about downloading blobs, and to explore more code samples, see [Do
387
380
388
381
### Delete a container
389
382
390
-
The following code cleans up the resources the app created by removing the entire container using the [delete_container](/python/api/azure-storage-blob/azure.storage.blob.containerclient#delete-container---kwargs-) method. You can also delete the local files, if you like.
383
+
The following code cleans up the resources the app created by removing the entire container using the [delete_container](/python/api/azure-storage-blob/azure.storage.blob.containerclient#azure-storage-blob-containerclient-delete-container) method. You can also delete the local files, if you like.
391
384
392
385
The app pauses for user input by calling `input()` before it deletes the blob, container, and local files. Verify that the resources were created correctly before they're deleted.
0 commit comments