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
description: In this quickstart, you learn how to use the Azure Blob Storage client library version 12 for Python to create a container and a blob in Blob (object) storage. Next, you learn how to download the blob to your local computer, and how to list all of the blobs in a container.
4
4
author: pauljewellmsft
5
5
ms.author: pauljewell
6
-
ms.date: 01/28/2021
6
+
ms.date: 09/26/2022
7
7
ms.topic: quickstart
8
8
ms.service: storage
9
9
ms.subservice: blobs
10
10
ms.devlang: python
11
11
ms.custom: devx-track-python, mode-api
12
12
---
13
13
14
-
# Quickstart: Manage blobs with Python v12 SDK
14
+
# Quickstart: Azure Blob Storage client library for Python
15
15
16
-
In this quickstart, you learn to manage blobs by using Python. Blobs are objects that can hold large amounts of text or binary data, including images, documents, streaming media, and archive data. You'll upload, download, and list blobs, and you'll create and delete containers.
16
+
Get started with the Azure Blob Storage client library for Python to manage blobs and containers. Follow steps to install the package and try out example code for basic tasks.
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio).
28
-
- An Azure Storage account. [Create a storage account](../common/storage-account-create.md).
22
+
- An Azure account with an active subscription - [create an account for free](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio).
23
+
- An Azure Storage account - [create a storage account](../common/storage-account-create.md).
29
24
-[Python](https://www.python.org/downloads/) 2.7 or 3.6+.
30
25
31
26
## Setting up
@@ -36,7 +31,7 @@ This section walks you through preparing a project to work with the Azure Blob S
36
31
37
32
Create a Python application named *blob-quickstart-v12*.
38
33
39
-
1. In a console window (such as cmd, PowerShell, or Bash), create a new directory for the project.
34
+
1. In a console window (such as PowerShell, cmd, or bash), create a new directory for the project.
40
35
41
36
```console
42
37
mkdir blob-quickstart-v12
@@ -50,27 +45,22 @@ Create a Python application named *blob-quickstart-v12*.
50
45
51
46
### Install the package
52
47
53
-
While still in the application directory, install the Azure Blob Storage client library for Python package by using the `pip install` command.
48
+
From the project directory, install the Azure Blob Storage client library for Python package by using the `pip install` command.
54
49
55
50
```console
56
51
pip install azure-storage-blob
57
52
```
58
53
59
-
This command installs the Azure Blob Storage client library for Python package and all the libraries on which it depends. In this case, that is just the Azure core library for Python.
54
+
This command installs the Azure Blob Storage for Python package and libraries on which it depends. In this case, the only dependency is the Azure core library for Python.
60
55
61
56
### Set up the app framework
62
57
63
-
From the project directory:
58
+
From the project directory, follow steps to create the basic structure of the app:
64
59
65
60
1. Open a new text file in your code editor
66
-
1. Add `import` statements
67
-
1. Create the structure for the program, including basic exception handling
@@ -82,7 +72,7 @@ Azure Blob Storage is optimized for storing massive amounts of unstructured data
82
72
- A container in the storage account
83
73
- A blob in the container
84
74
85
-
The following diagram shows the relationship between these resources.
75
+
The following diagram shows the relationship between these resources:
86
76
87
77

88
78
@@ -96,14 +86,14 @@ Use the following Python classes to interact with these resources:
96
86
97
87
These example code snippets show you how to do the following tasks with the Azure Blob Storage client library for Python:
98
88
99
-
-[Get the connection string](#get-the-connection-string)
89
+
-[Get the connection string](#get-the-connection-string-for-authentication)
100
90
-[Create a container](#create-a-container)
101
91
-[Upload blobs to a container](#upload-blobs-to-a-container)
102
92
-[List the blobs in a container](#list-the-blobs-in-a-container)
103
93
-[Download blobs](#download-blobs)
104
94
-[Delete a container](#delete-a-container)
105
95
106
-
### Get the connection string
96
+
### Get the connection string for authentication
107
97
108
98
The code below retrieves the storage account connection string from the environment variable created in the [Configure your storage connection string](#configure-your-storage-connection-string) section.
109
99
@@ -157,7 +147,7 @@ Add this code to the end of the `try` block:
157
147
158
148
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.
159
149
160
-
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.
150
+
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.
161
151
162
152
Add this code to the end of the `try` block:
163
153
@@ -194,9 +184,11 @@ Deleting the local source and downloaded files...
194
184
Done
195
185
```
196
186
197
-
Before you begin the cleanup process, check your *data* folder for the two files. You can open them and observe that they're identical.
187
+
Before you begin the cleanup process, check your *data* folder for the two files. You can compare them and observe that they're identical.
188
+
189
+
## Clean up resources
198
190
199
-
After you've verified the files, press the **Enter** key to delete the test files and finish the demo.
191
+
After you've verified the files and finished testing, press the **Enter** key to delete the test files along with the container you created in the storage account.
0 commit comments