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
+25-32Lines changed: 25 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ ms.topic: quickstart
11
11
12
12
# Quickstart: Upload, download, and list blobs with Python
13
13
14
-
In this quickstart, you see how to use Python to upload, download, and list block blobs in a container in Azure Blob storage. Blobs are simply objects that can hold any amount of text or binary data including: images, documents, streaming media, archive data, and so on. They're distinct in Azure Storage from file shares, schema-less tables, and message queues. For more info, see [Introduction to Azure Storage](/azure/storage/common/storage-introduction).
14
+
In this quickstart, you use Python to upload, download, and list block blobs in a container in Azure Blob storage. Blobs are simply objects that can hold any amount of text or binary data, including images, documents, streaming media, and archive data. Blobs in Azure Storage are different from file shares, schema-less tables, and message queues. For more info, see [Introduction to Azure Storage](/azure/storage/common/storage-introduction).
This command clones the *Azure-Samples/storage-blobs-python-quickstart* repository to your local git folder. To run the Python program, open the *example.py* file at the root of the repository.
38
+
To review the Python program, open the *example.py* file at the root of the repository.
@@ -56,7 +56,7 @@ In the application, provide your storage account name and account key to create
56
56
57
57
## Run the sample
58
58
59
-
This sample creates a test fileinthe*Documents* folder. The sample program uploads the test file to Blob storage, lists the blobs in the container, and downloads the filewith a new name.
59
+
The sample program creates a test fileinyour*Documents* folder, uploads the file to Blob storage, lists the blobs in the file, and downloads the filewith a new name.
60
60
61
61
1. Install the dependencies:
62
62
@@ -89,36 +89,23 @@ This sample creates a test file in the *Documents* folder. The sample program up
89
89
Downloading blob to C:\Users\azureuser\Documents\QuickStart_9f4ed0f9-22d3-43e1-98d0-8b2c05c01078_DOWNLOADED.txt
90
90
```
91
91
92
-
1. Before you continue, go to your **Documents** folder and check for the two files.
92
+
1. Before you continue, go to your *Documents* folder and check for the two files.
You can also use a tool like the [Azure Storage Explorer](https://storageexplorer.com). It's good for viewing the files in Blob storage. Azure Storage Explorer is a free cross-platform tool that lets you access your storage account info.
100
100
101
-
1. After you've looked at the files, press any key to finish the demo and delete the test files.
102
-
103
-
Now that you know what the sample does, open the *example.py*file to look at the code.
101
+
1. After you've looked at the files, press any key to finish the sample and delete the test files.
104
102
105
103
## Learn about the sample code
106
104
107
-
Let’s walk through the sample code to learn how it works.
105
+
Now that you know what the sample does, open the *example.py*fileto look at the code.
108
106
109
107
### Get references to the storage objects
110
108
111
-
First, you create the references to the objects used to access and manage Blob storage. These objects build on each other, and each is used by the next one in the list.
112
-
113
-
* Instantiate the **BlockBlobService**object, which points to the Blob service in your storage account.
114
-
115
-
* Instantiate the **CloudBlobContainer**object, which represents the container you're accessing. The system uses containers to organize your blobs like you use folders on your computer to organize your files.
116
-
117
-
Once you have the Cloud Blob container, instantiate the **CloudBlockBlob**object that points to the specific blob that you're interested in. You can then upload, download, and copy the blob as you need.
118
-
119
-
> [!IMPORTANT]
120
-
> Container names must be lowercase. For more information about container and blob names, see [Naming and Referencing Containers, Blobs, and Metadata](https://docs.microsoft.com/rest/api/storageservices/naming-and-referencing-containers--blobs--and-metadata).
121
-
122
109
In this section, you instantiate the objects, create a new container, and then set permissions on the container so the blobs are public. You'll call the container `quickstartblobs`.
First, you create the references to the objects used to access and manage Blob storage. These objects build on each other, and each is used by the next one in the list.
126
+
127
+
* Instantiate the **BlockBlobService**object, which points to the Blob service in your storage account.
128
+
129
+
* Instantiate the **CloudBlobContainer**object, which represents the container you're accessing. The system uses containers to organize your blobs like you use folders on your computer to organize your files.
130
+
131
+
Once you have the Cloud Blob container, instantiate the **CloudBlockBlob**object that points to the specific blob that you're interested in. You can then upload, download, and copy the blob as you need.
132
+
133
+
> [!IMPORTANT]
134
+
> Container names must be lowercase. For more information about container and blob names, see [Naming and Referencing Containers, Blobs, and Metadata](https://docs.microsoft.com/rest/api/storageservices/naming-and-referencing-containers--blobs--and-metadata).
135
+
138
136
### Upload blobs to the container
139
137
140
-
Blob storage supports block blobs, append blobs, and page blobs. Block blobs are the most commonly used, and that's what you'll use in this quickstart.
138
+
Blob storage supports block blobs, append blobs, and page blobs. Block blobs can be as large as4.7TB, andcan be anything from Excel spreadsheets to large video files. You can use append blobs for logging when you want to write to a fileand then keep adding more information. Page blobs are primarily used for the Virtual Hard Disk (VHD) files that back infrastructure as a service virtual machines (IaaS VMs). Block blobs are the most commonly used. This quickstart uses block blobs.
141
139
142
140
To upload a file to a blob, get the full file path by joining the directory name with the file name on your local drive. You can then upload the file to the specified path using the `create_blob_from_path` method.
There are several upload methods that you can use with Blob storage. For example, if you have a memory stream, you can use the `create_blob_from_stream` method rather than `create_blob_from_path`.
166
164
167
-
Block blobs can be as large as 4.7 TB, and can be anything from Excel spreadsheets to large video files. Page blobs are primarily used for the VHD files that back IaaS VMs. The system uses append blobs for logging, like when you want to write to a file and then keep adding more information. Most objects stored in Blob storage are block blobs.
168
-
169
165
### List the blobs in a container
170
166
171
-
Get a list of files in the container with the `list_blobs` method. This method returns a generator. The following code retrieves the list of blobs—then loops through them—showing the names of the blobs found in a container.
167
+
The following code creates a `generator`forthe `list_blobs` method. The code loops through the list of blobsinthe container and prints their names to the console.
172
168
173
169
```python
174
170
# List the blobs in the container.
@@ -182,7 +178,7 @@ for blob in generator:
182
178
183
179
184
180
Download blobs to your local disk using the `get_blob_to_path` method.
185
-
The following code downloads the blob uploaded in a previous section. The system adds *\_DOWNLOADED*as a suffix to the blob name so you can see both files on local disk.
181
+
The following code downloads the blob you uploaded previously. The system appends *_DOWNLOADED* to the blob name so you can see both files on your local disk.”
186
182
187
183
```python
188
184
# Download the blob(s).
@@ -215,13 +211,10 @@ For more about Python development with Blob storage, see these additional resour
215
211
### Client library reference and samples
216
212
217
213
- For more about the Python client library, see the [Azure Storage libraries for Python](https://docs.microsoft.com/python/api/overview/azure/storage).
218
-
- Explore [blob storage samples](https://azure.microsoft.com/resources/samples/?sort=0&service=storage&platform=python&term=blob) written using the Python client library.
214
+
- Explore [Blob storage samples](https://azure.microsoft.com/resources/samples/?sort=0&service=storage&platform=python&term=blob) written using the Python client library.
219
215
220
216
## Next steps
221
217
222
-
In this quickstart, you learned how to transfer files between a local disk and Azure Blob storage using Python. To learn more about working with Blob storage, continue to the Blob storage How-to.
218
+
In this quickstart, you learned how to transfer files between a local disk and Azure Blob storage using Python.
For more about the Storage Explorer and Blobs, see [Manage Azure Blob storage resources with Storage Explorer](../../vs-azure-tools-storage-explorer-blobs.md?toc=%2fazure%2fstorage%2fblobs%2ftoc.json).
Copy file name to clipboardExpand all lines: includes/storage-copy-account-key-portal.md
+4-5Lines changed: 4 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,10 +14,9 @@ ms.custom: "include file"
14
14
15
15
The sample application needs to authorize access to your storage account. Provide your storage account credentials to the application in the form of a connection string. To view your storage account credentials:
16
16
17
-
1. Sign in to the [Azure portal](https://portal.azure.com).
18
-
2. Locate your storage account.
19
-
3. In the **Settings** section of the storage account overview, select **Access keys**. Your account access keys and connection string are displayed.
20
-
4. Note the name of your storage account, which you'll need for authorization.
21
-
5. Find the **Key** value under **key1**, and select **Copy** to copy the account key.
17
+
1. In to the [Azure portal](https://portal.azure.com) go to your storage account.
18
+
1. In the **Settings** section of the storage account overview, select **Access keys** to display your account access keys and connection string.
19
+
1. Note the name of your storage account, which you'll need for authorization.
20
+
1. Find the **Key** value under **key1**, and select **Copy** to copy the account key.
22
21
23
22

Copy file name to clipboardExpand all lines: includes/storage-quickstart-prereq-include.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,6 @@ ms.author: tamram
10
10
ms.custom: "include file"
11
11
---
12
12
13
-
To access Azure Storage, you'll need an Azure subscription. If you don't already have a subscription, then create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
13
+
To access Azure Storage, you'll need an Azure subscription. If you don't already have a subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
14
14
15
15
All access to Azure Storage takes place through a storage account. For this quickstart, create a storage account using the [Azure portal](https://portal.azure.com/), Azure PowerShell, or Azure CLI. For help creating the account, see [Create a storage account](../articles/storage/common/storage-quickstart-create-account.md).
0 commit comments