Skip to content

Commit 1a8467f

Browse files
Review pass
1 parent 02e07b4 commit 1a8467f

File tree

3 files changed

+35
-12
lines changed

3 files changed

+35
-12
lines changed

articles/storage/blobs/storage-blob-container-lease-python.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
title: Create and manage blob or container leases with Python
2+
title: Create and manage container leases with Python
33
titleSuffix: Azure Storage
4-
description: Learn how to manage a lock on a blob or container in your Azure Storage account using the Python client library.
4+
description: Learn how to manage a lock on a container in your Azure Storage account using the Python client library.
55
services: storage
66
author: pauljewellmsft
77
ms.author: pauljewell
@@ -14,7 +14,7 @@ ms.devlang: python
1414
ms.custom: devx-track-python, devguide-python
1515
---
1616

17-
# Create and manage blob container leases with Python
17+
# Create and manage container leases with Python
1818

1919
This article shows how to create and manage container leases using the [Azure Storage client library for Python](/python/api/overview/azure/storage).
2020

@@ -24,11 +24,15 @@ You can use the Python client library to acquire, renew, release and break lease
2424

2525
## Acquire a lease
2626

27-
When you acquire a lease, you'll obtain a lease ID that your code can use to operate on the blob or container. To acquire a lease, create an instance of the [BlobLeaseClient](/python/api/azure-storage-blob/azure.storage.blob.blobleaseclient) class, and then use the following method:
27+
When you acquire a lease, you'll obtain a lease ID that your code can use to operate on the container. To acquire a lease, create an instance of the [BlobLeaseClient](/python/api/azure-storage-blob/azure.storage.blob.blobleaseclient) class, and then use the following method:
2828

2929
- [BlobLeaseClient.acquire](/python/api/azure-storage-blob/azure.storage.blob.blobleaseclient#azure-storage-blob-blobleaseclient-acquire)
3030

31-
The following example acquires a 30-second lease for a blob:
31+
You can also acquire a lease using the following method from the [ContainerClient](/python/api/azure-storage-blob/azure.storage.blob.containerclient) class:
32+
33+
- [ContainerClient.acquire_lease](/python/api/azure-storage-blob/azure.storage.blob.containerclient#azure-storage-blob-containerclient-acquire-lease)
34+
35+
The following example acquires a 30-second lease on a container:
3236

3337
:::code language="python" source="~/azure-storage-snippets/blobs/howto/python/blob-devguide-py/blob-devguide-containers.py" id="Snippet_acquire_container_lease":::
3438

@@ -38,7 +42,7 @@ If your lease expires, you can renew it. To renew a lease, use the following met
3842

3943
- [BlobLeaseClient.renew](/python/api/azure-storage-blob/azure.storage.blob.blobleaseclient#azure-storage-blob-blobleaseclient-renew)
4044

41-
The following example renews a lease for a blob:
45+
The following example renews a lease for a container:
4246

4347
:::code language="python" source="~/azure-storage-snippets/blobs/howto/python/blob-devguide-py/blob-devguide-containers.py" id="Snippet_renew_container_lease":::
4448

@@ -48,7 +52,7 @@ You can either wait for a lease to expire or explicitly release it. When you rel
4852

4953
- [BlobLeaseClient.release](/python/api/azure-storage-blob/azure.storage.blob.blobleaseclient#azure-storage-blob-blobleaseclient-release)
5054

51-
The following example releases the lease on a blob:
55+
The following example releases the lease on a container:
5256

5357
:::code language="python" source="~/azure-storage-snippets/blobs/howto/python/blob-devguide-py/blob-devguide-containers.py" id="Snippet_release_container_lease":::
5458

@@ -58,7 +62,7 @@ When you break a lease, the lease ends, but other clients can't acquire a lease
5862

5963
- [BlobLeaseClient.break_lease](/python/api/azure-storage-blob/azure.storage.blob.blobleaseclient#azure-storage-blob-blobleaseclient-break-lease)
6064

61-
The following example breaks the lease on a blob:
65+
The following example breaks the lease on a container:
6266

6367
:::code language="python" source="~/azure-storage-snippets/blobs/howto/python/blob-devguide-py/blob-devguide-containers.py" id="Snippet_break_container_lease":::
6468

articles/storage/blobs/storage-blob-containers-list-python.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ To filter the list of containers, specify a string or character for the `name_st
3434

3535
## Code examples
3636

37-
The following example lists all containers names and any associated metadata:
37+
The following example lists all containers and metadata. You can include container metadata by setting `include_metadata` to :
3838

3939
:::code language="python" source="~/azure-storage-snippets/blobs/howto/python/blob-devguide-py/blob-devguide-containers.py" id="Snippet_list_containers":::
4040

41-
The following example lists only containers that begin with a specified prefix:
41+
The following example lists only containers that begin with a prefix specified in the `name_starts_with` parameter:
4242

4343
:::code language="python" source="~/azure-storage-snippets/blobs/howto/python/blob-devguide-py/blob-devguide-containers.py" id="Snippet_list_containers_prefix":::
4444

45-
You can also specify a limit for the number of results per page:
45+
You can also specify a limit for the number of results per page. This example passes in `results_per_page` and paginates the results:
4646

4747
:::code language="python" source="~/azure-storage-snippets/blobs/howto/python/blob-devguide-py/blob-devguide-containers.py" id="Snippet_list_containers_pages":::
4848

articles/storage/blobs/storage-blob-python-get-started.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,36 @@ ms.custom: devx-track-python, devguide-python
1515

1616
# Get started with Azure Blob Storage and Python
1717

18-
This article shows you how to connect to Azure Blob Storage by using the Azure Blob Storage client library Python. Once connected, your code can operate on containers, blobs, and features of the Blob Storage service.
18+
This article shows you how to connect to Azure Blob Storage by using the Azure Blob Storage client library for Python. Once connected, your code can operate on containers, blobs, and features of the Blob Storage service.
1919

2020
[API reference documentation](/python/api/azure-storage-blob) | [Library source code](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/storage/azure-storage-blob) | [Package (PyPi)](https://pypi.org/project/azure-storage-blob/) | [Samples](../common/storage-samples-python.md?toc=/azure/storage/blobs/toc.json#blob-samples)
2121

2222
## Prerequisites
2323

2424
- Azure subscription - [create one for free](https://azure.microsoft.com/free/)
2525
- Azure storage account - [create a storage account](../common/storage-account-create.md)
26+
- [Python](https://www.python.org/downloads/) 3.6+
2627

2728
## Set up your project
2829

30+
This section walks you through preparing a project to work with the Azure Blob Storage client library for Python.
31+
32+
From your project directory, install packages for the Azure Blob Storage and Azure Identity client libraries using the `pip install` command. The **azure-identity** package is needed for passwordless connections to Azure services.
33+
34+
```console
35+
pip install azure-storage-blob azure-identity
36+
```
37+
38+
Then open your code file and add the necessary import statements. In this example, we add the following to our *.py* file:
39+
40+
```python
41+
from azure.identity import DefaultAzureCredential
42+
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient
43+
```
44+
45+
Blob client library information:
46+
- [azure.storage.blob](/python/api/azure-storage-blob/azure.storage.blob): Contains the primary classes (_client objects_) that you can use to operate on the service, containers, and blobs.
47+
2948
## Authorize access and connect to Blob Storage
3049

3150
To connect to Blob Storage, create an instance of the [BlobServiceClient](/python/api/azure-storage-blob/azure.storage.blob.blobserviceclient) class. This object is your starting point. You can use it to operate on the blob service instance and its containers. You can create a `BlobServiceClient` object by using an Azure Active Directory (Azure AD) authorization token, an account access key, or a shared access signature (SAS).

0 commit comments

Comments
 (0)