Skip to content

Commit daec816

Browse files
committed
1561426, incorporated second round of peer review feedback.
1 parent 906c771 commit daec816

File tree

3 files changed

+30
-38
lines changed

3 files changed

+30
-38
lines changed

articles/storage/blobs/storage-quickstart-blobs-python.md

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ms.topic: quickstart
1111

1212
# Quickstart: Upload, download, and list blobs with Python
1313

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).
1515

1616
[!INCLUDE [storage-multi-protocol-access-preview](../../../includes/storage-multi-protocol-access-preview.md)]
1717

@@ -29,13 +29,13 @@ Make sure you have the following additional prerequisites installed:
2929

3030
The [sample application](https://github.com/Azure-Samples/storage-blobs-python-quickstart.git) in this quickstart is a basic Python application.
3131

32-
Use [git](https://git-scm.com/) to download a copy of the application to your development environment.
32+
Use the following [git](https://git-scm.com/) command to download the application to your development environment.
3333

3434
```bash
3535
git clone https://github.com/Azure-Samples/storage-blobs-python-quickstart.git
3636
```
3737

38-
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.
3939

4040
[!INCLUDE [storage-copy-account-key-portal](../../../includes/storage-copy-account-key-portal.md)]
4141

@@ -56,7 +56,7 @@ In the application, provide your storage account name and account key to create
5656

5757
## Run the sample
5858

59-
This sample creates a test file in the *Documents* folder. The sample program uploads the test file to Blob storage, lists the blobs in the container, and downloads the file with a new name.
59+
The sample program creates a test file in your *Documents* folder, uploads the file to Blob storage, lists the blobs in the file, and downloads the file with a new name.
6060

6161
1. Install the dependencies:
6262

@@ -89,36 +89,23 @@ This sample creates a test file in the *Documents* folder. The sample program up
8989
Downloading blob to C:\Users\azureuser\Documents\QuickStart_9f4ed0f9-22d3-43e1-98d0-8b2c05c01078_DOWNLOADED.txt
9090
```
9191

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.
9393

94-
* QuickStart_\<universally-unique-identifier\>
95-
* QuickStart_\<universally-unique-identifier\>_DOWNLOADED
94+
* *QuickStart_\<universally-unique-identifier\>*
95+
* *QuickStart_\<universally-unique-identifier\>_DOWNLOADED*
9696

9797
1. You can open them and see they're the same.
9898

9999
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.
100100

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.
104102

105103
## Learn about the sample code
106104

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* file to look at the code.
108106

109107
### Get references to the storage objects
110108

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-
122109
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`.
123110

124111
```python
@@ -135,9 +122,20 @@ block_blob_service.set_container_acl(
135122
container_name, public_access=PublicAccess.Container)
136123
```
137124

125+
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+
138136
### Upload blobs to the container
139137

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 as 4.7 TB, and can be anything from Excel spreadsheets to large video files. You can use append blobs for logging when you want to write to a file and 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.
141139

142140
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.
143141

@@ -164,11 +162,9 @@ block_blob_service.create_blob_from_path(
164162

165163
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`.
166164

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-
169165
### List the blobs in a container
170166

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&mdash;then loops through them&mdash;showing the names of the blobs found in a container.
167+
The following code creates a `generator` for the `list_blobs` method. The code loops through the list of blobs in the container and prints their names to the console.
172168

173169
```python
174170
# List the blobs in the container.
@@ -182,7 +178,7 @@ for blob in generator:
182178

183179

184180
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.
186182

187183
```python
188184
# Download the blob(s).
@@ -215,13 +211,10 @@ For more about Python development with Blob storage, see these additional resour
215211
### Client library reference and samples
216212

217213
- 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.
219215

220216
## Next steps
221217

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.
223219

224-
> [!div class="nextstepaction"]
225-
> [Blob Storage Operations How-To](./storage-python-how-to-use-blob-storage.md)
226-
227220
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).

includes/storage-copy-account-key-portal.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ ms.custom: "include file"
1414

1515
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:
1616

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.
2221

2322
![Screenshot showing how to copy your account key from the Azure portal](media/storage-copy-account-key-portal/portal-account-key.png)

includes/storage-quickstart-prereq-include.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ ms.author: tamram
1010
ms.custom: "include file"
1111
---
1212

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.
1414

1515
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

Comments
 (0)